Search in sources :

Example 6 with MigrationWarning

use of org.codice.ddf.migration.MigrationWarning in project ddf by codice.

the class SecurityMigratableTest method testExportExceptionThrownWhenCopyingDirectory.

@Test(expected = MigrationException.class)
public void testExportExceptionThrownWhenCopyingDirectory() throws Exception {
    MigratableUtil mockMigratableUtil = mock(MigratableUtil.class);
    doThrow(MigrationException.class).when(mockMigratableUtil).copyDirectory(any(Path.class), eq(EXPORT_DIRECTORY), Matchers.<Collection<MigrationWarning>>any());
    SecurityMigratable securityMigratable = new SecurityMigratable(DESCRIBABLE_BEAN, mockMigratableUtil);
    securityMigratable.export(EXPORT_DIRECTORY);
}
Also used : Path(java.nio.file.Path) MigrationWarning(org.codice.ddf.migration.MigrationWarning) MigratableUtil(org.codice.ddf.migration.util.MigratableUtil) Test(org.junit.Test)

Example 7 with MigrationWarning

use of org.codice.ddf.migration.MigrationWarning in project ddf by codice.

the class SecurityMigratableTest method testExportExceptionThrownWhenCopyingFile.

@Test(expected = MigrationException.class)
public void testExportExceptionThrownWhenCopyingFile() throws Exception {
    // Setup
    MigratableUtil mockMigratableUtil = mock(MigratableUtil.class);
    when(mockMigratableUtil.getJavaPropertyValue(SERVER_ENCRYPTION_PROPERTIES_PATH, CRL_PROP_KEY)).thenReturn(EXPECTED_SERVER_ENCRYPTION_CRL_PATH.toString());
    doThrow(MigrationException.class).when(mockMigratableUtil).copyFile(any(Path.class), eq(EXPORT_DIRECTORY), Matchers.<Collection<MigrationWarning>>any());
    SecurityMigratable securityMigratable = new SecurityMigratable(DESCRIBABLE_BEAN, mockMigratableUtil);
    // Perform test
    securityMigratable.export(EXPORT_DIRECTORY);
}
Also used : Path(java.nio.file.Path) MigrationWarning(org.codice.ddf.migration.MigrationWarning) MigratableUtil(org.codice.ddf.migration.util.MigratableUtil) Test(org.junit.Test)

Example 8 with MigrationWarning

use of org.codice.ddf.migration.MigrationWarning in project ddf by codice.

the class TestMigratable method exportWhenMigratablesReturnWarnings.

@Test
public void exportWhenMigratablesReturnWarnings() throws Exception {
    ConfigurationMigrationManager configurationMigrationManager = createConfigurationMigrationManager();
    MigrationWarning[] expectedWarnings = new MigrationWarning[] { new MigrationWarning("Warning1"), new MigrationWarning("Warning2") };
    when(configurationMigratable.export(any(Path.class))).thenReturn(new MigrationMetadata(ImmutableList.of(expectedWarnings[0])));
    when(dataMigratable.export(any(Path.class))).thenReturn(new MigrationMetadata(ImmutableList.of(expectedWarnings[1])));
    Collection<MigrationWarning> migrationWarnings = export(() -> configurationMigrationManager.export(exportDirectory));
    assertThat(migrationWarnings, containsInAnyOrder(expectedWarnings));
    verify(configurationMigratable).export(exportDirectory);
    verify(dataMigratable).export(exportDirectory);
}
Also used : Path(java.nio.file.Path) MigrationWarning(org.codice.ddf.migration.MigrationWarning) MigrationMetadata(org.codice.ddf.migration.MigrationMetadata) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 9 with MigrationWarning

use of org.codice.ddf.migration.MigrationWarning in project ddf by codice.

the class TestMigratable method exportWithWarnings.

@Test
public void exportWithWarnings() {
    ConfigurationMigrationManager configurationMigrationManager = createConfigurationMigrationManager();
    MigrationWarning migrationWarning = new MigrationWarning("");
    Collection<MigrationWarning> warningList = new ArrayList<>();
    warningList.add(migrationWarning);
    MigrationMetadata warning = new MigrationMetadata(warningList);
    when(configurationMigratable.export(any(Path.class))).thenReturn(warning);
    Collection<MigrationWarning> migrationWarnings = configurationMigrationManager.export(exportDirectory);
    assertThat(migrationWarnings, contains(migrationWarning));
}
Also used : Path(java.nio.file.Path) MigrationWarning(org.codice.ddf.migration.MigrationWarning) ArrayList(java.util.ArrayList) MigrationMetadata(org.codice.ddf.migration.MigrationMetadata) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 10 with MigrationWarning

use of org.codice.ddf.migration.MigrationWarning in project ddf by codice.

the class PlatformMigratableTest method testExportExceptionThrownWhenCopyingFile.

@Test(expected = MigrationException.class)
public void testExportExceptionThrownWhenCopyingFile() throws Exception {
    // Setup
    MigratableUtil mockMigratableUtil = mock(MigratableUtil.class);
    doThrow(MigrationException.class).when(mockMigratableUtil).copyFile(any(Path.class), eq(exportDirectory), Matchers.<Collection<MigrationWarning>>any());
    PlatformMigratable platformMigratable = new PlatformMigratable(DESCRIBABLE_BEAN, mockMigratableUtil);
    // Perform test
    platformMigratable.export(exportDirectory);
}
Also used : Path(java.nio.file.Path) MigrationWarning(org.codice.ddf.migration.MigrationWarning) MigratableUtil(org.codice.ddf.migration.util.MigratableUtil) Test(org.junit.Test)

Aggregations

MigrationWarning (org.codice.ddf.migration.MigrationWarning)19 Path (java.nio.file.Path)12 Test (org.junit.Test)12 MigratableUtil (org.codice.ddf.migration.util.MigratableUtil)9 ArrayList (java.util.ArrayList)7 MigrationMetadata (org.codice.ddf.migration.MigrationMetadata)7 ExportMigrationException (org.codice.ddf.migration.ExportMigrationException)4 MigrationException (org.codice.ddf.migration.MigrationException)4 IOException (java.io.IOException)3 NotNull (javax.validation.constraints.NotNull)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 Files (java.nio.file.Files)2 Paths (java.nio.file.Paths)2 Collection (java.util.Collection)2 Properties (java.util.Properties)2 BooleanSupplier (java.util.function.BooleanSupplier)2 Function (java.util.function.Function)2 FileUtils (org.apache.commons.io.FileUtils)2