Polish contribution

Closes gh-655
This commit is contained in:
Stephane Nicoll
2018-04-16 16:21:30 +02:00
parent 593759f321
commit 432be66c5a
11 changed files with 18 additions and 22 deletions

View File

@@ -163,8 +163,7 @@ public class MainControllerStatsIntegrationTests
assertThat(json.get("invalid").booleanValue()).isEqualTo(true); assertThat(json.get("invalid").booleanValue()).isEqualTo(true);
assertThat(json.get("invalidType").booleanValue()).isEqualTo(true); assertThat(json.get("invalidType").booleanValue()).isEqualTo(true);
assertThat(json.get("errorMessage")).isNotNull(); assertThat(json.get("errorMessage")).isNotNull();
assertThat(json.get("errorMessage").textValue().contains("invalid-type")) assertThat(json.get("errorMessage").textValue()).contains("invalid-type");
.isTrue();
} }
@Test @Test

View File

@@ -20,7 +20,7 @@ package io.spring.initializr.metadata;
* Metadata with a default value. * Metadata with a default value.
* *
* @param <T> The value type * @param <T> The value type
* @author Stephane Nicoll * @author Dave Syer
*/ */
public interface Defaultable<T> { public interface Defaultable<T> {

View File

@@ -19,7 +19,7 @@ package io.spring.initializr.metadata;
/** /**
* An item that can describe itself. * An item that can describe itself.
* *
* @author Stephane Nicoll * @author Dave Syer
*/ */
public interface Describable { public interface Describable {

View File

@@ -65,9 +65,7 @@ public class LinkTests {
Link link = Link.create("reference", "https://example.com/{a}/2/{b}"); Link link = Link.create("reference", "https://example.com/{a}/2/{b}");
link.resolve(); link.resolve();
assertThat(link.isTemplated()).isTrue(); assertThat(link.isTemplated()).isTrue();
assertThat(link.getTemplateVariables()).hasSize(2); assertThat(link.getTemplateVariables()).containsExactlyInAnyOrder("a", "b");
assertThat(link.getTemplateVariables().contains("a")).isTrue();
assertThat(link.getTemplateVariables().contains("b")).isTrue();
} }
@Test @Test

View File

@@ -106,6 +106,7 @@ public abstract class AbstractInitializrIntegrationTests {
protected void validateContentType(ResponseEntity<String> response, protected void validateContentType(ResponseEntity<String> response,
MediaType expected) { MediaType expected) {
MediaType actual = response.getHeaders().getContentType(); MediaType actual = response.getHeaders().getContentType();
assertThat(actual).isNotNull();
assertThat(actual.isCompatibleWith(expected)) assertThat(actual.isCompatibleWith(expected))
.as("Non compatible media-type, expected " + expected + ", got " + actual) .as("Non compatible media-type, expected " + expected + ", got " + actual)
.isTrue(); .isTrue();

View File

@@ -72,8 +72,8 @@ public class InitializrMetadataJsonMapperTests {
int first = json.indexOf("https://example.com/how-to"); int first = json.indexOf("https://example.com/how-to");
int second = json.indexOf("https://example.com/doc"); int second = json.indexOf("https://example.com/doc");
// JSON objects are not ordered // JSON objects are not ordered
assertThat(first > 0).isTrue(); assertThat(first).isGreaterThan(0);
assertThat(second > 0).isTrue(); assertThat(second).isGreaterThan(0);
} }
private Object get(JsonNode result, String path) { private Object get(JsonNode result, String path) {

View File

@@ -83,7 +83,7 @@ public class LinkMapperTests {
links.add(Link.create("second", "https://example.com")); links.add(Link.create("second", "https://example.com"));
ObjectNode model = LinkMapper.mapLinks(links); ObjectNode model = LinkMapper.mapLinks(links);
String json = model.toString(); String json = model.toString();
assertThat(json.indexOf("first") < json.indexOf("second")).isTrue(); assertThat(json.indexOf("first")).isLessThan(json.indexOf("second"));
} }
@Test @Test
@@ -94,7 +94,7 @@ public class LinkMapperTests {
links.add(Link.create("first", "https://example.com")); links.add(Link.create("first", "https://example.com"));
ObjectNode model = LinkMapper.mapLinks(links); ObjectNode model = LinkMapper.mapLinks(links);
String json = model.toString(); String json = model.toString();
assertThat(json.indexOf("first") < json.indexOf("second")).isTrue(); assertThat(json.indexOf("first")).isLessThan(json.indexOf("second"));
} }
} }

View File

@@ -46,12 +46,11 @@ public class MainControllerDefaultsIntegrationTests
@Test @Test
public void defaultsAppliedToHome() { public void defaultsAppliedToHome() {
String body = htmlHome(); String body = htmlHome();
assertThat(body.contains("org.foo")).as("custom groupId not found").isTrue(); assertThat(body).as("custom groupId not found").contains("org.foo");
assertThat(body.contains("foo-bar")).as("custom artifactId not found").isTrue(); assertThat(body).as("custom artifactId not found").contains("foo-bar");
assertThat(body.contains("FooBar")).as("custom name not found").isTrue(); assertThat(body).as("custom name not found").contains("FooBar");
assertThat(body.contains("FooBar Project")).as("custom description not found") assertThat(body).as("custom description not found").contains("FooBar Project");
.isTrue(); assertThat(body).as("custom package not found").contains("org.foo.demo");
assertThat(body.contains("org.foo.demo")).as("custom package not found").isTrue();
} }
} }

View File

@@ -48,9 +48,8 @@ public class MainControllerEnvIntegrationTests
public void doNotForceSsl() { public void doNotForceSsl() {
ResponseEntity<String> response = invokeHome("curl/1.2.4", "*/*"); ResponseEntity<String> response = invokeHome("curl/1.2.4", "*/*");
String body = response.getBody(); String body = response.getBody();
assertThat(body.contains("http://start.spring.io/")).as("Must not force https") assertThat(body).as("Must not force https").contains("http://start.spring.io/");
.isTrue(); assertThat(body).as("Must not force https").doesNotContain("https://");
assertThat(body.contains("https://")).as("Must not force https").isFalse();
} }
@Test @Test

View File

@@ -406,7 +406,7 @@ public class MainControllerIntegrationTests
byte[] body = getRestTemplate().getForObject(createUrl("starter.zip"), byte[] body = getRestTemplate().getForObject(createUrl("starter.zip"),
byte[].class); byte[].class);
assertThat(body).isNotNull(); assertThat(body).isNotNull();
assertThat(body.length > 100).isTrue(); assertThat(body.length).isGreaterThan(100);
} }
@Test @Test

View File

@@ -374,7 +374,7 @@ public class ProjectGenerationSmokeTests
private File getArchive(String fileName) { private File getArchive(String fileName) {
File archive = new File(this.downloadDir, fileName); File archive = new File(this.downloadDir, fileName);
assertThat(archive.exists()).isTrue(); assertThat(archive).exists();
return archive; return archive;
} }