Search in sources :

Example 11 with MigrationWarning

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

the class PlatformMigratableTest method testExportWarningReturnedWhenExportingWsSecurity.

@Test
public void testExportWarningReturnedWhenExportingWsSecurity() throws Exception {
    // Setup
    MigratableUtil mockMigratableUtil = mock(MigratableUtil.class);
    MigrationWarning expectedMigrationWarning = new MigrationWarning("warning 1");
    doAnswer(new MigrationWarningAnswer(expectedMigrationWarning)).when(mockMigratableUtil).copyDirectory(eq(WS_SECURITY_DIR_REL_PATH), eq(exportDirectory), Matchers.<Collection<MigrationWarning>>any());
    PlatformMigratable platformMigratable = new PlatformMigratable(DESCRIBABLE_BEAN, mockMigratableUtil);
    // Perform Test
    MigrationMetadata migrationMetadata = platformMigratable.export(exportDirectory);
    // Verify
    assertThat(migrationMetadata.getMigrationWarnings().contains(expectedMigrationWarning), is(true));
}
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 12 with MigrationWarning

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

the class PlatformMigratableTest method testExportWarningsReturnedWhenExportingKeystoreTruststoreAppList.

/**
     * Verify that if an absolute path is encountered during the export, a warning is returned.
     */
@Test
public void testExportWarningsReturnedWhenExportingKeystoreTruststoreAppList() throws Exception {
    // Setup
    MigratableUtil mockMigratableUtil = mock(MigratableUtil.class);
    MigrationWarning expectedMigrationWarning1 = new MigrationWarning("warning 1");
    doAnswer(new MigrationWarningAnswer(expectedMigrationWarning1)).when(mockMigratableUtil).copyFileFromSystemPropertyValue(eq(KEYSTORE_SYSTEM_PROP), eq(exportDirectory), Matchers.<Collection<MigrationWarning>>any());
    MigrationWarning expectedMigrationWarning2 = new MigrationWarning("warning 2");
    doAnswer(new MigrationWarningAnswer(expectedMigrationWarning2)).when(mockMigratableUtil).copyFileFromSystemPropertyValue(eq(TRUSTSTORE_SYSTEM_PROP), eq(exportDirectory), Matchers.<Collection<MigrationWarning>>any());
    MigrationWarning expectedMigrationWarning3 = new MigrationWarning("warning 3");
    doAnswer(new MigrationWarningAnswer(expectedMigrationWarning3)).when(mockMigratableUtil).copyFile(eq(APPLICATION_LIST), eq(exportDirectory), Matchers.<Collection<MigrationWarning>>any());
    PlatformMigratable platformMigratable = new PlatformMigratable(DESCRIBABLE_BEAN, mockMigratableUtil);
    // Perform Test
    MigrationMetadata migrationMetadata = platformMigratable.export(exportDirectory);
    // Verify
    List<MigrationWarning> expectedWarnings = new ArrayList<>();
    expectedWarnings.add(expectedMigrationWarning1);
    expectedWarnings.add(expectedMigrationWarning2);
    expectedWarnings.add(expectedMigrationWarning3);
    assertThat(migrationMetadata.getMigrationWarnings(), containsInAnyOrder(expectedWarnings.toArray()));
}
Also used : MigrationWarning(org.codice.ddf.migration.MigrationWarning) MigratableUtil(org.codice.ddf.migration.util.MigratableUtil) ArrayList(java.util.ArrayList) MigrationMetadata(org.codice.ddf.migration.MigrationMetadata) Test(org.junit.Test)

Example 13 with MigrationWarning

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

the class PlatformMigratableTest method testExportWarningsReturnedWhenExportingSystemPropertiesFiles.

@Test
public void testExportWarningsReturnedWhenExportingSystemPropertiesFiles() throws Exception {
    // Setup
    MigratableUtil mockMigratableUtil = mock(MigratableUtil.class);
    MigrationWarning expectedMigrationWarning1 = new MigrationWarning("warning 1");
    doAnswer(new MigrationWarningAnswer(expectedMigrationWarning1)).when(mockMigratableUtil).copyFile(eq(SYSTEM_PROPERTIES_REL_PATH), eq(exportDirectory), Matchers.<Collection<MigrationWarning>>any());
    MigrationWarning expectedMigrationWarning2 = new MigrationWarning("warning 2");
    doAnswer(new MigrationWarningAnswer(expectedMigrationWarning2)).when(mockMigratableUtil).copyFile(eq(USERS_PROPERTIES_REL_PATH), eq(exportDirectory), Matchers.<Collection<MigrationWarning>>any());
    PlatformMigratable platformMigratable = new PlatformMigratable(DESCRIBABLE_BEAN, mockMigratableUtil);
    // Perform Test
    MigrationMetadata migrationMetadata = platformMigratable.export(exportDirectory);
    // Verify
    List<MigrationWarning> expectedWarnings = new ArrayList<>();
    expectedWarnings.add(expectedMigrationWarning1);
    expectedWarnings.add(expectedMigrationWarning2);
    assertThat(migrationMetadata.getMigrationWarnings(), containsInAnyOrder(expectedWarnings.toArray()));
}
Also used : MigrationWarning(org.codice.ddf.migration.MigrationWarning) MigratableUtil(org.codice.ddf.migration.util.MigratableUtil) ArrayList(java.util.ArrayList) MigrationMetadata(org.codice.ddf.migration.MigrationMetadata) Test(org.junit.Test)

Example 14 with MigrationWarning

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

the class PlatformMigratableTest method testExportExceptionThrownWhenCopyingDirectory.

@Test(expected = MigrationException.class)
public void testExportExceptionThrownWhenCopyingDirectory() throws Exception {
    // Setup
    MigratableUtil mockMigratableUtil = mock(MigratableUtil.class);
    doThrow(MigrationException.class).when(mockMigratableUtil).copyDirectory(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)

Example 15 with MigrationWarning

use of org.codice.ddf.migration.MigrationWarning 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)

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