use of org.eclipse.jkube.kit.common.Assembly in project jkube by eclipse.
the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryWithAbsoluteDirectoryShouldReturnSameWindows.
@Test
public void getAssemblyFileOutputDirectoryWithAbsoluteDirectoryShouldReturnSameWindows() throws IOException {
// Given
assumeTrue(isWindows());
final AssemblyFile af = AssemblyFile.builder().outputDirectory(new File("C:\\")).build();
final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().build();
// When
final File result = getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
// Then
assertEquals("C:\\", result.getAbsolutePath());
}
use of org.eclipse.jkube.kit.common.Assembly in project jkube by eclipse.
the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryRequired.
@Test
public void getAssemblyFileOutputDirectoryRequired() throws IOException {
// Given
final AssemblyFile af = AssemblyFile.builder().build();
final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().build();
// When
final NullPointerException result = assertThrows(NullPointerException.class, () -> {
getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
fail("Should fail as output directory should not be null");
});
// Then
assertEquals("Assembly Configuration output dir is required", result.getMessage());
}
use of org.eclipse.jkube.kit.common.Assembly in project jkube by eclipse.
the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryWithRelativeDirectoryShouldReturnComputedPath.
@Test
public void getAssemblyFileOutputDirectoryWithRelativeDirectoryShouldReturnComputedPath() throws IOException {
// Given
final AssemblyFile af = AssemblyFile.builder().outputDirectory(new File("target")).build();
final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().targetDir("/project").build();
// When
final File result = getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
// Then
final String expectedPath = outputDirectoryForRelativePaths.toPath().resolve("project").resolve("target").toAbsolutePath().toString();
assertEquals(expectedPath, result.getAbsolutePath());
}
use of org.eclipse.jkube.kit.common.Assembly in project jkube by eclipse.
the class AssemblyConfigurationUtilsTest method getJKubeAssemblyFilesNullFilesShouldReturnEmptyList.
@Test
public void getJKubeAssemblyFilesNullFilesShouldReturnEmptyList() {
// Given
final Assembly assembly = new Assembly();
// When
final List<AssemblyFile> result = getJKubeAssemblyFiles(assembly);
// Then
assertThat(result).isNotNull().isEmpty();
}
use of org.eclipse.jkube.kit.common.Assembly in project jkube by eclipse.
the class AssemblyConfigurationUtilsTest method createDockerFileBuilder_withAssemblyAndFilesInSingleLayer_shouldReturnTransformedContent.
@Test
public void createDockerFileBuilder_withAssemblyAndFilesInSingleLayer_shouldReturnTransformedContent() {
// Given
final BuildConfiguration buildConfig = BuildConfiguration.builder().user("1000").maintainer("Alex").build();
final AssemblyConfiguration assemblyConfiguration = AssemblyConfiguration.builder().targetDir("/deployments").layer(Assembly.builder().id("layer-with-id").build()).layer(new Assembly()).build();
final Map<Assembly, List<AssemblyFileEntry>> layers = assemblyConfiguration.getLayers().stream().collect(Collectors.toMap(Function.identity(), a -> Collections.singletonList(new AssemblyFileEntry(new File(""), new File(""), null))));
layers.put(new Assembly(), Collections.emptyList());
// When
final String result = createDockerFileBuilder(buildConfig, assemblyConfiguration, layers).content();
// Then
assertThat(result).isEqualTo("FROM busybox\n" + "MAINTAINER Alex\n" + "COPY /layer-with-id/deployments /deployments/\n" + "VOLUME [\"/deployments\"]\n" + "USER 1000\n");
}
Aggregations