Search in sources :

Example 6 with MigrationMetadata

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

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

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

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

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

MigrationMetadata (org.codice.ddf.migration.MigrationMetadata)11 Test (org.junit.Test)9 MigrationWarning (org.codice.ddf.migration.MigrationWarning)8 MigratableUtil (org.codice.ddf.migration.util.MigratableUtil)5 ArrayList (java.util.ArrayList)4 Path (java.nio.file.Path)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 MigrationException (org.codice.ddf.migration.MigrationException)2 Stopwatch (com.google.common.base.Stopwatch)1 Result (ddf.catalog.data.Result)1 FederationException (ddf.catalog.federation.FederationException)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 QueryImpl (ddf.catalog.operation.impl.QueryImpl)1 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)1 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)1 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)1 Serializable (java.io.Serializable)1 NotNull (javax.validation.constraints.NotNull)1 ExportMigrationException (org.codice.ddf.migration.ExportMigrationException)1 Filter (org.opengis.filter.Filter)1