use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.
the class GradleUtilTest method extractPlugins_withMultipleAndBuildScriptDuplicateDependencies_shouldReturnValidPlugins.
@Test
public void extractPlugins_withMultipleAndBuildScriptDuplicateDependencies_shouldReturnValidPlugins() {
// Given
final ConfigurationContainer cc = mock(ConfigurationContainer.class);
when(project.getBuildscript().getConfigurations()).thenReturn(cc);
final Function<String[], Configuration> mockConfiguration = configurationDependencyMock();
when(cc.stream()).thenAnswer(i -> Stream.of(mockConfiguration.apply(new String[] { "implementation", "org.springframework.boot", "org.springframework.boot.gradle.plugin", "1.33.7" }), mockConfiguration.apply(new String[] { "implementation", "org.springframework.boot", "org.springframework.boot.gradle.plugin", "1.33.7" }), mockConfiguration.apply(new String[] { "implementation", "com.example", "not-a-plugin", "1.33.7" }), mockConfiguration.apply(new String[] { "implementation", "org.eclipse.jkube.kubernetes", "org.eclipse.jkube.kubernetes.gradle.plugin", "1.0.0" })));
// When
final JavaProject result = convertGradleProject(project);
// Then
assertThat(result.getPlugins()).hasSize(2).extracting("groupId", "artifactId", "version").containsExactlyInAnyOrder(tuple("org.springframework.boot", "org.springframework.boot.gradle.plugin", "1.33.7"), tuple("org.eclipse.jkube.kubernetes", "org.eclipse.jkube.kubernetes.gradle.plugin", "1.0.0"));
}
use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.
the class SpringBootUtilTest method getSpringBootPluginConfiguration_whenSpringBootMavenPluginPresent_thenReturnsPluginConfiguration.
@Test
public void getSpringBootPluginConfiguration_whenSpringBootMavenPluginPresent_thenReturnsPluginConfiguration() {
// Given
JavaProject javaProject = JavaProject.builder().plugin(Plugin.builder().groupId("org.springframework.boot").artifactId("spring-boot-maven-plugin").configuration(Collections.singletonMap("layout", "ZIP")).build()).build();
// When
Map<String, Object> configuration = SpringBootUtil.getSpringBootPluginConfiguration(javaProject);
// Then
assertNotNull(configuration);
assertEquals("ZIP", configuration.get("layout").toString());
}
use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.
the class AbstractHealthCheckEnricherTest method createEnricher.
protected AbstractHealthCheckEnricher createEnricher(Properties properties, Map<String, String> pi) {
JavaProject project = JavaProject.builder().properties(new Properties()).build();
project.getProperties().putAll(properties);
final JKubeEnricherContext.JKubeEnricherContextBuilder enricherContextBuilder = JKubeEnricherContext.builder().project(project).log(log);
if (pi != null && !pi.isEmpty()) {
enricherContextBuilder.processingInstructions(pi);
}
EnricherContext context = enricherContextBuilder.build();
AbstractHealthCheckEnricher enricher = new AbstractHealthCheckEnricher(context, "basic") {
@Override
protected Probe getLivenessProbe() {
return getReadinessProbe();
}
@Override
protected Probe getReadinessProbe() {
return new ProbeBuilder().withNewHttpGet().withHost("localhost").withNewPort(8080).endHttpGet().build();
}
};
return enricher;
}
use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.
the class JKubeProjectUtilTest method getProperty_whenProjectPropertyPresent_returnsProjectProperty.
@Test
public void getProperty_whenProjectPropertyPresent_returnsProjectProperty() {
// Given
Properties properties = new Properties();
properties.put("jkube.test.project.property", "true");
JavaProject javaProject = JavaProject.builder().properties(properties).build();
// When
String result = JKubeProjectUtil.getProperty("jkube.test.project.property", javaProject);
// Then
assertThat(result).isEqualTo("true");
}
use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.
the class JKubeProjectUtilTest method resolveArtifact_whenArtifactPresent_shouldReturnArtifact.
@Test
public void resolveArtifact_whenArtifactPresent_shouldReturnArtifact() {
// Given
File actualArtifact = new File(temporaryFolder.getRoot(), "test-artifact-0.0.1.jar");
JavaProject javaProject = JavaProject.builder().dependency(Dependency.builder().groupId("org.example").artifactId("test-artifact").version("0.0.1").type("jar").file(actualArtifact).build()).build();
// When
File resolvedArtifact = JKubeProjectUtil.resolveArtifact(javaProject, "org.example", "test-artifact", "0.0.1", "jar");
// Then
assertThat(resolvedArtifact).isNotNull().isEqualTo(actualArtifact);
}
Aggregations