/** * Create an URL suitable to download Spring Boot cli for the specified version and * extension. * @param extension the required extension * @return the download URL */ public String createCliDistributionURl(String extension) { String bootVersion = defaultId(this.bootVersions); return this.configuration.getEnv().getArtifactRepository() + "org/springframework/boot/spring-boot-cli/" + bootVersion + "/spring-boot-cli-" + bootVersion + "-bin." + extension; }
private void resolveBom(InitializrMetadata metadata, String bomId, Version requestedVersion) { if (!this.boms.containsKey(bomId)) { BillOfMaterials bom = metadata.getConfiguration().getEnv().getBoms() .get(bomId).resolve(requestedVersion); bom.getAdditionalBoms() .forEach((id) -> resolveBom(metadata, id, requestedVersion)); this.boms.put(bomId, bom); } }
public boolean isForceSsl() { if (this.forceSsl == null) { this.forceSsl = this.metadataProvider.get().getConfiguration().getEnv() .isForceSsl(); } return this.forceSsl; }
@Test void generateApplicationNameInvalidStartCharacter() { assertThat(this.properties.generateApplicationName("1MyDemo")) .isEqualTo(this.properties.getEnv().getFallbackApplicationName()); }
@Test void generateApplicationNameInvalidPartCharacter() { assertThat(this.properties.generateApplicationName("MyDe|mo")) .isEqualTo(this.properties.getEnv().getFallbackApplicationName()); }
@Test void generateApplicationNameNull() { assertThat(this.properties.generateApplicationName(null)) .isEqualTo(this.properties.getEnv().getFallbackApplicationName()); }
@Test void generateApplicationNameAnotherInvalidApplicationName() { assertThat(this.properties.generateApplicationName("Spring")) .isEqualTo(this.properties.getEnv().getFallbackApplicationName()); }
@Test void generateApplicationNameInvalidApplicationName() { assertThat(this.properties.generateApplicationName("SpringBoot")) .isEqualTo(this.properties.getEnv().getFallbackApplicationName()); }
public InitializrMetadataTestBuilder addBom(String id, BillOfMaterials bom) { this.builder.withCustomizer( (it) -> it.getConfiguration().getEnv().getBoms().put(id, bom)); return this; }
public InitializrMetadataTestBuilder setKotlinEnv(String defaultKotlinVersion, Kotlin.Mapping... mappings) { this.builder.withCustomizer((it) -> { it.getConfiguration().getEnv().getKotlin() .setDefaultVersion(defaultKotlinVersion); for (Kotlin.Mapping mapping : mappings) { it.getConfiguration().getEnv().getKotlin().getMappings().add(mapping); } }); return this; }
@Test void resolveKotlinVersionUsingDefault() { Kotlin kotlin = this.properties.getEnv().getKotlin(); kotlin.setDefaultVersion("1.2.3"); kotlin.getMappings() .add(createKotlinVersionMapping("[1.4.0.RELEASE,1.5.0.RELEASE)", "1.5")); kotlin.validate(); assertThat(kotlin.resolveKotlinVersion(Version.parse("1.3.2.RELEASE"))) .isEqualTo("1.2.3"); }
@Test void resolveKotlinVersionMatchingMapping() { Kotlin kotlin = this.properties.getEnv().getKotlin(); kotlin.setDefaultVersion("1.2.3"); kotlin.getMappings() .add(createKotlinVersionMapping("[1.4.0.RELEASE,1.5.0.RELEASE)", "1.5")); kotlin.getMappings().add(createKotlinVersionMapping("1.5.0.RELEASE", "1.6")); kotlin.validate(); assertThat(kotlin.resolveKotlinVersion(Version.parse("1.5.3.RELEASE"))) .isEqualTo("1.6"); }
@Test void resolveApplicationNameWithNoName() { ProjectRequest request = initProjectRequest(); request.setName(null); request.resolve(this.metadata); assertThat(request.getApplicationName()).isEqualTo( this.metadata.getConfiguration().getEnv().getFallbackApplicationName()); }
public InitializrMetadataTestBuilder setGradleEnv( String dependencyManagementPluginVersion) { this.builder.withCustomizer((it) -> it.getConfiguration().getEnv().getGradle() .setDependencyManagementPluginVersion(dependencyManagementPluginVersion)); return this; }
@Test void invalidBomUnknownRepository() { InitializrMetadata metadata = initializeMetadata(); BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom", "1.0.0.RELEASE"); bom.getRepositories().add("foo-repo"); metadata.getConfiguration().getEnv().getBoms().put("foo-bom", bom); assertThatExceptionOfType(InvalidInitializrMetadataException.class) .isThrownBy(metadata::validate) .withMessageContaining("invalid repository id foo-repo") .withMessageContaining("foo-bom"); }
@Test void invalidRepository() throws MalformedURLException { InitializrMetadata metadata = initializeMetadata(); Dependency foo = Dependency.withId("foo", "org.acme", "foo"); foo.setRepository("foo-repo"); addTestDependencyGroup(metadata, foo); metadata.getConfiguration().getEnv().getRepositories().put("my-repo", new Repository("repo", new URL("http://example.com/repo"), true)); assertThatExceptionOfType(InvalidInitializrMetadataException.class) .isThrownBy(metadata::validate).withMessageContaining("foo-repo") .withMessageContaining("my-repo"); }
@Test void invalidBomVersionRangeMapping() { InitializrMetadata metadata = initializeMetadata(); BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom"); bom.getMappings().add(Mapping.create("[1.2.0.RELEASE,1.3.0.M1)", "1.0.0")); bom.getMappings().add(Mapping.create("FOO_BAR", "1.2.0")); metadata.getConfiguration().getEnv().getBoms().put("foo-bom", bom); assertThatExceptionOfType(InvalidInitializrMetadataException.class) .isThrownBy(metadata::validate).withMessageContaining("FOO_BAR") .withMessageContaining("foo-bom"); }
@Test void invalidBomNoVersion() { InitializrMetadata metadata = initializeMetadata(); metadata.getConfiguration().getEnv().getBoms().put("foo-bom", BillOfMaterials.create("org.acme", "foo-bom")); assertThatExceptionOfType(InvalidInitializrMetadataException.class) .isThrownBy(metadata::validate).withMessageContaining("No version") .withMessageContaining("foo-bom"); }
@Test void invalidParentMissingVersion() { InitializrMetadata metadata = initializeMetadata(); ParentPom parent = metadata.getConfiguration().getEnv().getMaven().getParent(); parent.setGroupId("org.foo"); parent.setArtifactId("foo-parent"); assertThatExceptionOfType(InvalidInitializrMetadataException.class) .isThrownBy(metadata::validate).withMessageContaining( "Custom maven pom requires groupId, artifactId and version"); }