io.spring.initializr.metadata.InitializrMetadata Java Examples
The following examples show how to use
io.spring.initializr.metadata.InitializrMetadata.
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: KotlinProjectGenerationConfigurationTests.java From initializr with Apache License 2.0 | 6 votes |
@BeforeEach void setup(@TempDir Path directory) { this.projectTester = new ProjectAssetTester().withIndentingWriterFactory() .withConfiguration(SourceCodeProjectGenerationConfiguration.class, KotlinProjectGenerationConfiguration.class, BuildProjectGenerationConfiguration.class, MavenProjectGenerationConfiguration.class) .withDirectory(directory).withBean(InitializrMetadata.class, () -> { io.spring.initializr.metadata.Dependency dependency = io.spring.initializr.metadata.Dependency .withId("foo"); dependency.setFacets(Collections.singletonList("json")); return InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("test", dependency).build(); }).withDescriptionCustomizer((description) -> { description.setLanguage(new KotlinLanguage()); if (description.getPlatformVersion() == null) { description.setPlatformVersion(Version.parse("2.1.0.RELEASE")); } description.setBuildSystem(new MavenBuildSystem()); }); }
Example #2
Source File: BomRangesInfoContributorTests.java From initializr with Apache License 2.0 | 6 votes |
@Test void withMappings() { BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "1.0.0"); bom.getMappings().add(BillOfMaterials.Mapping.create("[1.3.0.RELEASE,1.3.8.RELEASE]", "1.1.0")); bom.getMappings().add(BillOfMaterials.Mapping.create("1.3.8.BUILD-SNAPSHOT", "1.1.1-SNAPSHOT")); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addBom("foo", bom).build(); Info info = getInfo(metadata); assertThat(info.getDetails()).containsKeys("bom-ranges"); @SuppressWarnings("unchecked") Map<String, Object> ranges = (Map<String, Object>) info.getDetails().get("bom-ranges"); assertThat(ranges).containsOnlyKeys("foo"); @SuppressWarnings("unchecked") Map<String, Object> foo = (Map<String, Object>) ranges.get("foo"); assertThat(foo).containsExactly(entry("1.1.0", "Spring Boot >=1.3.0.RELEASE and <=1.3.8.RELEASE"), entry("1.1.1-SNAPSHOT", "Spring Boot >=1.3.8.BUILD-SNAPSHOT")); }
Example #3
Source File: DefaultProjectRequestToDescriptionConverter.java From initializr with Apache License 2.0 | 6 votes |
/** * Validate the specified {@link ProjectRequest request} and initialize the specified * {@link ProjectDescription description}. Override any attribute of the description * that are managed by this instance. * @param request the request to validate * @param description the description to initialize * @param metadata the metadata instance to use to apply defaults if necessary */ public void convert(ProjectRequest request, MutableProjectDescription description, InitializrMetadata metadata) { validate(request, metadata); Version platformVersion = getPlatformVersion(request, metadata); List<Dependency> resolvedDependencies = getResolvedDependencies(request, platformVersion, metadata); validateDependencyRange(platformVersion, resolvedDependencies); description.setApplicationName(request.getApplicationName()); description.setArtifactId(request.getArtifactId()); description.setBaseDirectory(request.getBaseDir()); description.setBuildSystem(getBuildSystem(request, metadata)); description.setDescription(request.getDescription()); description.setGroupId(request.getGroupId()); description.setLanguage(Language.forId(request.getLanguage(), request.getJavaVersion())); description.setName(request.getName()); description.setPackageName(request.getPackageName()); description.setPackaging(Packaging.forId(request.getPackaging())); description.setPlatformVersion(platformVersion); description.setVersion(request.getVersion()); resolvedDependencies.forEach((dependency) -> description.addDependency(dependency.getId(), MetadataBuildItemMapper.toDependency(dependency))); }
Example #4
Source File: DependencyRangesInfoContributorTests.java From initializr with Apache License 2.0 | 6 votes |
@Test void dependencyWithMappingAndNoOpenRange() { Dependency dependency = Dependency.withId("foo", null, null, "0.3.0.RELEASE"); dependency.getMappings().add( Dependency.Mapping.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE", null, null)); dependency.getMappings().add( Dependency.Mapping.create("[1.2.0.RELEASE, 1.3.0.RELEASE)", null, null, "0.2.0.RELEASE", null, null)); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults() .addDependencyGroup("test", dependency).build(); Info info = getInfo(metadata); assertDependencyId(info, "foo"); Map<String, Object> foo = getDependencyRangeInfo(info, "foo"); assertThat(foo).containsExactly(entry("0.1.0.RELEASE", "Spring Boot >=1.1.0.RELEASE and <1.2.0.RELEASE"), entry("0.2.0.RELEASE", "Spring Boot >=1.2.0.RELEASE and <1.3.0.RELEASE"), entry("managed", "Spring Boot >=1.3.0.RELEASE")); }
Example #5
Source File: BuildComplianceTests.java From initializr with Apache License 2.0 | 6 votes |
@ParameterizedTest @MethodSource("parameters") void bomWithOrdering(BuildSystem build, String fileName) { Dependency foo = Dependency.withId("foo", "org.acme", "foo"); foo.setBom("foo-bom"); BillOfMaterials barBom = BillOfMaterials.create("org.acme", "bar-bom", "1.0"); barBom.setOrder(50); BillOfMaterials bizBom = BillOfMaterials.create("org.acme", "biz-bom"); bizBom.setOrder(40); bizBom.getAdditionalBoms().add("bar-bom"); bizBom.getMappings().add(BillOfMaterials.Mapping.create("1.0.0.RELEASE", "1.0")); BillOfMaterials fooBom = BillOfMaterials.create("org.acme", "foo-bom", "1.0"); fooBom.setOrder(20); fooBom.getAdditionalBoms().add("biz-bom"); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("foo", foo) .addBom("foo-bom", fooBom).addBom("bar-bom", barBom).addBom("biz-bom", bizBom).build(); ProjectStructure project = generateProject(java, build, "2.1.1.RELEASE", (description) -> description.addDependency("foo", MetadataBuildItemMapper.toDependency(foo)), metadata); assertThat(project).textFile(fileName).hasSameContentAs( new ClassPathResource("project/" + build + "/bom-ordering-" + getAssertFileName(fileName))); }
Example #6
Source File: CommandLineHelpGeneratorTests.java From initializr with Apache License 2.0 | 6 votes |
@Test void generateSpringBootCliCapabilities() throws IOException { InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("test", createDependency("id-b", "depB"), createDependency("id-a", "depA", "and some description")).build(); String content = this.generator.generateSpringBootCliCapabilities(metadata, "https://fake-service"); assertThat(content).contains("| Id"); assertThat(content).contains("| Tags"); assertThat(content).contains("id-a | and some description |"); assertThat(content).contains("id-b | depB"); assertThat(content).contains("https://fake-service"); assertThat(content).doesNotContain("Examples:"); assertThat(content).doesNotContain("curl"); assertThat(content).doesNotContain("| Rel"); assertThat(content).doesNotContain("| dependencies"); assertThat(content).doesNotContain("| applicationName"); assertThat(content).doesNotContain("| baseDir"); }
Example #7
Source File: SaganInitializrMetadataUpdateStrategyTests.java From initializr with Apache License 2.0 | 6 votes |
@Test void defaultBootVersionIsAlwaysSet() { InitializrMetadata metadata = new InitializrMetadataTestBuilder().addBootVersion("0.0.9.RELEASE", true) .addBootVersion("0.0.8.RELEASE", false).build(); assertThat(metadata.getBootVersions().getDefault().getId()).isEqualTo("0.0.9.RELEASE"); SaganInitializrMetadataUpdateStrategy provider = new SaganInitializrMetadataUpdateStrategy(this.restTemplate, objectMapper); expectJson(metadata.getConfiguration().getEnv().getSpringBootMetadataUrl(), "metadata/sagan/spring-boot-no-default.json"); InitializrMetadata updatedMetadata = provider.update(metadata); assertThat(updatedMetadata.getBootVersions()).isNotNull(); List<DefaultMetadataElement> updatedBootVersions = updatedMetadata.getBootVersions().getContent(); assertThat(updatedBootVersions).hasSize(5); assertBootVersion(updatedBootVersions.get(0), "2.5.0 (M1)", true); assertBootVersion(updatedBootVersions.get(1), "2.4.1 (SNAPSHOT)", false); assertBootVersion(updatedBootVersions.get(2), "2.4.0", false); assertBootVersion(updatedBootVersions.get(3), "2.3.8 (SNAPSHOT)", false); assertBootVersion(updatedBootVersions.get(4), "2.3.7", false); }
Example #8
Source File: DefaultDependencyMetadataProviderTests.java From initializr with Apache License 2.0 | 6 votes |
private DependencyMetadata testRepoFromBomAccordingToVersion(String bootVersion) { Dependency first = Dependency.withId("first", "org.foo", "first"); first.setRepository("repo-foo"); Dependency second = Dependency.withId("second", "org.foo", "second"); Dependency third = Dependency.withId("third", "org.foo", "third"); third.setBom("bom-foo"); BillOfMaterials bom = BillOfMaterials.create("org.foo", "bom"); bom.getMappings().add(BillOfMaterials.Mapping.create("[1.0.0.RELEASE, 1.1.0.RELEASE)", "2.0.0.RELEASE", "repo-foo", "repo-bar")); bom.getMappings().add(BillOfMaterials.Mapping.create("1.1.0.RELEASE", "3.0.0.RELEASE", "repo-biz")); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addBom("bom-foo", bom) .addRepository("repo-foo", "foo", "http://localhost", false) .addRepository("repo-bar", "bar", "http://localhost", false) .addRepository("repo-biz", "biz", "http://localhost", false) .addDependencyGroup("test", first, second, third).build(); return this.provider.get(metadata, Version.parse(bootVersion)); }
Example #9
Source File: InitializrMetadataV2JsonMapper.java From initializr with Apache License 2.0 | 6 votes |
@Override public String write(InitializrMetadata metadata, String appUrl) { ObjectNode delegate = nodeFactory.objectNode(); links(delegate, metadata.getTypes().getContent(), appUrl); dependencies(delegate, metadata.getDependencies()); type(delegate, metadata.getTypes()); singleSelect(delegate, metadata.getPackagings()); singleSelect(delegate, metadata.getJavaVersions()); singleSelect(delegate, metadata.getLanguages()); singleSelect(delegate, metadata.getBootVersions(), this::mapVersionMetadata); text(delegate, metadata.getGroupId()); text(delegate, metadata.getArtifactId()); text(delegate, metadata.getVersion()); text(delegate, metadata.getName()); text(delegate, metadata.getDescription()); text(delegate, metadata.getPackageName()); return delegate.toString(); }
Example #10
Source File: BuildComplianceTests.java From initializr with Apache License 2.0 | 6 votes |
@ParameterizedTest @MethodSource("parameters") void repositories(BuildSystem build, String fileName) { Dependency foo = Dependency.withId("foo", "org.acme", "foo"); foo.setRepository("foo-repository"); Dependency bar = Dependency.withId("bar", "org.acme", "bar"); bar.setRepository("bar-repository"); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("test", foo, bar) .addRepository("foo-repository", "foo-repo", "https://example.com/foo", false) .addRepository("bar-repository", "bar-repo", "https://example.com/bar", true).build(); ProjectStructure project = generateProject(java, build, "2.1.1.RELEASE", (description) -> { description.addDependency("foo", MetadataBuildItemMapper.toDependency(foo)); description.addDependency("bar", MetadataBuildItemMapper.toDependency(bar)); }, metadata); assertThat(project).textFile(fileName).hasSameContentAs( new ClassPathResource("project/" + build + "/repositories-" + getAssertFileName(fileName))); }
Example #11
Source File: CommandLineHelpGenerator.java From initializr with Apache License 2.0 | 6 votes |
protected String generateTypeTable(InitializrMetadata metadata, String linkHeader, boolean addTags) { String[][] typeTable = new String[metadata.getTypes().getContent().size() + 1][]; if (addTags) { typeTable[0] = new String[] { linkHeader, "Description", "Tags" }; } else { typeTable[0] = new String[] { linkHeader, "Description" }; } int i = 1; for (Type type : metadata.getTypes().getContent().stream().sorted(Comparator.comparing(MetadataElement::getId)) .collect(Collectors.toList())) { String[] data = new String[typeTable[0].length]; data[0] = (type.isDefault() ? type.getId() + " *" : type.getId()); data[1] = (type.getDescription() != null) ? type.getDescription() : type.getName(); if (addTags) { data[2] = buildTagRepresentation(type); } typeTable[i++] = data; } return TableGenerator.generate(typeTable, this.maxColumnWidth); }
Example #12
Source File: DefaultDependencyMetadataProviderTests.java From initializr with Apache License 2.0 | 6 votes |
@Test void addBomAndRemoveDuplicates() { Dependency first = Dependency.withId("first", "org.foo", "first"); first.setBom("bom-foo"); Dependency second = Dependency.withId("second", "org.foo", "second"); Dependency third = Dependency.withId("third", "org.foo", "third"); third.setBom("bom-foo"); BillOfMaterials bom = BillOfMaterials.create("org.foo", "bom"); bom.getMappings().add(BillOfMaterials.Mapping.create("[1.0.0.RELEASE, 1.1.8.RELEASE)", "1.0.0.RELEASE")); bom.getMappings().add(BillOfMaterials.Mapping.create("1.1.8.RELEASE", "2.0.0.RELEASE")); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addBom("bom-foo", bom) .addDependencyGroup("test", first, second, third).build(); DependencyMetadata dependencyMetadata = this.provider.get(metadata, Version.parse("1.1.5.RELEASE")); assertThat(dependencyMetadata.getDependencies()).hasSize(3); assertThat(dependencyMetadata.getRepositories()).isEmpty(); assertThat(dependencyMetadata.getBoms()).hasSize(1); assertThat(dependencyMetadata.getBoms().get("bom-foo").getGroupId()).isEqualTo("org.foo"); assertThat(dependencyMetadata.getBoms().get("bom-foo").getArtifactId()).isEqualTo("bom"); assertThat(dependencyMetadata.getBoms().get("bom-foo").getVersion()).isEqualTo("1.0.0.RELEASE"); }
Example #13
Source File: BuildComplianceTests.java From initializr with Apache License 2.0 | 6 votes |
@ParameterizedTest @MethodSource("parameters") void annotationProcessorDependency(BuildSystem build, String fileName) { Dependency annotationProcessor = Dependency.withId("configuration-processor", "org.springframework.boot", "spring-boot-configuration-processor"); Dependency dataJpa = Dependency.withId("data-jpa", "org.springframework.boot", "spring-boot-starter-data-jpa"); annotationProcessor.setScope(Dependency.SCOPE_ANNOTATION_PROCESSOR); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults() .addDependencyGroup("core", "web", "data-jpa") .addDependencyGroup("configuration-processor", annotationProcessor).build(); ProjectStructure project = generateProject(java, build, "2.1.1.RELEASE", (description) -> { description.addDependency("configuration-processor", MetadataBuildItemMapper.toDependency(annotationProcessor)); description.addDependency("web", MetadataBuildItemMapper.toDependency(WEB)); description.addDependency("data-jpa", MetadataBuildItemMapper.toDependency(dataJpa)); }, metadata); assertThat(project).textFile(fileName).hasSameContentAs(new ClassPathResource( "project/" + build + "/annotation-processor-dependency-" + getAssertFileName(fileName))); }
Example #14
Source File: DefaultProjectRequestToDescriptionConverter.java From initializr with Apache License 2.0 | 5 votes |
private void validate(ProjectRequest request, InitializrMetadata metadata) { validatePlatformVersion(request, metadata); validateType(request.getType(), metadata); validateLanguage(request.getLanguage(), metadata); validatePackaging(request.getPackaging(), metadata); validateDependencies(request, metadata); }
Example #15
Source File: CommandLineHelpGeneratorTests.java From initializr with Apache License 2.0 | 5 votes |
@Test void generateGenericCapabilities() throws IOException { InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("test", createDependency("id-b", "depB"), createDependency("id-a", "depA", "and some description")).build(); String content = this.generator.generateGenericCapabilities(metadata, "https://fake-service"); assertCommandLineCapabilities(content); assertThat(content).contains("id-a | and some description |"); assertThat(content).contains("id-b | depB"); assertThat(content).contains("https://fake-service"); assertThat(content).doesNotContain("Examples:"); assertThat(content).doesNotContain("curl"); }
Example #16
Source File: BuildMetadataResolverTests.java From initializr with Apache License 2.0 | 5 votes |
private InitializrMetadata createSampleMetadata() { Dependency web = Dependency.withId("my-web"); web.getFacets().addAll(Arrays.asList("test", "web", "another")); Dependency custom = Dependency.withId("my-custom"); custom.getFacets().add("custom"); return InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("core", "one", "two", "three") .addDependencyGroup("test", web, custom).build(); }
Example #17
Source File: BuildComplianceTests.java From initializr with Apache License 2.0 | 5 votes |
@ParameterizedTest @MethodSource("parameters") void bomWithVersionProperty(BuildSystem build, String fileName) { Dependency foo = Dependency.withId("foo", "org.acme", "foo"); foo.setBom("the-bom"); BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom", "1.3.3"); bom.setVersionProperty("foo.version"); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("foo", foo) .addBom("the-bom", bom).build(); ProjectStructure project = generateProject(java, build, "2.1.1.RELEASE", (description) -> description.addDependency("foo", MetadataBuildItemMapper.toDependency(foo)), metadata); assertThat(project).textFile(fileName).hasSameContentAs( new ClassPathResource("project/" + build + "/bom-property-" + getAssertFileName(fileName))); }
Example #18
Source File: DefaultProjectRequestToDescriptionConverter.java From initializr with Apache License 2.0 | 5 votes |
private void validateDependencies(ProjectRequest request, InitializrMetadata metadata) { List<String> dependencies = request.getDependencies(); dependencies.forEach((dep) -> { Dependency dependency = metadata.getDependencies().get(dep); if (dependency == null) { throw new InvalidProjectRequestException("Unknown dependency '" + dep + "' check project metadata"); } }); }
Example #19
Source File: GradleProjectGenerationConfiguration.java From initializr with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnGradleVersion({ "4", "5", "6" }) BuildCustomizer<GradleBuild> springBootPluginContributor(ProjectDescription description, ObjectProvider<DependencyManagementPluginVersionResolver> versionResolver, InitializrMetadata metadata) { return new SpringBootPluginBuildCustomizer(description, versionResolver .getIfAvailable(() -> new InitializrDependencyManagementPluginVersionResolver(metadata))); }
Example #20
Source File: RequestedDependenciesHelpDocumentCustomizerTests.java From initializr with Apache License 2.0 | 5 votes |
private HelpDocument customizeHelp(String... requestedDependencies) { MutableProjectDescription description = new MutableProjectDescription(); for (String requestedDependency : requestedDependencies) { description.addDependency(requestedDependency, mock(io.spring.initializr.generator.buildsystem.Dependency.class)); } InitializrMetadata metadata = this.metadataBuilder.build(); HelpDocument document = new HelpDocument(new MustacheTemplateRenderer("classpath:/templates")); new RequestedDependenciesHelpDocumentCustomizer(description, metadata).customize(document); return document; }
Example #21
Source File: HelpDocumentProjectGenerationConfigurationTests.java From initializr with Apache License 2.0 | 5 votes |
@BeforeEach void setup(@TempDir Path directory) { this.projectTester = new ProjectAssetTester() .withConfiguration(HelpDocumentProjectGenerationConfiguration.class) .withBean(MustacheTemplateRenderer.class, () -> new MustacheTemplateRenderer("classpath:/templates")) .withBean(InitializrMetadata.class, () -> this.metadataBuilder.build()).withDirectory(directory); }
Example #22
Source File: AbstractComplianceTests.java From initializr with Apache License 2.0 | 5 votes |
private ProjectStructure generateProject(Language language, BuildSystem buildSystem, String version, Consumer<MutableProjectDescription> descriptionCustomizer, InitializrMetadata metadata, Consumer<ProjectGenerationContext> contextCustomizer) { ProjectGeneratorTester projectTester = new ProjectGeneratorTester().withDirectory(this.tempDir) .withDescriptionCustomizer( (description) -> setupProjectDescription(language, version, buildSystem, description)) .withDescriptionCustomizer(descriptionCustomizer) .withContextInitializer((context) -> setupProjectGenerationContext(metadata, context)) .withContextInitializer(contextCustomizer); return projectTester.generate(new MutableProjectDescription()); }
Example #23
Source File: GradleKtsProjectGenerationConfigurationTests.java From initializr with Apache License 2.0 | 5 votes |
@BeforeEach void setup(@TempDir Path directory) { this.projectTester = new ProjectAssetTester().withIndentingWriterFactory() .withConfiguration(BuildProjectGenerationConfiguration.class, GradleProjectGenerationConfiguration.class) .withDirectory(directory) .withBean(InitializrMetadata.class, () -> InitializrMetadataTestBuilder.withDefaults().build()) .withDescriptionCustomizer((description) -> description .setBuildSystem(new GradleBuildSystem(GradleBuildSystem.DIALECT_KOTLIN))); }
Example #24
Source File: InitializrMetadataV21JsonMapperTests.java From initializr with Apache License 2.0 | 5 votes |
@Test void platformVersionUsingSemVerUseBackwardCompatibleFormat() throws JsonProcessingException { InitializrMetadata metadata = new InitializrMetadataTestBuilder().addBootVersion("2.5.0-SNAPSHOT", false) .addBootVersion("2.5.0-M2", false).addBootVersion("2.4.2", true).build(); String json = this.jsonMapper.write(metadata, null); JsonNode result = objectMapper.readTree(json); JsonNode versions = result.get("bootVersion").get("values"); assertThat(versions).hasSize(3); assertVersionMetadata(versions.get(0), "2.5.0.BUILD-SNAPSHOT", "2.5.0-SNAPSHOT"); assertVersionMetadata(versions.get(1), "2.5.0.M2", "2.5.0-M2"); assertVersionMetadata(versions.get(2), "2.4.2.RELEASE", "2.4.2"); }
Example #25
Source File: CommandLineHelpGenerator.java From initializr with Apache License 2.0 | 5 votes |
protected String generateDependencyTable(InitializrMetadata metadata) { String[][] dependencyTable = new String[metadata.getDependencies().getAll().size() + 1][]; dependencyTable[0] = new String[] { "Id", "Description", "Required version" }; int i = 1; for (Dependency dep : metadata.getDependencies().getAll().stream() .sorted(Comparator.comparing(MetadataElement::getId)).collect(Collectors.toList())) { String[] data = new String[3]; data[0] = dep.getId(); data[1] = (dep.getDescription() != null) ? dep.getDescription() : dep.getName(); data[2] = dep.getVersionRequirement(); dependencyTable[i++] = data; } return TableGenerator.generate(dependencyTable, this.maxColumnWidth); }
Example #26
Source File: DependencyRangesInfoContributorTests.java From initializr with Apache License 2.0 | 5 votes |
@Test void dependencyWithMappingAndOpenRange() { Dependency dependency = Dependency.withId("foo", null, null, "0.3.0.RELEASE"); dependency.getMappings().add( Dependency.Mapping.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE", null, null)); dependency.getMappings() .add(Dependency.Mapping.create("1.2.0.RELEASE", null, null, "0.2.0.RELEASE", null, null)); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults() .addDependencyGroup("test", dependency).build(); Info info = getInfo(metadata); assertDependencyId(info, "foo"); Map<String, Object> foo = getDependencyRangeInfo(info, "foo"); assertThat(foo).containsExactly(entry("0.1.0.RELEASE", "Spring Boot >=1.1.0.RELEASE and <1.2.0.RELEASE"), entry("0.2.0.RELEASE", "Spring Boot >=1.2.0.RELEASE")); }
Example #27
Source File: InitializrMetadataV21JsonMapperTests.java From initializr with Apache License 2.0 | 5 votes |
@Test void withAppUrl() throws IOException { InitializrMetadata metadata = new InitializrMetadataTestBuilder() .addType("foo", true, "/foo.zip", "none", "test").addDependencyGroup("foo", "one", "two").build(); String json = this.jsonMapper.write(metadata, "http://server:8080/my-app"); JsonNode result = objectMapper.readTree(json); assertThat(get(result, "_links.foo.href")) .isEqualTo("http://server:8080/my-app/foo.zip?type=foo{&dependencies,packaging,javaVersion," + "language,bootVersion,groupId,artifactId,version,name,description,packageName}"); }
Example #28
Source File: CommandLineHelpGeneratorTests.java From initializr with Apache License 2.0 | 5 votes |
@Test void generateCurlCapabilities() throws IOException { InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("test", createDependency("id-b", "depB"), createDependency("id-a", "depA", "and some description")).build(); String content = this.generator.generateCurlCapabilities(metadata, "https://fake-service"); assertCommandLineCapabilities(content); assertThat(content).contains("id-a | and some description |"); assertThat(content).contains("id-b | depB"); assertThat(content).contains("https://fake-service"); assertThat(content).contains("Examples:"); assertThat(content).contains("curl https://fake-service"); }
Example #29
Source File: DependencyRangesInfoContributorTests.java From initializr with Apache License 2.0 | 5 votes |
@Test void dependencyNoMappingSimpleRange() { Dependency dependency = Dependency.withId("foo", "com.example", "foo", "1.2.3.RELEASE"); dependency.setCompatibilityRange("[1.1.0.RELEASE, 1.5.0.RELEASE)"); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("foo", dependency) .build(); Info info = getInfo(metadata); assertThat(info.getDetails()).containsKeys("dependency-ranges"); @SuppressWarnings("unchecked") Map<String, Object> ranges = (Map<String, Object>) info.getDetails().get("dependency-ranges"); assertThat(ranges).containsOnlyKeys("foo"); @SuppressWarnings("unchecked") Map<String, Object> foo = (Map<String, Object>) ranges.get("foo"); assertThat(foo).containsExactly(entry("1.2.3.RELEASE", "Spring Boot >=1.1.0.RELEASE and <1.5.0.RELEASE")); }
Example #30
Source File: CommandLineHelpGeneratorTests.java From initializr with Apache License 2.0 | 5 votes |
@Test void generateCapabilitiesWithCompatibilityRange() throws IOException { Dependency first = Dependency.withId("first"); first.setDescription("first desc"); first.setCompatibilityRange("1.2.0.RELEASE"); Dependency second = Dependency.withId("second"); second.setDescription("second desc"); second.setCompatibilityRange(" [1.2.0.RELEASE,1.3.0.M1) "); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults() .addDependencyGroup("test", first, second).build(); String content = this.generator.generateSpringBootCliCapabilities(metadata, "https://fake-service"); assertThat(content).contains("| first | first desc | >=1.2.0.RELEASE |"); assertThat(content).contains("| second | second desc | >=1.2.0.RELEASE and <1.3.0.M1 |"); }