Search in sources :

Example 6 with MigratableUtil

use of org.codice.ddf.migration.util.MigratableUtil 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 7 with MigratableUtil

use of org.codice.ddf.migration.util.MigratableUtil in project ddf by codice.

the class SecurityMigratableTest method testExportCrlIsNull.

@Test
public void testExportCrlIsNull() {
    // Setup
    MigratableUtil mockMigratableUtil = mock(MigratableUtil.class);
    when(mockMigratableUtil.getJavaPropertyValue(SERVER_ENCRYPTION_PROPERTIES_PATH, CRL_PROP_KEY)).thenReturn(null);
    SecurityMigratable securityMigratable = new SecurityMigratable(DESCRIBABLE_BEAN, mockMigratableUtil);
    // Perform test
    MigrationMetadata migrationMetadata = securityMigratable.export(EXPORT_DIRECTORY);
    // Verify
    verify(mockMigratableUtil, never()).copyFile(eq(EXPECTED_SERVER_ENCRYPTION_CRL_PATH), eq(EXPORT_DIRECTORY), anyCollectionOf(MigrationWarning.class));
    assertThat(migrationMetadata.getMigrationWarnings().size(), is(0));
}
Also used : MigrationWarning(org.codice.ddf.migration.MigrationWarning) MigratableUtil(org.codice.ddf.migration.util.MigratableUtil) MigrationMetadata(org.codice.ddf.migration.MigrationMetadata) Test(org.junit.Test)

Example 8 with MigratableUtil

use of org.codice.ddf.migration.util.MigratableUtil in project ddf by codice.

the class SecurityMigratableTest method testWarningsReturned.

@Test
public void testWarningsReturned() throws Exception {
    MigratableUtil migratableUtil = mock(MigratableUtil.class);
    MigrationWarning expectedWarning = new MigrationWarning("Expected Warning");
    doAnswer(new MigrationWarningAnswer(expectedWarning)).when(migratableUtil).copyDirectory(eq(PDP_POLICIES_DIR_REL_PATH), eq(EXPORT_DIRECTORY), Matchers.<Collection<MigrationWarning>>any());
    SecurityMigratable securityMigratable = new SecurityMigratable(DESCRIBABLE_BEAN, migratableUtil);
    MigrationMetadata migrationMetadata = securityMigratable.export(EXPORT_DIRECTORY);
    assertThat(migrationMetadata.getMigrationWarnings(), containsInAnyOrder(expectedWarning));
}
Also used : MigrationWarning(org.codice.ddf.migration.MigrationWarning) MigratableUtil(org.codice.ddf.migration.util.MigratableUtil) MigrationMetadata(org.codice.ddf.migration.MigrationMetadata) Test(org.junit.Test)

Example 9 with MigratableUtil

use of org.codice.ddf.migration.util.MigratableUtil in project ddf by codice.

the class SecurityMigratableTest method testExportCrlIsBlank.

@Test(expected = MigrationException.class)
public void testExportCrlIsBlank() {
    // Setup
    MigratableUtil mockMigratableUtil = mock(MigratableUtil.class);
    when(mockMigratableUtil.getJavaPropertyValue(SERVER_ENCRYPTION_PROPERTIES_PATH, CRL_PROP_KEY)).thenReturn("");
    SecurityMigratable securityMigratable = new SecurityMigratable(DESCRIBABLE_BEAN, mockMigratableUtil);
    // Perform test
    securityMigratable.export(EXPORT_DIRECTORY);
}
Also used : MigratableUtil(org.codice.ddf.migration.util.MigratableUtil) Test(org.junit.Test)

Example 10 with MigratableUtil

use of org.codice.ddf.migration.util.MigratableUtil 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

MigratableUtil (org.codice.ddf.migration.util.MigratableUtil)14 Test (org.junit.Test)14 MigrationWarning (org.codice.ddf.migration.MigrationWarning)10 MigrationMetadata (org.codice.ddf.migration.MigrationMetadata)5 Path (java.nio.file.Path)4 ArrayList (java.util.ArrayList)2