mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-19 18:22:26 +08:00
Polish
This commit is contained in:
@@ -38,7 +38,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.fail;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests for stats processing.
|
* Integration tests for stats processing.
|
||||||
@@ -142,13 +142,9 @@ class MainControllerStatsIntegrationTests extends AbstractFullStackInitializrInt
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void invalidProjectSillHasStats() {
|
void invalidProjectSillHasStats() {
|
||||||
try {
|
assertThatExceptionOfType(HttpClientErrorException.class)
|
||||||
downloadArchive("/starter.zip?type=invalid-type");
|
.isThrownBy(() -> downloadArchive("/starter.zip?type=invalid-type"))
|
||||||
fail("Should have failed to generate project with invalid type");
|
.satisfies((ex) -> assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST));
|
||||||
}
|
|
||||||
catch (HttpClientErrorException ex) {
|
|
||||||
assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
assertThat(this.statsMockController.stats).as("No stat got generated").hasSize(1);
|
assertThat(this.statsMockController.stats).as("No stat got generated").hasSize(1);
|
||||||
StatsMockController.Content content = this.statsMockController.stats.get(0);
|
StatsMockController.Content content = this.statsMockController.stats.get(0);
|
||||||
|
|
||||||
|
@@ -31,7 +31,6 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
import static org.assertj.core.api.Assertions.fail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests for {@link ProjectGenerationController}.
|
* Integration tests for {@link ProjectGenerationController}.
|
||||||
@@ -148,27 +147,22 @@ class ProjectGenerationControllerIntegrationTests extends AbstractInitializrCont
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void missingDependencyProperException() {
|
void missingDependencyProperException() {
|
||||||
try {
|
assertThatExceptionOfType(HttpClientErrorException.class)
|
||||||
downloadArchive("/starter.zip?dependencies=foo:bar");
|
.isThrownBy(() -> downloadArchive("/starter.zip?dependencies=foo:bar")).satisfies((ex) -> {
|
||||||
fail("Should have failed");
|
|
||||||
}
|
|
||||||
catch (HttpClientErrorException ex) {
|
|
||||||
assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
|
assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
|
||||||
assertStandardErrorBody(ex.getResponseBodyAsString(),
|
assertStandardErrorBody(ex.getResponseBodyAsString(),
|
||||||
"Unknown dependency 'foo:bar' check project metadata");
|
"Unknown dependency 'foo:bar' check project metadata");
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void invalidDependencyProperException() {
|
void invalidDependencyProperException() {
|
||||||
try {
|
assertThatExceptionOfType(HttpClientErrorException.class)
|
||||||
downloadArchive("/starter.zip?dependencies=foo");
|
.isThrownBy(() -> downloadArchive("/starter.zip?dependencies=foo")).satisfies((ex) -> {
|
||||||
fail("Should have failed");
|
|
||||||
}
|
|
||||||
catch (HttpClientErrorException ex) {
|
|
||||||
assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
|
assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
|
||||||
assertStandardErrorBody(ex.getResponseBodyAsString(), "Unknown dependency 'foo' check project metadata");
|
assertStandardErrorBody(ex.getResponseBodyAsString(),
|
||||||
}
|
"Unknown dependency 'foo' check project metadata");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -32,7 +32,6 @@ import org.springframework.test.web.client.MockRestServiceServer;
|
|||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.fail;
|
|
||||||
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
|
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
|
||||||
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
|
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ class SpringBootMetadataReaderTests {
|
|||||||
assertThat(it.getName()).as("Name must be set").isNotNull();
|
assertThat(it.getName()).as("Name must be set").isNotNull();
|
||||||
if (it.isDefault()) {
|
if (it.isDefault()) {
|
||||||
if (defaultFound.get()) {
|
if (defaultFound.get()) {
|
||||||
fail("One default version was already found " + it.getId());
|
throw new AssertionError("One default version was already found " + it.getId());
|
||||||
}
|
}
|
||||||
defaultFound.set(true);
|
defaultFound.set(true);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user