use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.
the class AssemblyManagerTest method testEnsureThatArtifactFileIsSetWithEverythingNull.
@Test
public void testEnsureThatArtifactFileIsSetWithEverythingNull() throws IOException {
// Given
JavaProject project = JavaProject.builder().build();
// When
final File artifactFile = assemblyManager.ensureThatArtifactFileIsSet(project);
// Then
assertThat(artifactFile).isNull();
}
use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.
the class WildflyJARHealthCheckEnricher method isAvailable.
private boolean isAvailable() {
if (isProbeEnforced()) {
return true;
}
JavaProject project = ((JKubeEnricherContext) getContext()).getProject();
Plugin plugin = JKubeProjectUtil.getPlugin(project, BOOTABLE_JAR_GROUP_ID, BOOTABLE_JAR_ARTIFACT_ID);
if (plugin == null) {
return false;
}
Map<String, Object> config = plugin.getConfiguration();
return config.containsKey("cloud");
}
use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.
the class GradleUtilTest method findArtifact_withMultipleArchiveFiles_shouldReturnJavaArchiveOnly.
@Test
public void findArtifact_withMultipleArchiveFiles_shouldReturnJavaArchiveOnly() throws IOException {
// Given
final Configuration c = mock(Configuration.class, RETURNS_DEEP_STUBS);
File jar1 = folder.newFile("final-artifact.jar");
File jar2 = folder.newFile("final-artifact.tar");
File jar3 = folder.newFile("final-artifact.zip");
when(c.getAllDependencies().stream()).thenAnswer(i -> Stream.empty());
when(c.getOutgoing().getArtifacts().getFiles().getFiles()).thenReturn(Stream.of(jar1, jar2, jar3).collect(Collectors.toSet()));
projectConfigurations.add(c);
// When
final JavaProject result = convertGradleProject(project);
// Then
assertThat(result.getArtifact()).isNotNull().hasName("final-artifact.jar");
}
use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.
the class GradleUtilTest method extractProperties_withComplexMap_shouldReturnValidProperties.
@Test
public void extractProperties_withComplexMap_shouldReturnValidProperties() {
// Given
final Map<String, Object> complexProperties = new HashMap<>();
when(project.getProperties()).thenAnswer(i -> complexProperties);
complexProperties.put("property.1", "test");
complexProperties.put("property.ignored", null);
complexProperties.put("object", Collections.singletonMap("field1", 1));
// When
final JavaProject result = convertGradleProject(project);
// Then
assertThat(result.getProperties()).isNotEmpty().hasFieldOrPropertyWithValue("object.field1", 1).hasFieldOrPropertyWithValue("property.1", null).hasEntrySatisfying("property.1", e -> assertThat(e).isEqualTo("test"));
}
use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.
the class GradleUtilTest method convertGradleProject_withConcurrentConfigurationModifications_shouldReturnValidProject.
/**
* Some plugins might modify the ConfigurationContainer collection while we traverse it.
*
* This test ensures that no ConcurrentModificationException are thrown because we clone the ConfigurationContainer
* into an ArrayList.
*/
@Test
public void convertGradleProject_withConcurrentConfigurationModifications_shouldReturnValidProject() {
// Given
final Configuration mockConfiguration = mock(Configuration.class, RETURNS_DEEP_STUBS);
projectConfigurations.add(mockConfiguration);
final Answer<Set<?>> concurrentModificationAnswer = i -> {
projectConfigurations.remove(mockConfiguration);
projectConfigurations.add(mockConfiguration);
return Collections.emptySet();
};
when(mockConfiguration.isCanBeResolved()).thenReturn(true);
when(mockConfiguration.getOutgoing().getArtifacts().getFiles().getFiles()).thenAnswer(concurrentModificationAnswer);
when(mockConfiguration.getIncoming().getResolutionResult().getAllDependencies()).thenAnswer(concurrentModificationAnswer);
when(mockConfiguration.getIncoming().getResolutionResult().getRoot().getDependencies()).thenAnswer(concurrentModificationAnswer);
// When
final JavaProject result = convertGradleProject(project);
// Then
assertThat(result).isNotNull();
}
Aggregations