use of org.eclipse.jkube.kit.common.AssemblyFile 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.AssemblyFile in project jkube by eclipse.
the class AssemblyConfigurationUtilsTest method getJKubeAssemblyFilesNotNullShouldReturnFiles.
@Test
public void getJKubeAssemblyFilesNotNullShouldReturnFiles(@Injectable Assembly assembly, @Injectable AssemblyFile file) {
// Given
// @formatter:off
new Expectations() {
{
assembly.getFiles();
result = Collections.singletonList(file);
file.getSource();
result = new File("1337");
}
};
// @formatter:on
// When
final List<AssemblyFile> result = getJKubeAssemblyFiles(assembly);
// Then
assertThat(result).isNotNull().hasSize(1).first().hasFieldOrPropertyWithValue("source.name", "1337");
}
use of org.eclipse.jkube.kit.common.AssemblyFile in project jkube by eclipse.
the class AssemblyManager method processJKubeProjectAssemblyFile.
private AssemblyFileEntry processJKubeProjectAssemblyFile(JavaProject project, AssemblyFile assemblyFile, BuildDirs buildDirs, Assembly layer, AssemblyConfiguration assemblyConfiguration) throws IOException {
final File sourceFile = resolveSourceFile(project.getBaseDirectory(), assemblyFile);
final File outputDirectory = getAssemblyFileOutputDirectory(assemblyFile, buildDirs.getOutputDirectory(), layer, assemblyConfiguration);
FileUtil.createDirectory(outputDirectory);
final String destinationFilename = Optional.ofNullable(assemblyFile.getDestName()).orElse(sourceFile.getName());
final File destinationFile = new File(outputDirectory, destinationFilename);
FileUtil.copy(sourceFile, destinationFile);
return new AssemblyFileEntry(sourceFile, destinationFile, assemblyFile.getFileMode());
}
use of org.eclipse.jkube.kit.common.AssemblyFile in project jkube by eclipse.
the class AssemblyFileUtilsTest method resolveSourceFileAbsoluteFileShouldReturnSame.
@Test
public void resolveSourceFileAbsoluteFileShouldReturnSame() throws IOException {
// Given
assumeFalse(isWindows());
final File baseDirectory = temporaryFolder.newFolder("base");
final AssemblyFile af = AssemblyFile.builder().source(new File("/")).build();
// When
final File result = AssemblyFileUtils.resolveSourceFile(baseDirectory, af);
// Then
assertEquals("/", result.getAbsolutePath());
}
use of org.eclipse.jkube.kit.common.AssemblyFile in project jkube by eclipse.
the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryWithRelativeDirectoryAndAssemblyIdShouldReturnComputedPath.
@Test
public void getAssemblyFileOutputDirectoryWithRelativeDirectoryAndAssemblyIdShouldReturnComputedPath() throws IOException {
// Given
final AssemblyFile af = AssemblyFile.builder().outputDirectory(new File("target")).build();
final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
final Assembly layer = Assembly.builder().id("layer-1").build();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().targetDir("/project").build();
// When
final File result = getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
// Then
final String expectedPath = outputDirectoryForRelativePaths.toPath().resolve("layer-1").resolve("project").resolve("target").toAbsolutePath().toString();
assertEquals(expectedPath, result.getAbsolutePath());
}
Aggregations