Java Code Examples for io.spring.initializr.metadata.InitializrMetadata#validate()

The following examples show how to use io.spring.initializr.metadata.InitializrMetadata#validate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetadataBuildItemResolverTests.java    From initializr with Apache License 2.0 6 votes vote down vote up
@Test
void resoleDependencyWithMatchingEntry() {
	InitializrMetadata metadata = new InitializrMetadata();
	DependencyGroup group = DependencyGroup.create("test");
	Dependency target = Dependency.withId("test-dep", "com.example", "test", "1.0.0", "runtime");
	target.setClassifier("test-jar");
	group.getContent().add(target);
	metadata.getDependencies().getContent().add(group);
	metadata.validate();
	MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
	io.spring.initializr.generator.buildsystem.Dependency dependency = resolver.resolveDependency("test-dep");
	assertThat(dependency.getGroupId()).isEqualTo("com.example");
	assertThat(dependency.getArtifactId()).isEqualTo("test");
	assertThat(dependency.getVersion()).hasToString("1.0.0");
	assertThat(dependency.getClassifier()).hasToString("test-jar");
	assertThat(dependency.getScope()).isEqualTo(DependencyScope.RUNTIME);
}
 
Example 2
Source File: MetadataBuildItemResolverTests.java    From initializr with Apache License 2.0 6 votes vote down vote up
@Test
void resoleDependencyWithMatchingEntryAndCompatibilityRange() {
	InitializrMetadata metadata = new InitializrMetadata();
	DependencyGroup group = DependencyGroup.create("test");
	Dependency dependency = Dependency.withId("test-dep", "com.example", "test");
	dependency.getMappings()
			.add(Mapping.create("[1.0.0.RELEASE, 2.0.0.RELEASE)", null, null, "1.0.0.RELEASE", null, null));
	dependency.getMappings()
			.add(Mapping.create("2.0.0.RELEASE", "com.example.override", "test-override", null, null, null));
	group.getContent().add(dependency);
	metadata.getDependencies().getContent().add(group);
	metadata.validate();
	MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
	io.spring.initializr.generator.buildsystem.Dependency resolveDependency = resolver
			.resolveDependency("test-dep");
	assertThat(resolveDependency.getGroupId()).isEqualTo("com.example.override");
	assertThat(resolveDependency.getArtifactId()).isEqualTo("test-override");
	assertThat(resolveDependency.getVersion()).isNull();
	assertThat(resolveDependency.getScope()).isEqualTo(DependencyScope.COMPILE);
}
 
Example 3
Source File: MetadataBuildItemResolverTests.java    From initializr with Apache License 2.0 6 votes vote down vote up
@Test
void resoleBomWithMatchingEntryAndCompatibilityRange() throws MalformedURLException {
	InitializrMetadata metadata = new InitializrMetadata();
	BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "0.0.1");
	bom.getMappings().add(BillOfMaterials.Mapping.create("[1.0.0.RELEASE, 2.0.0.RELEASE)", "1.0.0"));
	bom.getMappings().add(BillOfMaterials.Mapping.create("2.0.0.RELEASE", "1.1.0"));
	metadata.getConfiguration().getEnv().getBoms().put("test-bom", bom);
	metadata.getConfiguration().getEnv().getRepositories().put("test-repo",
			new Repository("test", new URL("https://example.com/repo"), false));
	metadata.validate();
	MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
	io.spring.initializr.generator.buildsystem.BillOfMaterials resolvedBom = resolver.resolveBom("test-bom");
	assertThat(resolvedBom.getGroupId()).isEqualTo("com.example");
	assertThat(resolvedBom.getArtifactId()).isEqualTo("bom");
	assertThat(resolvedBom.getVersion()).hasToString("1.1.0");
}
 
Example 4
Source File: MetadataBuildItemResolverTests.java    From initializr with Apache License 2.0 5 votes vote down vote up
@Test
void resoleDependencyWithNotMatchingEntry() {
	InitializrMetadata metadata = new InitializrMetadata();
	DependencyGroup group = DependencyGroup.create("test");
	group.getContent().add(Dependency.withId("test-dep", "com.example", "test", "1.0.0", "runtime"));
	metadata.getDependencies().getContent().add(group);
	metadata.validate();
	MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
	assertThat(resolver.resolveDependency("does-not-exist")).isNull();
}
 
Example 5
Source File: MetadataBuildItemResolverTests.java    From initializr with Apache License 2.0 5 votes vote down vote up
@Test
void resoleBomWithMatchingEntry() {
	InitializrMetadata metadata = new InitializrMetadata();
	BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "2.0.0");
	metadata.getConfiguration().getEnv().getBoms().put("test-bom", bom);
	metadata.validate();
	MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
	io.spring.initializr.generator.buildsystem.BillOfMaterials resolvedBom = resolver.resolveBom("test-bom");
	assertThat(resolvedBom.getGroupId()).isEqualTo("com.example");
	assertThat(resolvedBom.getArtifactId()).isEqualTo("bom");
	assertThat(resolvedBom.getVersion()).hasToString("2.0.0");
}
 
Example 6
Source File: MetadataBuildItemResolverTests.java    From initializr with Apache License 2.0 5 votes vote down vote up
@Test
void resoleBomWithNotMatchingEntry() {
	InitializrMetadata metadata = new InitializrMetadata();
	BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "2.0.0");
	metadata.getConfiguration().getEnv().getBoms().put("test-bom", bom);
	metadata.validate();
	MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
	assertThat(resolver.resolveBom("does-not-exost")).isNull();
}
 
Example 7
Source File: MetadataBuildItemResolverTests.java    From initializr with Apache License 2.0 5 votes vote down vote up
@Test
void resoleRepositoryWithMatchingEntry() throws MalformedURLException {
	InitializrMetadata metadata = new InitializrMetadata();
	metadata.getConfiguration().getEnv().getRepositories().put("test-repo",
			new Repository("test", new URL("https://example.com/repo"), false));
	metadata.validate();
	MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
	MavenRepository repository = resolver.resolveRepository("test-repo");
	assertThat(repository.getId()).isEqualTo("test-repo");
	assertThat(repository.getName()).isEqualTo("test");
	assertThat(repository.getUrl()).isEqualTo("https://example.com/repo");
	assertThat(repository.isSnapshotsEnabled()).isFalse();
}
 
Example 8
Source File: MetadataBuildItemResolverTests.java    From initializr with Apache License 2.0 5 votes vote down vote up
@Test
void resoleRepositoryWithNonMatchingEntry() throws MalformedURLException {
	InitializrMetadata metadata = new InitializrMetadata();
	metadata.getConfiguration().getEnv().getRepositories().put("test-repo",
			new Repository("test", new URL("https://example.com/repo"), false));
	metadata.validate();
	MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
	assertThat(resolver.resolveRepository("does-not-exist")).isNull();
}