mirror of
https://gitee.com/dcren/initializr.git
synced 2025-12-02 11:24:04 +08:00
Apply automatic cleanup rules
Apply code cleanup rules from Eclipse for better consistency.
This commit is contained in:
@@ -58,7 +58,7 @@ class InitializrStatsAutoConfiguration {
|
||||
InitializrMetadataProvider provider,
|
||||
RestTemplateBuilder restTemplateBuilder) {
|
||||
return new ProjectGenerationStatPublisher(
|
||||
new ProjectRequestDocumentFactory(provider), statsProperties,
|
||||
new ProjectRequestDocumentFactory(provider), this.statsProperties,
|
||||
restTemplateBuilder, statsRetryTemplate());
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class InitializrStatsAutoConfiguration {
|
||||
backOffPolicy.setInitialInterval(3000L);
|
||||
backOffPolicy.setMultiplier(3);
|
||||
SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(
|
||||
statsProperties.getElastic().getMaxAttempts(),
|
||||
this.statsProperties.getElastic().getMaxAttempts(),
|
||||
Collections.singletonMap(Exception.class, true));
|
||||
retryTemplate.setBackOffPolicy(backOffPolicy);
|
||||
retryTemplate.setRetryPolicy(retryPolicy);
|
||||
|
||||
@@ -41,17 +41,18 @@ public class BomRangesInfoContributor implements InfoContributor {
|
||||
@Override
|
||||
public void contribute(Info.Builder builder) {
|
||||
Map<String, Object> details = new LinkedHashMap<>();
|
||||
metadataProvider.get().getConfiguration().getEnv().getBoms().forEach((k, v) -> {
|
||||
if (v.getMappings() != null && !v.getMappings().isEmpty()) {
|
||||
Map<String, Object> bom = new LinkedHashMap<>();
|
||||
v.getMappings().forEach(it -> {
|
||||
String requirement = "Spring Boot "
|
||||
+ it.determineVersionRangeRequirement();
|
||||
bom.put(it.getVersion(), requirement);
|
||||
this.metadataProvider.get().getConfiguration().getEnv().getBoms()
|
||||
.forEach((k, v) -> {
|
||||
if (v.getMappings() != null && !v.getMappings().isEmpty()) {
|
||||
Map<String, Object> bom = new LinkedHashMap<>();
|
||||
v.getMappings().forEach(it -> {
|
||||
String requirement = "Spring Boot "
|
||||
+ it.determineVersionRangeRequirement();
|
||||
bom.put(it.getVersion(), requirement);
|
||||
});
|
||||
details.put(k, bom);
|
||||
}
|
||||
});
|
||||
details.put(k, bom);
|
||||
}
|
||||
});
|
||||
if (!details.isEmpty()) {
|
||||
builder.withDetail("bom-ranges", details);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class DependencyRangesInfoContributor implements InfoContributor {
|
||||
@Override
|
||||
public void contribute(Info.Builder builder) {
|
||||
Map<String, Object> details = new LinkedHashMap<>();
|
||||
metadataProvider.get().getDependencies().getAll().forEach(d -> {
|
||||
this.metadataProvider.get().getDependencies().getAll().forEach(d -> {
|
||||
if (d.getBom() == null) {
|
||||
if (!ObjectUtils.isEmpty(d.getMappings())) {
|
||||
Map<String, VersionRange> dep = new LinkedHashMap<>();
|
||||
|
||||
@@ -122,7 +122,7 @@ public class ProjectGenerationMetricsListener {
|
||||
}
|
||||
|
||||
protected void increment(String key) {
|
||||
meterRegistry.counter(key).increment();
|
||||
this.meterRegistry.counter(key).increment();
|
||||
}
|
||||
|
||||
protected String key(String part) {
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ProjectGenerationStatPublisher {
|
||||
public void handleEvent(ProjectRequestEvent event) {
|
||||
String json = null;
|
||||
try {
|
||||
ProjectRequestDocument document = documentFactory.createDocument(event);
|
||||
ProjectRequestDocument document = this.documentFactory.createDocument(event);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Publishing " + document);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class ProjectGenerationStatPublisher {
|
||||
|
||||
this.retryTemplate
|
||||
.execute((RetryCallback<Void, RuntimeException>) context -> {
|
||||
restTemplate.exchange(request, String.class);
|
||||
this.restTemplate.exchange(request, String.class);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class ProjectRequestDocument {
|
||||
private final List<String> invalidDependencies = new ArrayList<>();
|
||||
|
||||
public long getGenerationTimestamp() {
|
||||
return generationTimestamp;
|
||||
return this.generationTimestamp;
|
||||
}
|
||||
|
||||
public void setGenerationTimestamp(long generationTimestamp) {
|
||||
@@ -79,7 +79,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getRequestIp() {
|
||||
return requestIp;
|
||||
return this.requestIp;
|
||||
}
|
||||
|
||||
public void setRequestIp(String requestIp) {
|
||||
@@ -87,7 +87,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getRequestIpv4() {
|
||||
return requestIpv4;
|
||||
return this.requestIpv4;
|
||||
}
|
||||
|
||||
public void setRequestIpv4(String requestIpv4) {
|
||||
@@ -95,7 +95,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getRequestCountry() {
|
||||
return requestCountry;
|
||||
return this.requestCountry;
|
||||
}
|
||||
|
||||
public void setRequestCountry(String requestCountry) {
|
||||
@@ -103,7 +103,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
return this.clientId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
@@ -111,7 +111,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getClientVersion() {
|
||||
return clientVersion;
|
||||
return this.clientVersion;
|
||||
}
|
||||
|
||||
public void setClientVersion(String clientVersion) {
|
||||
@@ -119,7 +119,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
@@ -127,7 +127,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getArtifactId() {
|
||||
return artifactId;
|
||||
return this.artifactId;
|
||||
}
|
||||
|
||||
public void setArtifactId(String artifactId) {
|
||||
@@ -135,7 +135,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
return this.packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
@@ -143,7 +143,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getBootVersion() {
|
||||
return bootVersion;
|
||||
return this.bootVersion;
|
||||
}
|
||||
|
||||
public void setBootVersion(String bootVersion) {
|
||||
@@ -151,7 +151,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getJavaVersion() {
|
||||
return javaVersion;
|
||||
return this.javaVersion;
|
||||
}
|
||||
|
||||
public void setJavaVersion(String javaVersion) {
|
||||
@@ -159,7 +159,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
return this.language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
@@ -167,7 +167,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getPackaging() {
|
||||
return packaging;
|
||||
return this.packaging;
|
||||
}
|
||||
|
||||
public void setPackaging(String packaging) {
|
||||
@@ -175,7 +175,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
@@ -183,7 +183,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
return this.errorMessage;
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
@@ -191,7 +191,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public boolean isInvalid() {
|
||||
return invalid;
|
||||
return this.invalid;
|
||||
}
|
||||
|
||||
public void setInvalid(boolean invalid) {
|
||||
@@ -199,7 +199,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public boolean isInvalidJavaVersion() {
|
||||
return invalidJavaVersion;
|
||||
return this.invalidJavaVersion;
|
||||
}
|
||||
|
||||
public void setInvalidJavaVersion(boolean invalidJavaVersion) {
|
||||
@@ -207,7 +207,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public boolean isInvalidLanguage() {
|
||||
return invalidLanguage;
|
||||
return this.invalidLanguage;
|
||||
}
|
||||
|
||||
public void setInvalidLanguage(boolean invalidLanguage) {
|
||||
@@ -215,7 +215,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public boolean isInvalidPackaging() {
|
||||
return invalidPackaging;
|
||||
return this.invalidPackaging;
|
||||
}
|
||||
|
||||
public void setInvalidPackaging(boolean invalidPackaging) {
|
||||
@@ -223,7 +223,7 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public boolean isInvalidType() {
|
||||
return invalidType;
|
||||
return this.invalidType;
|
||||
}
|
||||
|
||||
public void setInvalidType(boolean invalidType) {
|
||||
@@ -231,37 +231,45 @@ public class ProjectRequestDocument {
|
||||
}
|
||||
|
||||
public List<String> getDependencies() {
|
||||
return dependencies;
|
||||
return this.dependencies;
|
||||
}
|
||||
|
||||
public List<String> getInvalidDependencies() {
|
||||
return invalidDependencies;
|
||||
return this.invalidDependencies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectRequestDocument [generationTimestamp=" + generationTimestamp + ", "
|
||||
+ (requestIp != null ? "requestIp=" + requestIp + ", " : "")
|
||||
+ (requestIpv4 != null ? "requestIpv4=" + requestIpv4 + ", " : "")
|
||||
+ (requestCountry != null ? "requestCountry=" + requestCountry + ", "
|
||||
return "ProjectRequestDocument [generationTimestamp=" + this.generationTimestamp
|
||||
+ ", "
|
||||
+ (this.requestIp != null ? "requestIp=" + this.requestIp + ", " : "")
|
||||
+ (this.requestIpv4 != null ? "requestIpv4=" + this.requestIpv4 + ", "
|
||||
: "")
|
||||
+ (clientId != null ? "clientId=" + clientId + ", " : "")
|
||||
+ (clientVersion != null ? "clientVersion=" + clientVersion + ", " : "")
|
||||
+ (groupId != null ? "groupId=" + groupId + ", " : "")
|
||||
+ (artifactId != null ? "artifactId=" + artifactId + ", " : "")
|
||||
+ (packageName != null ? "packageName=" + packageName + ", " : "")
|
||||
+ (bootVersion != null ? "bootVersion=" + bootVersion + ", " : "")
|
||||
+ (javaVersion != null ? "javaVersion=" + javaVersion + ", " : "")
|
||||
+ (language != null ? "language=" + language + ", " : "")
|
||||
+ (packaging != null ? "packaging=" + packaging + ", " : "")
|
||||
+ (type != null ? "type=" + type + ", " : "")
|
||||
+ (dependencies != null ? "dependencies=" + dependencies + ", " : "")
|
||||
+ (errorMessage != null ? "errorMessage=" + errorMessage + ", " : "")
|
||||
+ "invalid=" + invalid + ", invalidJavaVersion=" + invalidJavaVersion
|
||||
+ ", invalidLanguage=" + invalidLanguage + ", invalidPackaging="
|
||||
+ invalidPackaging + ", invalidType=" + invalidType + ", "
|
||||
+ (invalidDependencies != null
|
||||
? "invalidDependencies=" + invalidDependencies : "")
|
||||
+ (this.requestCountry != null
|
||||
? "requestCountry=" + this.requestCountry + ", " : "")
|
||||
+ (this.clientId != null ? "clientId=" + this.clientId + ", " : "")
|
||||
+ (this.clientVersion != null
|
||||
? "clientVersion=" + this.clientVersion + ", " : "")
|
||||
+ (this.groupId != null ? "groupId=" + this.groupId + ", " : "")
|
||||
+ (this.artifactId != null ? "artifactId=" + this.artifactId + ", " : "")
|
||||
+ (this.packageName != null ? "packageName=" + this.packageName + ", "
|
||||
: "")
|
||||
+ (this.bootVersion != null ? "bootVersion=" + this.bootVersion + ", "
|
||||
: "")
|
||||
+ (this.javaVersion != null ? "javaVersion=" + this.javaVersion + ", "
|
||||
: "")
|
||||
+ (this.language != null ? "language=" + this.language + ", " : "")
|
||||
+ (this.packaging != null ? "packaging=" + this.packaging + ", " : "")
|
||||
+ (this.type != null ? "type=" + this.type + ", " : "")
|
||||
+ (this.dependencies != null ? "dependencies=" + this.dependencies + ", "
|
||||
: "")
|
||||
+ (this.errorMessage != null ? "errorMessage=" + this.errorMessage + ", "
|
||||
: "")
|
||||
+ "invalid=" + this.invalid + ", invalidJavaVersion="
|
||||
+ this.invalidJavaVersion + ", invalidLanguage=" + this.invalidLanguage
|
||||
+ ", invalidPackaging=" + this.invalidPackaging + ", invalidType="
|
||||
+ this.invalidType + ", " + (this.invalidDependencies != null
|
||||
? "invalidDependencies=" + this.invalidDependencies : "")
|
||||
+ "]";
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ProjectRequestDocumentFactory {
|
||||
}
|
||||
|
||||
public ProjectRequestDocument createDocument(ProjectRequestEvent event) {
|
||||
InitializrMetadata metadata = metadataProvider.get();
|
||||
InitializrMetadata metadata = this.metadataProvider.get();
|
||||
ProjectRequest request = event.getProjectRequest();
|
||||
|
||||
ProjectRequestDocument document = new ProjectRequestDocument();
|
||||
|
||||
@@ -35,7 +35,7 @@ public class StatsProperties {
|
||||
private final Elastic elastic = new Elastic();
|
||||
|
||||
public Elastic getElastic() {
|
||||
return elastic;
|
||||
return this.elastic;
|
||||
}
|
||||
|
||||
public static final class Elastic {
|
||||
@@ -71,7 +71,7 @@ public class StatsProperties {
|
||||
private int maxAttempts = 3;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
@@ -79,7 +79,7 @@ public class StatsProperties {
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
@@ -87,7 +87,7 @@ public class StatsProperties {
|
||||
}
|
||||
|
||||
public String getIndexName() {
|
||||
return indexName;
|
||||
return this.indexName;
|
||||
}
|
||||
|
||||
public void setIndexName(String indexName) {
|
||||
@@ -95,7 +95,7 @@ public class StatsProperties {
|
||||
}
|
||||
|
||||
public String getEntityName() {
|
||||
return entityName;
|
||||
return this.entityName;
|
||||
}
|
||||
|
||||
public void setEntityName(String entityName) {
|
||||
@@ -103,7 +103,7 @@ public class StatsProperties {
|
||||
}
|
||||
|
||||
public int getMaxAttempts() {
|
||||
return maxAttempts;
|
||||
return this.maxAttempts;
|
||||
}
|
||||
|
||||
public void setMaxAttempts(int maxAttempts) {
|
||||
@@ -111,7 +111,7 @@ public class StatsProperties {
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
return this.uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
@@ -119,7 +119,7 @@ public class StatsProperties {
|
||||
}
|
||||
|
||||
public URI getEntityUrl() {
|
||||
String string = uri + "/" + indexName + "/" + entityName;
|
||||
String string = this.uri + "/" + this.indexName + "/" + this.entityName;
|
||||
try {
|
||||
return new URI(string);
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.spring.initializr.web.AbstractFullStackInitializrIntegrationTests;
|
||||
import io.spring.initializr.web.AbstractInitializrIntegrationTests.Config;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import static io.spring.initializr.web.AbstractInitializrIntegrationTests.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -44,43 +44,43 @@ public class ProjectGenerationMetricsListenerTests {
|
||||
@Before
|
||||
public void setup() {
|
||||
SimpleMeterRegistry meterRegistry = new SimpleMeterRegistry();
|
||||
listener = new ProjectGenerationMetricsListener(meterRegistry);
|
||||
metricsAssert = new MetricsAssert(meterRegistry);
|
||||
this.listener = new ProjectGenerationMetricsListener(meterRegistry);
|
||||
this.metricsAssert = new MetricsAssert(meterRegistry);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void projectGenerationCount() {
|
||||
ProjectRequest request = initialize();
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.requests");
|
||||
this.metricsAssert.hasValue(1, "initializr.requests");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void projectGenerationCountWithFailure() {
|
||||
ProjectRequest request = initialize();
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectFailedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.requests");
|
||||
metricsAssert.hasValue(1, "initializr.failures");
|
||||
this.metricsAssert.hasValue(1, "initializr.requests");
|
||||
this.metricsAssert.hasValue(1, "initializr.failures");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dependencies() {
|
||||
ProjectRequest request = initialize();
|
||||
request.getStyle().addAll(Arrays.asList("security", "spring-data"));
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.dependency.security",
|
||||
this.metricsAssert.hasValue(1, "initializr.dependency.security",
|
||||
"initializr.dependency.spring-data");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noDependencies() {
|
||||
ProjectRequest request = initialize();
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasNoValue("initializr.dependency.");
|
||||
this.metricsAssert.hasNoValue("initializr.dependency.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,9 +88,9 @@ public class ProjectGenerationMetricsListenerTests {
|
||||
ProjectRequest request = initialize();
|
||||
request.getStyle().add("spring-data");
|
||||
request.setPackaging("war");
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.dependency.web",
|
||||
this.metricsAssert.hasValue(1, "initializr.dependency.web",
|
||||
"initializr.dependency.spring-data");
|
||||
}
|
||||
|
||||
@@ -106,110 +106,111 @@ public class ProjectGenerationMetricsListenerTests {
|
||||
request.getStyle().add("foo-old");
|
||||
request.resolve(metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.dependency.foo"); // standard id is used
|
||||
this.metricsAssert.hasValue(1, "initializr.dependency.foo"); // standard id is
|
||||
// used
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultType() {
|
||||
ProjectRequest request = initialize();
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.type.maven-project");
|
||||
this.metricsAssert.hasValue(1, "initializr.type.maven-project");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void explicitType() {
|
||||
ProjectRequest request = initialize();
|
||||
request.setType("gradle-build");
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.type.gradle-build");
|
||||
this.metricsAssert.hasValue(1, "initializr.type.gradle-build");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultPackaging() {
|
||||
ProjectRequest request = initialize();
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.packaging.jar");
|
||||
this.metricsAssert.hasValue(1, "initializr.packaging.jar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void explicitPackaging() {
|
||||
ProjectRequest request = initialize();
|
||||
request.setPackaging("war");
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.packaging.war");
|
||||
this.metricsAssert.hasValue(1, "initializr.packaging.war");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultJavaVersion() {
|
||||
ProjectRequest request = initialize();
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.java_version.1_8");
|
||||
this.metricsAssert.hasValue(1, "initializr.java_version.1_8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void explicitJavaVersion() {
|
||||
ProjectRequest request = initialize();
|
||||
request.setJavaVersion("1.7");
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.java_version.1_7");
|
||||
this.metricsAssert.hasValue(1, "initializr.java_version.1_7");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultLanguage() {
|
||||
ProjectRequest request = initialize();
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.language.java");
|
||||
this.metricsAssert.hasValue(1, "initializr.language.java");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void explicitGroovyLanguage() {
|
||||
ProjectRequest request = initialize();
|
||||
request.setLanguage("groovy");
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.language.groovy");
|
||||
this.metricsAssert.hasValue(1, "initializr.language.groovy");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void explicitKotlinLanguage() {
|
||||
ProjectRequest request = initialize();
|
||||
request.setLanguage("kotlin");
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.language.kotlin");
|
||||
this.metricsAssert.hasValue(1, "initializr.language.kotlin");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultBootVersion() {
|
||||
ProjectRequest request = initialize();
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.boot_version.1_2_3_RELEASE");
|
||||
this.metricsAssert.hasValue(1, "initializr.boot_version.1_2_3_RELEASE");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void explicitBootVersion() {
|
||||
ProjectRequest request = initialize();
|
||||
request.setBootVersion("1.0.2.RELEASE");
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.boot_version.1_0_2_RELEASE");
|
||||
this.metricsAssert.hasValue(1, "initializr.boot_version.1_0_2_RELEASE");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void userAgentAvailable() {
|
||||
ProjectRequest request = initialize();
|
||||
request.getParameters().put("user-agent", "HTTPie/0.9.2");
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.client_id.httpie");
|
||||
this.metricsAssert.hasValue(1, "initializr.client_id.httpie");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -223,9 +224,9 @@ public class ProjectGenerationMetricsListenerTests {
|
||||
request.setBootVersion("1.0.2.RELEASE");
|
||||
request.getParameters().put("user-agent", "SpringBootCli/1.3.0.RELEASE");
|
||||
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.requests", "initializr.dependency.web",
|
||||
this.metricsAssert.hasValue(1, "initializr.requests", "initializr.dependency.web",
|
||||
"initializr.dependency.security", "initializr.type.gradle-project",
|
||||
"initializr.packaging.jar", "initializr.java_version.1_6",
|
||||
"initializr.language.groovy", "initializr.boot_version.1_0_2_RELEASE",
|
||||
@@ -236,32 +237,32 @@ public class ProjectGenerationMetricsListenerTests {
|
||||
public void incrementMetrics() {
|
||||
ProjectRequest request = initialize();
|
||||
request.getStyle().addAll(Arrays.asList("security", "spring-data"));
|
||||
request.resolve(metadata);
|
||||
request.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(request);
|
||||
metricsAssert.hasValue(1, "initializr.requests", "initializr.dependency.security",
|
||||
"initializr.dependency.spring-data");
|
||||
this.metricsAssert.hasValue(1, "initializr.requests",
|
||||
"initializr.dependency.security", "initializr.dependency.spring-data");
|
||||
|
||||
ProjectRequest anotherRequest = initialize();
|
||||
anotherRequest.getStyle().addAll(Arrays.asList("web", "spring-data"));
|
||||
anotherRequest.resolve(metadata);
|
||||
anotherRequest.resolve(this.metadata);
|
||||
fireProjectGeneratedEvent(anotherRequest);
|
||||
metricsAssert.hasValue(2, "initializr.dependency.spring-data",
|
||||
this.metricsAssert.hasValue(2, "initializr.dependency.spring-data",
|
||||
"initializr.dependency.spring-data");
|
||||
metricsAssert.hasValue(1, "initializr.dependency.web",
|
||||
this.metricsAssert.hasValue(1, "initializr.dependency.web",
|
||||
"initializr.dependency.security");
|
||||
}
|
||||
|
||||
private void fireProjectGeneratedEvent(ProjectRequest projectRequest) {
|
||||
listener.onGeneratedProject(new ProjectGeneratedEvent(projectRequest));
|
||||
this.listener.onGeneratedProject(new ProjectGeneratedEvent(projectRequest));
|
||||
}
|
||||
|
||||
private void fireProjectFailedEvent(ProjectRequest projectRequest) {
|
||||
listener.onFailedProject(new ProjectFailedEvent(projectRequest, null));
|
||||
this.listener.onFailedProject(new ProjectFailedEvent(projectRequest, null));
|
||||
}
|
||||
|
||||
private ProjectRequest initialize() {
|
||||
ProjectRequest request = new ProjectRequest();
|
||||
request.initialize(metadata);
|
||||
request.initialize(this.metadata);
|
||||
return request;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,12 +39,12 @@ abstract class AbstractInitializrStatTests {
|
||||
|
||||
protected ProjectRequest createProjectRequest() {
|
||||
ProjectRequest request = new ProjectRequest();
|
||||
request.initialize(metadata);
|
||||
request.initialize(this.metadata);
|
||||
return request;
|
||||
}
|
||||
|
||||
public InitializrMetadata getMetadata() {
|
||||
return metadata;
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,14 +63,15 @@ public class MainControllerStatsIntegrationTests
|
||||
public void setup() {
|
||||
this.statsMockController.stats.clear();
|
||||
// Make sure our mock is going to be invoked with the stats
|
||||
this.statsProperties.getElastic().setUri("http://localhost:" + port + "/elastic");
|
||||
this.statsProperties.getElastic()
|
||||
.setUri("http://localhost:" + this.port + "/elastic");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleProject() {
|
||||
downloadArchive("/starter.zip?groupId=com.foo&artifactId=bar&dependencies=web");
|
||||
assertEquals("No stat got generated", 1, statsMockController.stats.size());
|
||||
StatsMockController.Content content = statsMockController.stats.get(0);
|
||||
assertEquals("No stat got generated", 1, this.statsMockController.stats.size());
|
||||
StatsMockController.Content content = this.statsMockController.stats.get(0);
|
||||
|
||||
JsonNode json = parseJson(content.json);
|
||||
assertEquals("com.foo", json.get("groupId").textValue());
|
||||
@@ -83,8 +84,8 @@ public class MainControllerStatsIntegrationTests
|
||||
@Test
|
||||
public void authorizationHeaderIsSet() {
|
||||
downloadArchive("/starter.zip");
|
||||
assertEquals("No stat got generated", 1, statsMockController.stats.size());
|
||||
StatsMockController.Content content = statsMockController.stats.get(0);
|
||||
assertEquals("No stat got generated", 1, this.statsMockController.stats.size());
|
||||
StatsMockController.Content content = this.statsMockController.stats.get(0);
|
||||
|
||||
String authorization = content.authorization;
|
||||
assertNotNull("Authorization header must be set", authorization);
|
||||
@@ -99,8 +100,8 @@ public class MainControllerStatsIntegrationTests
|
||||
@Test
|
||||
public void requestIpNotSetByDefault() {
|
||||
downloadArchive("/starter.zip?groupId=com.foo&artifactId=bar&dependencies=web");
|
||||
assertEquals("No stat got generated", 1, statsMockController.stats.size());
|
||||
StatsMockController.Content content = statsMockController.stats.get(0);
|
||||
assertEquals("No stat got generated", 1, this.statsMockController.stats.size());
|
||||
StatsMockController.Content content = this.statsMockController.stats.get(0);
|
||||
|
||||
JsonNode json = parseJson(content.json);
|
||||
assertFalse("requestIp property should not be set", json.has("requestIp"));
|
||||
@@ -111,8 +112,8 @@ public class MainControllerStatsIntegrationTests
|
||||
RequestEntity<?> request = RequestEntity.get(new URI(createUrl("/starter.zip")))
|
||||
.header("X-FORWARDED-FOR", "10.0.0.123").build();
|
||||
getRestTemplate().exchange(request, String.class);
|
||||
assertEquals("No stat got generated", 1, statsMockController.stats.size());
|
||||
StatsMockController.Content content = statsMockController.stats.get(0);
|
||||
assertEquals("No stat got generated", 1, this.statsMockController.stats.size());
|
||||
StatsMockController.Content content = this.statsMockController.stats.get(0);
|
||||
|
||||
JsonNode json = parseJson(content.json);
|
||||
assertEquals("Wrong requestIp", "10.0.0.123", json.get("requestIp").textValue());
|
||||
@@ -123,8 +124,8 @@ public class MainControllerStatsIntegrationTests
|
||||
RequestEntity<?> request = RequestEntity.get(new URI(createUrl("/starter.zip")))
|
||||
.header("x-forwarded-for", "foo-bar").build();
|
||||
getRestTemplate().exchange(request, String.class);
|
||||
assertEquals("No stat got generated", 1, statsMockController.stats.size());
|
||||
StatsMockController.Content content = statsMockController.stats.get(0);
|
||||
assertEquals("No stat got generated", 1, this.statsMockController.stats.size());
|
||||
StatsMockController.Content content = this.statsMockController.stats.get(0);
|
||||
|
||||
JsonNode json = parseJson(content.json);
|
||||
assertFalse("requestIpv4 property should not be set if value is not a valid IPv4",
|
||||
@@ -136,8 +137,8 @@ public class MainControllerStatsIntegrationTests
|
||||
RequestEntity<?> request = RequestEntity.get(new URI(createUrl("/starter.zip")))
|
||||
.header("cf-ipcountry", "XX").build();
|
||||
getRestTemplate().exchange(request, String.class);
|
||||
assertEquals("No stat got generated", 1, statsMockController.stats.size());
|
||||
StatsMockController.Content content = statsMockController.stats.get(0);
|
||||
assertEquals("No stat got generated", 1, this.statsMockController.stats.size());
|
||||
StatsMockController.Content content = this.statsMockController.stats.get(0);
|
||||
|
||||
JsonNode json = parseJson(content.json);
|
||||
assertFalse("requestCountry property should not be set if value is set to xx",
|
||||
@@ -153,8 +154,8 @@ public class MainControllerStatsIntegrationTests
|
||||
catch (HttpClientErrorException ex) {
|
||||
assertEquals(HttpStatus.BAD_REQUEST, ex.getStatusCode());
|
||||
}
|
||||
assertEquals("No stat got generated", 1, statsMockController.stats.size());
|
||||
StatsMockController.Content content = statsMockController.stats.get(0);
|
||||
assertEquals("No stat got generated", 1, this.statsMockController.stats.size());
|
||||
StatsMockController.Content content = this.statsMockController.stats.get(0);
|
||||
|
||||
JsonNode json = parseJson(content.json);
|
||||
assertEquals("com.example", json.get("groupId").textValue());
|
||||
@@ -168,9 +169,10 @@ public class MainControllerStatsIntegrationTests
|
||||
@Test
|
||||
public void errorPublishingStatsDoesNotBubbleUp() {
|
||||
this.statsProperties.getElastic()
|
||||
.setUri("http://localhost:" + port + "/elastic-error");
|
||||
.setUri("http://localhost:" + this.port + "/elastic-error");
|
||||
downloadArchive("/starter.zip");
|
||||
assertEquals("No stat should be available", 0, statsMockController.stats.size());
|
||||
assertEquals("No stat should be available", 0,
|
||||
this.statsMockController.stats.size());
|
||||
}
|
||||
|
||||
@RestController
|
||||
@@ -198,7 +200,7 @@ public class MainControllerStatsIntegrationTests
|
||||
|
||||
Content(String authorization, String body) {
|
||||
this.authorization = authorization;
|
||||
json = body;
|
||||
this.json = body;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ public class ProjectGenerationStatPublisherTests extends AbstractInitializrStatT
|
||||
createProvider(getMetadata()));
|
||||
this.retryTemplate = new RetryTemplate();
|
||||
this.statPublisher = new ProjectGenerationStatPublisher(documentFactory,
|
||||
properties, new RestTemplateBuilder(), retryTemplate);
|
||||
mockServer = MockRestServiceServer
|
||||
properties, new RestTemplateBuilder(), this.retryTemplate);
|
||||
this.mockServer = MockRestServiceServer
|
||||
.createServer(this.statPublisher.getRestTemplate());
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ProjectGenerationStatPublisherTests extends AbstractInitializrStatT
|
||||
request.setGroupId("com.example.foo");
|
||||
request.setArtifactId("my-project");
|
||||
|
||||
mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
|
||||
this.mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
|
||||
.andExpect(method(HttpMethod.POST))
|
||||
.andExpect(jsonPath("$.groupId").value("com.example.foo"))
|
||||
.andExpect(jsonPath("$.artifactId").value("my-project"))
|
||||
@@ -76,29 +76,29 @@ public class ProjectGenerationStatPublisherTests extends AbstractInitializrStatT
|
||||
.contentType(MediaType.APPLICATION_JSON));
|
||||
|
||||
this.statPublisher.handleEvent(new ProjectGeneratedEvent(request));
|
||||
mockServer.verify();
|
||||
this.mockServer.verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void recoverFromError() {
|
||||
ProjectRequest request = createProjectRequest();
|
||||
|
||||
mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
|
||||
this.mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
|
||||
.andExpect(method(HttpMethod.POST))
|
||||
.andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
|
||||
mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
|
||||
this.mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
|
||||
.andExpect(method(HttpMethod.POST))
|
||||
.andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
|
||||
mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
|
||||
this.mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
|
||||
.andExpect(method(HttpMethod.POST))
|
||||
.andRespond(withStatus(HttpStatus.CREATED)
|
||||
.body(mockResponse(UUID.randomUUID().toString(), true))
|
||||
.contentType(MediaType.APPLICATION_JSON));
|
||||
|
||||
this.statPublisher.handleEvent(new ProjectGeneratedEvent(request));
|
||||
mockServer.verify();
|
||||
this.mockServer.verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -107,16 +107,16 @@ public class ProjectGenerationStatPublisherTests extends AbstractInitializrStatT
|
||||
this.retryTemplate.setRetryPolicy(new SimpleRetryPolicy(2,
|
||||
Collections.singletonMap(Exception.class, true)));
|
||||
|
||||
mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
|
||||
this.mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
|
||||
.andExpect(method(HttpMethod.POST))
|
||||
.andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
|
||||
mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
|
||||
this.mockServer.expect(requestTo("http://example.com/elastic/initializr/request"))
|
||||
.andExpect(method(HttpMethod.POST))
|
||||
.andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
|
||||
this.statPublisher.handleEvent(new ProjectGeneratedEvent(request));
|
||||
mockServer.verify();
|
||||
this.mockServer.verify();
|
||||
}
|
||||
|
||||
private static String mockResponse(String id, boolean created) {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
public void createDocumentForSimpleProject() {
|
||||
ProjectRequest request = createProjectRequest();
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertEquals(event.getTimestamp(), document.getGenerationTimestamp());
|
||||
assertEquals(null, document.getRequestIp());
|
||||
assertEquals("com.example", document.getGroupId());
|
||||
@@ -60,7 +60,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
ProjectRequest request = createProjectRequest();
|
||||
request.getParameters().put("x-forwarded-for", "10.0.0.123");
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertEquals("10.0.0.123", document.getRequestIp());
|
||||
assertEquals("10.0.0.123", document.getRequestIpv4());
|
||||
assertNull(document.getRequestCountry());
|
||||
@@ -71,7 +71,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
ProjectRequest request = createProjectRequest();
|
||||
request.getParameters().put("x-forwarded-for", "2001:db8:a0b:12f0::1");
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertEquals("2001:db8:a0b:12f0::1", document.getRequestIp());
|
||||
assertNull(document.getRequestIpv4());
|
||||
assertNull(document.getRequestCountry());
|
||||
@@ -83,7 +83,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
request.getParameters().put("cf-connecting-ip", "10.0.0.123");
|
||||
request.getParameters().put("cf-ipcountry", "BE");
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertEquals("10.0.0.123", document.getRequestIp());
|
||||
assertEquals("10.0.0.123", document.getRequestIpv4());
|
||||
assertEquals("BE", document.getRequestCountry());
|
||||
@@ -94,7 +94,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
ProjectRequest request = createProjectRequest();
|
||||
request.getParameters().put("cf-connecting-ip", "2001:db8:a0b:12f0::1");
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertEquals("2001:db8:a0b:12f0::1", document.getRequestIp());
|
||||
assertNull(document.getRequestIpv4());
|
||||
assertNull(document.getRequestCountry());
|
||||
@@ -106,7 +106,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
request.getParameters().put("cf-connecting-ip", "10.0.0.123");
|
||||
request.getParameters().put("x-forwarded-for", "192.168.1.101");
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertEquals("10.0.0.123", document.getRequestIp());
|
||||
assertEquals("10.0.0.123", document.getRequestIpv4());
|
||||
assertNull(document.getRequestCountry());
|
||||
@@ -117,7 +117,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
ProjectRequest request = createProjectRequest();
|
||||
request.getParameters().put("cf-connecting-ip", "Xx"); // case insensitive
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertNull(document.getRequestCountry());
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
ProjectRequest request = createProjectRequest();
|
||||
request.getParameters().put("user-agent", "HTTPie/0.8.0");
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertEquals("httpie", document.getClientId());
|
||||
assertEquals("0.8.0", document.getClientVersion());
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
ProjectRequest request = createProjectRequest();
|
||||
request.getParameters().put("user-agent", "IntelliJ IDEA");
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertEquals("intellijidea", document.getClientId());
|
||||
assertEquals(null, document.getClientVersion());
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
ProjectRequest request = createProjectRequest();
|
||||
request.setJavaVersion("1.2");
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertEquals("1.2", document.getJavaVersion());
|
||||
assertTrue(document.isInvalid());
|
||||
assertTrue(document.isInvalidJavaVersion());
|
||||
@@ -157,7 +157,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
ProjectRequest request = createProjectRequest();
|
||||
request.setLanguage("c++");
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertEquals("c++", document.getLanguage());
|
||||
assertTrue(document.isInvalid());
|
||||
assertTrue(document.isInvalidLanguage());
|
||||
@@ -168,7 +168,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
ProjectRequest request = createProjectRequest();
|
||||
request.setPackaging("ear");
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertEquals("ear", document.getPackaging());
|
||||
assertTrue(document.isInvalid());
|
||||
assertTrue(document.isInvalidPackaging());
|
||||
@@ -179,7 +179,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
ProjectRequest request = createProjectRequest();
|
||||
request.setType("ant-project");
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertEquals("ant-project", document.getType());
|
||||
assertTrue(document.isInvalid());
|
||||
assertTrue(document.isInvalidType());
|
||||
@@ -190,7 +190,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
ProjectRequest request = createProjectRequest();
|
||||
request.setDependencies(Arrays.asList("web", "invalid", "data-jpa", "invalid-2"));
|
||||
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request);
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertEquals("web", document.getDependencies().get(0));
|
||||
assertEquals("data-jpa", document.getDependencies().get(1));
|
||||
assertEquals(2, document.getDependencies().size());
|
||||
@@ -205,7 +205,7 @@ public class ProjectRequestDocumentFactoryTests extends AbstractInitializrStatTe
|
||||
ProjectRequest request = createProjectRequest();
|
||||
ProjectFailedEvent event = new ProjectFailedEvent(request,
|
||||
new IllegalStateException("my test message"));
|
||||
ProjectRequestDocument document = factory.createDocument(event);
|
||||
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||
assertTrue(document.isInvalid());
|
||||
assertEquals("my test message", document.getErrorMessage());
|
||||
}
|
||||
|
||||
@@ -30,16 +30,16 @@ public class StatsPropertiesTests {
|
||||
|
||||
@Test
|
||||
public void cleanTrailingSlash() {
|
||||
properties.getElastic().setUri("http://example.com/");
|
||||
assertThat(properties.getElastic().getUri(), is("http://example.com"));
|
||||
this.properties.getElastic().setUri("http://example.com/");
|
||||
assertThat(this.properties.getElastic().getUri(), is("http://example.com"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void provideEntityUrl() {
|
||||
properties.getElastic().setUri("http://example.com/");
|
||||
properties.getElastic().setIndexName("my-index");
|
||||
properties.getElastic().setEntityName("foo");
|
||||
assertThat(properties.getElastic().getEntityUrl().toString(),
|
||||
this.properties.getElastic().setUri("http://example.com/");
|
||||
this.properties.getElastic().setIndexName("my-index");
|
||||
this.properties.getElastic().setEntityName("foo");
|
||||
assertThat(this.properties.getElastic().getEntityUrl().toString(),
|
||||
is("http://example.com/my-index/foo"));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ public class MetricsAssert {
|
||||
}
|
||||
|
||||
public MetricsAssert hasValue(long value, String... metrics) {
|
||||
Arrays.asList(metrics)
|
||||
.forEach(metric -> assertThat(meterRegistry.get(metric).counter().count())
|
||||
Arrays.asList(metrics).forEach(
|
||||
metric -> assertThat(this.meterRegistry.get(metric).counter().count())
|
||||
.isEqualTo(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user