io.spring.initializr.metadata.InitializrMetadataBuilder Java Examples

The following examples show how to use io.spring.initializr.metadata.InitializrMetadataBuilder. 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: StartApplicationIntegrationTests.java    From start.spring.io with Apache License 2.0 5 votes vote down vote up
@Test
void configurationCanBeSerialized() throws URISyntaxException {
	RequestEntity<Void> request = RequestEntity.get(new URI("/metadata/config")).accept(MediaType.APPLICATION_JSON)
			.build();
	ResponseEntity<String> response = this.restTemplate.exchange(request, String.class);
	assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
	InitializrMetadata actual = InitializrMetadataBuilder.create()
			.withInitializrMetadata(new ByteArrayResource(response.getBody().getBytes())).build();
	assertThat(actual).isNotNull();
	InitializrMetadata expected = this.metadataProvider.get();
	assertThat(actual.getDependencies().getAll().size()).isEqualTo(expected.getDependencies().getAll().size());
	assertThat(actual.getConfiguration().getEnv().getBoms().size())
			.isEqualTo(expected.getConfiguration().getEnv().getBoms().size());
}
 
Example #2
Source File: InitializrConfig.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Bean
public InitializrMetadataProvider initializrMetadataProvider(
        InitializrProperties properties) {
    InitializrMetadata metadata = InitializrMetadataBuilder
            .fromInitializrProperties(properties).build();
    return new SimpleInitializrMetadataProvider(metadata);
}
 
Example #3
Source File: InitializrAutoConfiguration.java    From initializr with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(InitializrMetadataProvider.class)
public InitializrMetadataProvider initializrMetadataProvider(InitializrProperties properties,
		ObjectProvider<InitializrMetadataUpdateStrategy> initializrMetadataUpdateStrategy) {
	InitializrMetadata metadata = InitializrMetadataBuilder.fromInitializrProperties(properties).build();
	return new DefaultInitializrMetadataProvider(metadata,
			initializrMetadataUpdateStrategy.getIfAvailable(() -> (current) -> current));
}
 
Example #4
Source File: ProjectMetadataControllerCustomDefaultsIntegrationTests.java    From initializr with Apache License 2.0 5 votes vote down vote up
@Test
void initializeRemoteConfig() throws Exception {
	InitializrMetadata localMetadata = this.metadataProvider.get();
	InitializrMetadata metadata = InitializrMetadataBuilder.create()
			.withInitializrMetadata(new UrlResource(createUrl("/metadata/config"))).build();
	// Basic assertions
	assertThat(metadata.getDependencies().getContent()).hasSameSizeAs(localMetadata.getDependencies().getContent());
	assertThat(metadata.getTypes().getContent()).hasSameSizeAs(localMetadata.getTypes().getContent());
	assertThat(metadata.getBootVersions().getContent()).hasSameSizeAs(localMetadata.getBootVersions().getContent());
	assertThat(metadata.getPackagings().getContent()).hasSameSizeAs(localMetadata.getPackagings().getContent());
	assertThat(metadata.getJavaVersions().getContent()).hasSameSizeAs(localMetadata.getJavaVersions().getContent());
	assertThat(metadata.getLanguages().getContent()).hasSameSizeAs(localMetadata.getLanguages().getContent());
}