Search in sources :

Example 11 with JavaProject

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"));
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) Configuration(org.gradle.api.artifacts.Configuration) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) Test(org.junit.Test)

Example 12 with JavaProject

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());
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) Test(org.junit.Test)

Example 13 with JavaProject

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;
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) ProbeBuilder(io.fabric8.kubernetes.api.model.ProbeBuilder) JKubeEnricherContext(org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext) Properties(java.util.Properties) JKubeEnricherContext(org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext) EnricherContext(org.eclipse.jkube.kit.enricher.api.EnricherContext)

Example 14 with JavaProject

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");
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) Properties(java.util.Properties) Test(org.junit.Test)

Example 15 with JavaProject

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);
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) File(java.io.File) Test(org.junit.Test)

Aggregations

JavaProject (org.eclipse.jkube.kit.common.JavaProject)52 Test (org.junit.Test)43 File (java.io.File)16 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)9 DeploymentBuilder (io.fabric8.kubernetes.api.model.apps.DeploymentBuilder)9 Expectations (mockit.Expectations)9 HashMap (java.util.HashMap)7 Properties (java.util.Properties)6 Configuration (org.gradle.api.artifacts.Configuration)6 DeprecatableConfiguration (org.gradle.internal.deprecation.DeprecatableConfiguration)6 IOException (java.io.IOException)5 Collections (java.util.Collections)4 List (java.util.List)4 MavenProject (org.apache.maven.project.MavenProject)4 Plugin (org.eclipse.jkube.kit.common.Plugin)4 JKubeEnricherContext (org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext)4 ArrayList (java.util.ArrayList)3 Optional (java.util.Optional)3 Collectors (java.util.stream.Collectors)3 StringUtils (org.apache.commons.lang3.StringUtils)3