1
1
/*
2
- * Copyright 2020-2020 the original author or authors.
2
+ * Copyright 2012-2021 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
32
32
import org .springframework .util .FileCopyUtils ;
33
33
34
34
import static org .assertj .core .api .Assertions .assertThat ;
35
+ import static org .assertj .core .api .Assertions .entry ;
35
36
36
37
/**
37
38
* Tests for {@link UpgradeApplicator}.
@@ -47,13 +48,14 @@ class UpgradeApplicatorTests {
47
48
void whenUpgradeIsAppliedToLibraryWithVersionThenBomIsUpdated () throws IOException {
48
49
File bom = new File (this .temp , "bom.gradle" );
49
50
FileCopyUtils .copy (new File ("src/test/resources/bom.gradle" ), bom );
51
+ String originalContents = new String (Files .readAllBytes (bom .toPath ()), StandardCharsets .UTF_8 );
50
52
File gradleProperties = new File (this .temp , "gradle.properties" );
51
53
FileCopyUtils .copy (new File ("src/test/resources/gradle.properties" ), gradleProperties );
52
54
new UpgradeApplicator (bom .toPath (), gradleProperties .toPath ())
53
55
.apply (new Upgrade (new Library ("ActiveMQ" , DependencyVersion .parse ("5.15.11" ), null , null ),
54
56
DependencyVersion .parse ("5.16" )));
55
57
String bomContents = new String (Files .readAllBytes (bom .toPath ()), StandardCharsets .UTF_8 );
56
- assertThat (bomContents ). contains ( "library( \" ActiveMQ \" , \" 5.16 \" )" );
58
+ assertThat (bomContents . length ()). isEqualTo ( originalContents . length () - 3 );
57
59
}
58
60
59
61
@ Test
@@ -62,14 +64,14 @@ void whenUpgradeIsAppliedToLibraryWithVersionPropertyThenGradlePropertiesIsUpdat
62
64
FileCopyUtils .copy (new File ("src/test/resources/bom.gradle" ), bom );
63
65
File gradleProperties = new File (this .temp , "gradle.properties" );
64
66
FileCopyUtils .copy (new File ("src/test/resources/gradle.properties" ), gradleProperties );
65
- new UpgradeApplicator (bom .toPath (), gradleProperties .toPath ())
66
- .apply (new Upgrade (new Library ("Kotlin" , DependencyVersion .parse ("1.3.70" ), null , null ),
67
- DependencyVersion .parse ("1.3.71" )));
67
+ new UpgradeApplicator (bom .toPath (), gradleProperties .toPath ()).apply (new Upgrade (
68
+ new Library ("Kotlin" , DependencyVersion .parse ("1.3.70" ), null , null ), DependencyVersion .parse ("1.4" )));
68
69
Properties properties = new Properties ();
69
70
try (InputStream in = new FileInputStream (gradleProperties )) {
70
71
properties .load (in );
71
72
}
72
- assertThat (properties ).containsEntry ("kotlinVersion" , "1.3.71" );
73
+ assertThat (properties ).containsOnly (entry ("a" , "alpha" ), entry ("b" , "bravo" ), entry ("kotlinVersion" , "1.4" ),
74
+ entry ("t" , "tango" ));
73
75
}
74
76
75
77
}
0 commit comments