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));
}
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()));
}
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()));
}
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));
}
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));
}
Aggregations