Search in sources :

Example 6 with AssemblyFile

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

Example 7 with AssemblyFile

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

Example 8 with AssemblyFile

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());
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyFileUtils.resolveSourceFile(org.eclipse.jkube.kit.common.archive.AssemblyFileUtils.resolveSourceFile) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) File(java.io.File)

Example 9 with AssemblyFile

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

Example 10 with AssemblyFile

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

Aggregations

AssemblyFile (org.eclipse.jkube.kit.common.AssemblyFile)13 File (java.io.File)12 Test (org.junit.Test)11 Assembly (org.eclipse.jkube.kit.common.Assembly)6 AssemblyConfiguration (org.eclipse.jkube.kit.common.AssemblyConfiguration)6 Expectations (mockit.Expectations)1 AssemblyFileEntry (org.eclipse.jkube.kit.common.AssemblyFileEntry)1 JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)1 AssemblyFileUtils.resolveSourceFile (org.eclipse.jkube.kit.common.archive.AssemblyFileUtils.resolveSourceFile)1 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)1