diff --git a/src/main/java/edu/unc/lib/boxc/migration/cdm/InitializeProjectCommand.java b/src/main/java/edu/unc/lib/boxc/migration/cdm/InitializeProjectCommand.java index d80dc865..a15f4dd3 100644 --- a/src/main/java/edu/unc/lib/boxc/migration/cdm/InitializeProjectCommand.java +++ b/src/main/java/edu/unc/lib/boxc/migration/cdm/InitializeProjectCommand.java @@ -53,6 +53,12 @@ public class InitializeProjectCommand implements Callable { "If not specified, then the project will be initialized in the current directory.", "If the project name is different from the CDM collection ID, then use -c to specify the ID." }) private String projectName; + @Option(names = {"-s", "--source"}, + description = {"Specify the source of migration data when initializing a new project. Accepted values: " + + "cdm (CDM collection), files (filesystem, doesn't need to be linked with CDM collection)." + + "Defaults to cdm."}, + defaultValue = "cdm") + private String projectSource; private CdmFieldService fieldService; private CloseableHttpClient httpClient; @@ -87,11 +93,27 @@ public Integer call() throws Exception { log.error("Unable to read application configuration", e); return 1; } - var cdmEnvConfig = config.getCdmEnvironments().get(cdmEnvId); Path currentPath = parentCommand.getWorkingDirectory(); String projDisplayName = projectName == null ? currentPath.getFileName().toString() : projectName; + Integer integer = -1; + + if (projectSource.equalsIgnoreCase(MigrationProject.PROJECT_SOURCE_CDM)) { + integer = initCdmProject(config, currentPath, projDisplayName, start); + } else if (projectSource.equalsIgnoreCase(MigrationProject.PROJECT_SOURCE_FILES)) { + integer = initFilesProject(currentPath, projDisplayName, start); + } else { + log.error("Invalid project source: {}", projectSource); + outputLogger.info("Invalid project source: {}", projectSource); + } + + return integer; + } + + private Integer initCdmProject(ChompbConfig config, Path currentPath, String projDisplayName, long start) throws Exception { + var cdmEnvConfig = config.getCdmEnvironments().get(cdmEnvId); String collId = cdmCollectionId == null ? projDisplayName : cdmCollectionId; + String username = System.getProperty("user.name"); // Retrieve field information from CDM CdmFieldInfo fieldInfo; @@ -105,12 +127,10 @@ public Integer call() throws Exception { return 1; } - String username = System.getProperty("user.name"); - // Instantiate the project - MigrationProject project = null; + MigrationProject project; try { - project = MigrationProjectFactory.createMigrationProject( + project = MigrationProjectFactory.createCdmMigrationProject( currentPath, projectName, cdmCollectionId, username, cdmEnvId, bxcEnvId); // Persist field info to the project @@ -134,4 +154,18 @@ public Integer call() throws Exception { outputLogger.info("Initialized project {} in {}s", projDisplayName, (System.nanoTime() - start) / 1e9); return 0; } + + private Integer initFilesProject(Path currentPath, String projDisplayName, long start) throws Exception { + String username = System.getProperty("user.name"); + + try { + MigrationProjectFactory.createFilesMigrationProject(currentPath, projectName, username, bxcEnvId); + } catch (InvalidProjectStateException e) { + outputLogger.info("Failed to initialize project {}: {}", projDisplayName, e.getMessage()); + return 1; + } + + outputLogger.info("Initialized project {} in {}s", projDisplayName, (System.nanoTime() - start) / 1e9); + return 0; + } } diff --git a/src/main/java/edu/unc/lib/boxc/migration/cdm/model/MigrationProject.java b/src/main/java/edu/unc/lib/boxc/migration/cdm/model/MigrationProject.java index 2be750d0..694e87c4 100644 --- a/src/main/java/edu/unc/lib/boxc/migration/cdm/model/MigrationProject.java +++ b/src/main/java/edu/unc/lib/boxc/migration/cdm/model/MigrationProject.java @@ -25,6 +25,8 @@ public class MigrationProject { public static final String REDIRECT_MAPPING_FILENAME = "redirect_mappings.csv"; public static final String POST_MIGR_REPORT_FILENAME = "post_migration_report.csv"; public static final String PERMISSIONS_FILENAME = "patron_permissions.csv"; + public static final String PROJECT_SOURCE_CDM = "cdm"; + public static final String PROJECT_SOURCE_FILES = "files"; private Path projectPath; private MigrationProjectProperties properties; diff --git a/src/main/java/edu/unc/lib/boxc/migration/cdm/model/MigrationProjectProperties.java b/src/main/java/edu/unc/lib/boxc/migration/cdm/model/MigrationProjectProperties.java index 94606937..469c645f 100644 --- a/src/main/java/edu/unc/lib/boxc/migration/cdm/model/MigrationProjectProperties.java +++ b/src/main/java/edu/unc/lib/boxc/migration/cdm/model/MigrationProjectProperties.java @@ -28,6 +28,7 @@ public class MigrationProjectProperties { private String collectionNumber; private String cdmEnvironmentId; private String bxcEnvironmentId; + private String projectSource; public MigrationProjectProperties() { sipsSubmitted = new HashSet<>(); @@ -230,4 +231,12 @@ public String getBxcEnvironmentId() { public void setBxcEnvironmentId(String bxcEnvironmentId) { this.bxcEnvironmentId = bxcEnvironmentId; } + + public String getProjectSource() { + return projectSource; + } + + public void setProjectSource(String projectSource) { + this.projectSource = projectSource; + } } diff --git a/src/main/java/edu/unc/lib/boxc/migration/cdm/services/MigrationProjectFactory.java b/src/main/java/edu/unc/lib/boxc/migration/cdm/services/MigrationProjectFactory.java index b7682bd1..137f0404 100644 --- a/src/main/java/edu/unc/lib/boxc/migration/cdm/services/MigrationProjectFactory.java +++ b/src/main/java/edu/unc/lib/boxc/migration/cdm/services/MigrationProjectFactory.java @@ -21,10 +21,17 @@ public class MigrationProjectFactory { private MigrationProjectFactory() { } - public static MigrationProject createMigrationProject(Path path, String name, - String collectionId, String user, String cdmEnvId) + public static MigrationProject createCdmMigrationProject(Path path, String name, String collectionId, + String user, String cdmEnvId, String bxcEnvId) + throws IOException { + return createMigrationProject(path, name, collectionId, user, cdmEnvId, bxcEnvId, + MigrationProject.PROJECT_SOURCE_CDM); + } + + public static MigrationProject createFilesMigrationProject(Path path, String name, String user, String bxcEnvId) throws IOException { - return createMigrationProject(path, name, collectionId, user, cdmEnvId, null); + return createMigrationProject(path, name, null, user, null, bxcEnvId, + MigrationProject.PROJECT_SOURCE_FILES); } /** @@ -40,7 +47,7 @@ public static MigrationProject createMigrationProject(Path path, String name, */ public static MigrationProject createMigrationProject(Path path, String name, String collectionId, String user, - String cdmEnvId, String bxcEnvId) + String cdmEnvId, String bxcEnvId, String projectSource) throws IOException { Assert.notNull(path, "Project path not set"); Assert.notNull(user, "Username not set"); @@ -73,9 +80,14 @@ public static MigrationProject createMigrationProject(Path path, String name, properties.setCreator(user); properties.setCreatedDate(Instant.now()); properties.setName(projectName); - properties.setCdmCollectionId(collectionId == null ? projectName : collectionId); + if (projectSource.equalsIgnoreCase(MigrationProject.PROJECT_SOURCE_CDM)) { + properties.setCdmCollectionId(collectionId == null ? projectName : collectionId); + } else { + properties.setCdmCollectionId(null); + } properties.setCdmEnvironmentId(cdmEnvId); properties.setBxcEnvironmentId(bxcEnvId); + properties.setProjectSource(projectSource); project.setProjectProperties(properties); ProjectPropertiesSerialization.write(propertiesPath, properties); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/AbstractCommandIT.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/AbstractCommandIT.java index 61662876..80a4b317 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/AbstractCommandIT.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/AbstractCommandIT.java @@ -52,7 +52,8 @@ protected void initTestHelper() throws IOException { protected void initProject() throws IOException { project = MigrationProjectFactory.createMigrationProject(baseDir, PROJECT_ID, defaultCollectionId, USERNAME, - CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID, + MigrationProject.PROJECT_SOURCE_CDM); } protected void initProjectAndHelper() throws IOException { diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/CdmExportCommandIT.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/CdmExportCommandIT.java index a5443bc9..1f6dfb41 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/CdmExportCommandIT.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/CdmExportCommandIT.java @@ -6,6 +6,7 @@ import edu.unc.lib.boxc.migration.cdm.services.CdmFieldService; import edu.unc.lib.boxc.migration.cdm.services.CdmFileRetrievalService; import edu.unc.lib.boxc.migration.cdm.services.MigrationProjectFactory; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.TestSshServer; import org.apache.commons.io.FileUtils; @@ -182,8 +183,9 @@ private Path createProject() throws Exception { } private Path createProject(String collId) throws Exception { - MigrationProject project = MigrationProjectFactory.createMigrationProject( - baseDir, collId, null, USERNAME, CdmEnvironmentHelper.DEFAULT_ENV_ID); + MigrationProject project = MigrationProjectFactory.createCdmMigrationProject( + baseDir, collId, null, USERNAME, + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); CdmFieldInfo fieldInfo = new CdmFieldInfo(); CdmFieldEntry fieldEntry = new CdmFieldEntry(); fieldEntry.setNickName("title"); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/InitializeProjectCommandIT.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/InitializeProjectCommandIT.java index 2b7b239d..dfd4521e 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/InitializeProjectCommandIT.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/InitializeProjectCommandIT.java @@ -19,8 +19,6 @@ import java.util.List; import java.util.Optional; -import com.fasterxml.jackson.databind.ObjectMapper; -import edu.unc.lib.boxc.migration.cdm.services.ChompbConfigService; import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.apache.commons.io.IOUtils; @@ -105,7 +103,7 @@ public void initValidProjectUsingCurrentDirTest() throws Exception { } @Test - public void initCdmCollectioNotFoundTest() throws Exception { + public void initCdmCollectionNotFoundTest() throws Exception { String[] initArgs = new String[] { "-w", baseDir.toString(), "--env-config", chompbConfigPath, @@ -186,6 +184,29 @@ public void initNoEnvMappingPathTest() throws Exception { assertProjectDirectoryNotCreate(); } + @Test + public void initNewProjectFromFilesystemTest() throws Exception { + String[] initArgs = new String[] { + "-w", baseDir.toString(), + "--env-config", chompbConfigPath, + "init", + "-p", "test_file_project", + "-s", "files" }; + executeExpectSuccess(initArgs); + + MigrationProject project = MigrationProjectFactory.loadMigrationProject(baseDir.resolve("test_file_project")); + MigrationProjectProperties properties = project.getProjectProperties(); + assertEquals(USERNAME, properties.getCreator()); + assertEquals("test_file_project", properties.getName(), "Project name did not match expected value"); + assertNull(properties.getCdmCollectionId()); + assertNotNull(properties.getCreatedDate(), "Created date not set"); + assertNull(properties.getHookId()); + assertNull(properties.getCollectionNumber()); + assertNull(properties.getCdmEnvironmentId()); + assertEquals(BxcEnvironmentHelper.DEFAULT_ENV_ID, properties.getBxcEnvironmentId()); + assertTrue(Files.exists(project.getDescriptionsPath()), "Description folder not created"); + } + private void assertProjectDirectoryNotCreate() throws IOException { try (DirectoryStream dirStream = Files.newDirectoryStream(baseDir)) { for (Path path : dirStream) { diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/AggregateFileMappingServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/AggregateFileMappingServiceTest.java index cbe25e4d..9016caf6 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/AggregateFileMappingServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/AggregateFileMappingServiceTest.java @@ -6,6 +6,7 @@ import edu.unc.lib.boxc.migration.cdm.options.AggregateFileMappingOptions; import edu.unc.lib.boxc.migration.cdm.options.GroupMappingOptions; import edu.unc.lib.boxc.migration.cdm.options.GroupMappingSyncOptions; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.SipServiceHelper; import org.junit.jupiter.api.BeforeEach; @@ -38,8 +39,9 @@ public class AggregateFileMappingServiceTest { @BeforeEach public void init() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, "user", + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); Files.createDirectories(project.getExportPath()); basePath = tmpFolder.resolve("testFolder"); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/ArchivalDestinationsServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/ArchivalDestinationsServiceTest.java index 8b583189..d81c8996 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/ArchivalDestinationsServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/ArchivalDestinationsServiceTest.java @@ -70,8 +70,8 @@ public class ArchivalDestinationsServiceTest { public void setup() throws Exception { closeable = openMocks(this); project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", - CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); + tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID, + BxcEnvironmentHelper.DEFAULT_ENV_ID, MigrationProject.PROJECT_SOURCE_CDM); testHelper = new SipServiceHelper(project, tmpFolder); service = new ArchivalDestinationsService(); service.setProject(project); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/CdmExportServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/CdmExportServiceTest.java index 636a859d..0ef55441 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/CdmExportServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/CdmExportServiceTest.java @@ -6,6 +6,7 @@ import edu.unc.lib.boxc.migration.cdm.model.MigrationProject; import edu.unc.lib.boxc.migration.cdm.options.CdmExportOptions; import edu.unc.lib.boxc.migration.cdm.services.export.ExportStateService; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -53,8 +54,9 @@ public class CdmExportServiceTest { @BeforeEach public void setup() throws Exception { closeable = openMocks(this); - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, "user", + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); fieldService = new CdmFieldService(); exportStateService = new ExportStateService(); exportStateService.setProject(project); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/CdmFieldServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/CdmFieldServiceTest.java index b574f469..d15a5108 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/CdmFieldServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/CdmFieldServiceTest.java @@ -15,6 +15,7 @@ import java.util.List; import java.util.Optional; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.apache.commons.io.FileUtils; import org.apache.http.HttpEntity; @@ -56,8 +57,9 @@ public class CdmFieldServiceTest { @BeforeEach public void setup() throws Exception { closeable = openMocks(this); - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, "user", + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); service = new CdmFieldService(); service.setHttpClient(httpClient); service.setCdmBaseUri(CDM_BASE_URL); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/CdmIndexServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/CdmIndexServiceTest.java index 9776eac1..78288b15 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/CdmIndexServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/CdmIndexServiceTest.java @@ -5,11 +5,10 @@ import edu.unc.lib.boxc.migration.cdm.model.CdmFieldInfo; import edu.unc.lib.boxc.migration.cdm.model.MigrationProject; import edu.unc.lib.boxc.migration.cdm.model.MigrationProjectProperties; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.util.ProjectPropertiesSerialization; import org.apache.commons.io.FileUtils; -import org.jdom2.output.Format; -import org.jdom2.output.XMLOutputter; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -48,8 +47,9 @@ public class CdmIndexServiceTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, "user", + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); Files.createDirectories(project.getExportPath()); fieldService = new CdmFieldService(); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/DescriptionsServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/DescriptionsServiceTest.java index e56b7028..44060e27 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/DescriptionsServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/DescriptionsServiceTest.java @@ -17,6 +17,7 @@ import java.util.Set; import java.util.stream.Stream; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.apache.commons.io.FileUtils; import org.jdom2.Document; @@ -50,7 +51,8 @@ public class DescriptionsServiceTest { @BeforeEach public void setup() throws Exception { basePath = tmpFolder; - project = MigrationProjectFactory.createMigrationProject(basePath, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject(basePath, PROJECT_NAME, null, + "user", CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); Files.createDirectories(project.getDescriptionsPath()); service = new DescriptionsService(); service.setProject(project); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/FieldAssessmentTemplateServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/FieldAssessmentTemplateServiceTest.java index c22a8658..509fc5d4 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/FieldAssessmentTemplateServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/FieldAssessmentTemplateServiceTest.java @@ -6,6 +6,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.fail; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -35,8 +36,9 @@ public class FieldAssessmentTemplateServiceTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, "user", + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); fieldService = new CdmFieldService(); service = new FieldAssessmentTemplateService(); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/FieldUrlAssessmentServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/FieldUrlAssessmentServiceTest.java index 3d9320d1..4a47700e 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/FieldUrlAssessmentServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/FieldUrlAssessmentServiceTest.java @@ -19,6 +19,7 @@ import java.util.stream.Collectors; import edu.unc.lib.boxc.migration.cdm.model.CdmFieldInfo; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.SipServiceHelper; import org.apache.commons.csv.CSVFormat; @@ -52,8 +53,9 @@ public class FieldUrlAssessmentServiceTest { @BeforeEach public void setup(WireMockRuntimeInfo wmRuntimeInfo) throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, "user", + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); Files.createDirectories(project.getExportPath()); var testHelper = new SipServiceHelper(project, tmpFolder); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/FindingAidServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/FindingAidServiceTest.java index e80c489a..357eaf48 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/FindingAidServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/FindingAidServiceTest.java @@ -8,6 +8,7 @@ import edu.unc.lib.boxc.migration.cdm.exceptions.MigrationException; import edu.unc.lib.boxc.migration.cdm.model.MigrationProject; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -29,8 +30,9 @@ public class FindingAidServiceTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, "user", + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); fieldService = new CdmFieldService(); service = new FindingAidService(); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/GroupMappingServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/GroupMappingServiceTest.java index 44b6584b..a389f16f 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/GroupMappingServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/GroupMappingServiceTest.java @@ -9,6 +9,7 @@ import edu.unc.lib.boxc.migration.cdm.model.MigrationProjectProperties; import edu.unc.lib.boxc.migration.cdm.options.GroupMappingOptions; import edu.unc.lib.boxc.migration.cdm.options.GroupMappingSyncOptions; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.OutputHelper; import edu.unc.lib.boxc.migration.cdm.test.SipServiceHelper; @@ -53,8 +54,9 @@ public class GroupMappingServiceTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, "user", + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); Files.createDirectories(project.getExportPath()); fieldService = new CdmFieldService(); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/IndexFilteringServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/IndexFilteringServiceTest.java index 3e6d493b..16944900 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/IndexFilteringServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/IndexFilteringServiceTest.java @@ -37,8 +37,8 @@ public class IndexFilteringServiceTest { @BeforeEach public void setup() throws Exception { project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, USERNAME, - CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); + tmpFolder, PROJECT_NAME, null, USERNAME, CdmEnvironmentHelper.DEFAULT_ENV_ID, + BxcEnvironmentHelper.DEFAULT_ENV_ID, MigrationProject.PROJECT_SOURCE_CDM); testHelper = new SipServiceHelper(project, tmpFolder); service = new IndexFilteringService(); service.setProject(project); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/MigrationProjectFactoryTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/MigrationProjectFactoryTest.java index 5fcde246..ff52edaa 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/MigrationProjectFactoryTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/MigrationProjectFactoryTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -11,6 +12,7 @@ import java.nio.file.Files; import java.nio.file.Path; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -33,6 +35,7 @@ public class MigrationProjectFactoryTest { public Path tmpFolder; private Path projectsBase; private String testEnv = CdmEnvironmentHelper.DEFAULT_ENV_ID; + private String bxcTestEnv = BxcEnvironmentHelper.DEFAULT_ENV_ID; @BeforeEach public void setup() throws Exception { @@ -42,7 +45,8 @@ public void setup() throws Exception { @Test public void createNoUserTest() throws Exception { try { - MigrationProjectFactory.createMigrationProject(projectsBase, null, null, null, testEnv); + MigrationProjectFactory.createCdmMigrationProject(projectsBase, null, null, null, + testEnv, bxcTestEnv); fail(); } catch (IllegalArgumentException e) { // Expected @@ -53,7 +57,7 @@ public void createNoUserTest() throws Exception { @Test public void createWithNameTest() throws Exception { MigrationProject project = MigrationProjectFactory - .createMigrationProject(projectsBase, PROJ_NAME, null, USERNAME, testEnv); + .createCdmMigrationProject(projectsBase, PROJ_NAME, null, USERNAME, testEnv, bxcTestEnv); assertNotNull(project); assertEquals(projectsBase.resolve(PROJ_NAME), project.getProjectPath()); @@ -68,7 +72,7 @@ public void createWithNameAlreadyExistsTest() throws Exception { Files.createDirectory(projectsBase.resolve(PROJ_NAME)); MigrationProject project = MigrationProjectFactory - .createMigrationProject(projectsBase, PROJ_NAME, null, USERNAME, testEnv); + .createCdmMigrationProject(projectsBase, PROJ_NAME, null, USERNAME, testEnv, bxcTestEnv); assertNotNull(project); assertEquals(projectsBase.resolve(PROJ_NAME), project.getProjectPath()); @@ -82,7 +86,7 @@ public void createPathNotDirectoryTest() throws Exception { Files.createFile(projectsBase.resolve(PROJ_NAME)); try { // Create file at expected project path - MigrationProjectFactory.createMigrationProject(projectsBase, PROJ_NAME, null, USERNAME, testEnv); + MigrationProjectFactory.createCdmMigrationProject(projectsBase, PROJ_NAME, null, USERNAME, testEnv, bxcTestEnv); fail(); } catch (InvalidProjectStateException e) { assertTrue(e.getMessage().contains("already exists and is not a directory")); @@ -92,7 +96,7 @@ public void createPathNotDirectoryTest() throws Exception { @Test public void createWithNameAndCollectionTest() throws Exception { MigrationProject project = MigrationProjectFactory - .createMigrationProject(projectsBase, PROJ_NAME, COLL_ID, USERNAME, testEnv); + .createCdmMigrationProject(projectsBase, PROJ_NAME, COLL_ID, USERNAME, testEnv, bxcTestEnv); assertNotNull(project); assertEquals(projectsBase.resolve(PROJ_NAME), project.getProjectPath()); @@ -108,7 +112,7 @@ public void createForExistingDirectoryTest() throws Exception { Files.createDirectory(projectPath); MigrationProject project = MigrationProjectFactory - .createMigrationProject(projectPath, null, null, USERNAME, testEnv); + .createCdmMigrationProject(projectPath, null, null, USERNAME, testEnv, bxcTestEnv); assertNotNull(project); assertEquals(projectPath, project.getProjectPath()); @@ -124,7 +128,7 @@ public void createForExistingDirectoryWithCollIdTest() throws Exception { Files.createDirectory(projectPath); MigrationProject project = MigrationProjectFactory - .createMigrationProject(projectPath, null, COLL_ID, USERNAME, testEnv); + .createCdmMigrationProject(projectPath, null, COLL_ID, USERNAME, testEnv, bxcTestEnv); assertNotNull(project); assertEquals(projectPath, project.getProjectPath()); @@ -136,11 +140,11 @@ public void createForExistingDirectoryWithCollIdTest() throws Exception { @Test public void createProjectAlreadyExistsTest() throws Exception { MigrationProject project = MigrationProjectFactory - .createMigrationProject(projectsBase, PROJ_NAME, null, USERNAME, testEnv); + .createCdmMigrationProject(projectsBase, PROJ_NAME, null, USERNAME, testEnv, bxcTestEnv); try { // Create file at expected project path - MigrationProjectFactory.createMigrationProject(projectsBase, PROJ_NAME, COLL_ID, USERNAME, testEnv); + MigrationProjectFactory.createCdmMigrationProject(projectsBase, PROJ_NAME, COLL_ID, USERNAME, testEnv, bxcTestEnv); fail(); } catch (InvalidProjectStateException e) { assertTrue(e.getMessage().contains("directory already contains a migration project")); @@ -184,7 +188,7 @@ public void loadNotAProjectTest() throws Exception { public void loadValidProject() throws Exception { Path projectPath = projectsBase.resolve(PROJ_NAME); MigrationProject projectCreated = MigrationProjectFactory - .createMigrationProject(projectsBase, PROJ_NAME, COLL_ID, USERNAME, testEnv); + .createCdmMigrationProject(projectsBase, PROJ_NAME, COLL_ID, USERNAME, testEnv, bxcTestEnv); MigrationProject projectLoaded = MigrationProjectFactory.loadMigrationProject(projectPath); @@ -199,6 +203,40 @@ public void loadValidProject() throws Exception { "Expect created and loaded projects to have same timestamp"); } + @Test + public void createFilesMigrationTest() throws Exception { + Path projectPath = projectsBase.resolve(PROJ_NAME); + MigrationProject projectCreated = MigrationProjectFactory + .createFilesMigrationProject(projectsBase, PROJ_NAME, USERNAME, bxcTestEnv); + + MigrationProject projectLoaded = MigrationProjectFactory.loadMigrationProject(projectPath); + + assertNotNull(projectLoaded); + assertEquals(projectPath, projectLoaded.getProjectPath()); + + MigrationProjectProperties returnedProperties = projectLoaded.getProjectProperties(); + assertEquals(USERNAME, returnedProperties.getCreator()); + assertEquals(PROJ_NAME, returnedProperties.getName(), "Project name did not match expected value"); + assertEquals(MigrationProject.PROJECT_SOURCE_FILES, returnedProperties.getProjectSource()); + assertNull(returnedProperties.getCdmCollectionId()); + assertNotNull(returnedProperties.getCreatedDate(), "Created date not set"); + assertNull(returnedProperties.getCdmEnvironmentId()); + + Path propertiesPath = projectLoaded.getProjectPropertiesPath(); + assertTrue(Files.exists(propertiesPath), "Properties object must exist"); + MigrationProjectProperties propertiesFile = ProjectPropertiesSerialization.read(propertiesPath); + assertEquals(USERNAME, propertiesFile.getCreator()); + assertEquals(PROJ_NAME, propertiesFile.getName(), "Project name did not match expected value"); + assertEquals(MigrationProject.PROJECT_SOURCE_FILES, propertiesFile.getProjectSource()); + assertNull(propertiesFile.getCdmCollectionId()); + assertNotNull(propertiesFile.getCreatedDate(), "Created date not set"); + assertNull(propertiesFile.getCdmEnvironmentId()); + + assertEquals(projectCreated.getProjectProperties().getCreatedDate(), + projectLoaded.getProjectProperties().getCreatedDate(), + "Expect created and loaded projects to have same timestamp"); + } + private void assertPropertiesFilePopulated(MigrationProject project, String expName, String expCollId) throws IOException { Path propertiesPath = project.getProjectPropertiesPath(); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/MigrationTypeReportServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/MigrationTypeReportServiceTest.java index 88447f14..e8d020a0 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/MigrationTypeReportServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/MigrationTypeReportServiceTest.java @@ -37,8 +37,8 @@ public class MigrationTypeReportServiceTest { @BeforeEach public void setup() throws Exception { project = MigrationProjectFactory.createMigrationProject( - tmpFolder, "proj", null, "user", - CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); + tmpFolder, "proj", null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID, + BxcEnvironmentHelper.DEFAULT_ENV_ID, MigrationProject.PROJECT_SOURCE_CDM); testHelper = new SipServiceHelper(project, tmpFolder); reportGenerator = new PostMigrationReportService(); reportGenerator.setProject(project); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/PermissionsServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/PermissionsServiceTest.java index 63cb96f7..b56b6a7b 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/PermissionsServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/PermissionsServiceTest.java @@ -52,8 +52,8 @@ public class PermissionsServiceTest { public void setup() throws Exception { closeable = openMocks(this); project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", - CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); + tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID, + BxcEnvironmentHelper.DEFAULT_ENV_ID, MigrationProject.PROJECT_SOURCE_CDM); testHelper = new SipServiceHelper(project, tmpFolder); service = new PermissionsService(); service.setProject(project); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/PostMigrationReportServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/PostMigrationReportServiceTest.java index bc72d6dd..08801df9 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/PostMigrationReportServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/PostMigrationReportServiceTest.java @@ -47,8 +47,8 @@ public class PostMigrationReportServiceTest { public void setup() throws Exception { closeable = openMocks(this); project = MigrationProjectFactory.createMigrationProject( - tmpFolder, "proj", null, "user", - CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); + tmpFolder, "proj", null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID, + BxcEnvironmentHelper.DEFAULT_ENV_ID, MigrationProject.PROJECT_SOURCE_CDM); testHelper = new SipServiceHelper(project, tmpFolder); descriptionsService = testHelper.getDescriptionsService(); sourceFileService = testHelper.getSourceFileService(); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/PostMigrationReportVerifierTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/PostMigrationReportVerifierTest.java index c014b1b5..2401b2e1 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/PostMigrationReportVerifierTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/PostMigrationReportVerifierTest.java @@ -52,8 +52,8 @@ public class PostMigrationReportVerifierTest { public void setup() throws Exception { closeable = openMocks(this); project = MigrationProjectFactory.createMigrationProject( - tmpFolder, "proj", null, "user", - CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); + tmpFolder, "proj", null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID, + BxcEnvironmentHelper.DEFAULT_ENV_ID, MigrationProject.PROJECT_SOURCE_CDM); testHelper = new SipServiceHelper(project, tmpFolder); reportGenerator = new PostMigrationReportService(); reportGenerator.setProject(project); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/ProjectPropertiesServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/ProjectPropertiesServiceTest.java index dfe79b5c..3fd8cb0c 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/ProjectPropertiesServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/ProjectPropertiesServiceTest.java @@ -8,6 +8,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.fail; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -35,8 +36,9 @@ public class ProjectPropertiesServiceTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, "user", + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); service = new ProjectPropertiesService(); service.setProject(project); } diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/RedirectMappingIndexServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/RedirectMappingIndexServiceTest.java index 9c9acd0a..1c8eb730 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/RedirectMappingIndexServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/RedirectMappingIndexServiceTest.java @@ -48,8 +48,8 @@ public class RedirectMappingIndexServiceTest { @BeforeEach public void setup() throws Exception { project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", - CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); + tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID, + BxcEnvironmentHelper.DEFAULT_ENV_ID, MigrationProject.PROJECT_SOURCE_CDM); testHelper = new SipServiceHelper(project, tmpFolder); redirectMappingHelper = new RedirectMappingHelper(project); redirectMappingHelper.createRedirectMappingsTableInDb(); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SipServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SipServiceTest.java index 6b9e6f87..b9dd1eaa 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SipServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SipServiceTest.java @@ -102,8 +102,8 @@ public class SipServiceTest { public void setup() throws Exception { closeable = openMocks(this); project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, USERNAME, - CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); + tmpFolder, PROJECT_NAME, null, USERNAME, CdmEnvironmentHelper.DEFAULT_ENV_ID, + BxcEnvironmentHelper.DEFAULT_ENV_ID, MigrationProject.PROJECT_SOURCE_CDM); testHelper = new SipServiceHelper(project, tmpFolder); service = testHelper.createSipsService(); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileServiceTest.java index 96a98e6b..196ae0b8 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/SourceFileServiceTest.java @@ -13,10 +13,8 @@ import java.time.Instant; import java.util.List; -import edu.unc.lib.boxc.migration.cdm.AbstractOutputTest; -import edu.unc.lib.boxc.migration.cdm.status.SourceFilesSummaryService; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; -import edu.unc.lib.boxc.migration.cdm.test.OutputHelper; import edu.unc.lib.boxc.migration.cdm.test.SipServiceHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -50,8 +48,9 @@ public class SourceFileServiceTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, "user", + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); Files.createDirectories(project.getExportPath()); basePath = tmpFolder.resolve("testFolder"); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/StreamingMetadataServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/StreamingMetadataServiceTest.java index ec96cab6..f25b33b8 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/StreamingMetadataServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/StreamingMetadataServiceTest.java @@ -33,8 +33,8 @@ public class StreamingMetadataServiceTest { public void setup() throws Exception { closeable = openMocks(this); project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", - CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); + tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID, + BxcEnvironmentHelper.DEFAULT_ENV_ID, MigrationProject.PROJECT_SOURCE_CDM); testHelper = new SipServiceHelper(project, tmpFolder); service = new StreamingMetadataService(); service.setProject(project); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/export/ExportProgressServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/export/ExportProgressServiceTest.java index 32813e3f..065d7a23 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/export/ExportProgressServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/export/ExportProgressServiceTest.java @@ -3,6 +3,7 @@ import edu.unc.lib.boxc.migration.cdm.AbstractOutputTest; import edu.unc.lib.boxc.migration.cdm.model.MigrationProject; import edu.unc.lib.boxc.migration.cdm.services.MigrationProjectFactory; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -21,8 +22,9 @@ public class ExportProgressServiceTest extends AbstractOutputTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, "user", + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); exportStateService = new ExportStateService(); exportStateService.setProject(project); exportProgressService = new ExportProgressService(); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/export/ExportStateServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/export/ExportStateServiceTest.java index 767dde91..fdd4c197 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/export/ExportStateServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/export/ExportStateServiceTest.java @@ -4,6 +4,7 @@ import edu.unc.lib.boxc.migration.cdm.model.MigrationProject; import edu.unc.lib.boxc.migration.cdm.services.CdmFileRetrievalService; import edu.unc.lib.boxc.migration.cdm.services.MigrationProjectFactory; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -36,7 +37,8 @@ public class ExportStateServiceTest { @BeforeEach public void setup() throws Exception { project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID); + tmpFolder, PROJECT_NAME, null, "user", CdmEnvironmentHelper.DEFAULT_ENV_ID, + BxcEnvironmentHelper.DEFAULT_ENV_ID, MigrationProject.PROJECT_SOURCE_CDM); Files.copy(Paths.get("src/test/resources/gilmer_fields.csv"), project.getFieldsPath()); exportStateService = new ExportStateService(); exportStateService.setProject(project); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/status/DestinationsStatusServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/status/DestinationsStatusServiceTest.java index 594281e3..81adad3b 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/status/DestinationsStatusServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/status/DestinationsStatusServiceTest.java @@ -5,6 +5,7 @@ import java.nio.file.Path; import java.time.Instant; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.BeforeEach; @@ -35,8 +36,9 @@ public class DestinationsStatusServiceTest extends AbstractOutputTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, USERNAME, CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, USERNAME, + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); testHelper = new SipServiceHelper(project, tmpFolder); statusService = new DestinationsStatusService(); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/status/SourceFilesStatusServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/status/SourceFilesStatusServiceTest.java index fc347cf3..a2744c2a 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/status/SourceFilesStatusServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/status/SourceFilesStatusServiceTest.java @@ -5,6 +5,7 @@ import java.nio.file.Path; import java.time.Instant; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.BeforeEach; @@ -35,8 +36,9 @@ public class SourceFilesStatusServiceTest extends AbstractOutputTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, USERNAME, CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, USERNAME, + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); testHelper = new SipServiceHelper(project, tmpFolder); statusService = new SourceFilesStatusService(); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/status/SourceFilesSummaryServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/status/SourceFilesSummaryServiceTest.java index c5d298c6..2f8c0c18 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/status/SourceFilesSummaryServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/status/SourceFilesSummaryServiceTest.java @@ -6,6 +6,7 @@ import edu.unc.lib.boxc.migration.cdm.options.Verbosity; import edu.unc.lib.boxc.migration.cdm.services.MigrationProjectFactory; import edu.unc.lib.boxc.migration.cdm.services.SourceFileService; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.SipServiceHelper; import edu.unc.lib.boxc.migration.cdm.util.ProjectPropertiesSerialization; @@ -36,8 +37,9 @@ public class SourceFilesSummaryServiceTest extends AbstractOutputTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, USERNAME, CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, USERNAME, + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); basePath = tmpFolder.resolve("testFolder"); Files.createDirectory(basePath); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/DescriptionsValidatorTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/DescriptionsValidatorTest.java index acf0ce4a..5e7169c8 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/DescriptionsValidatorTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/DescriptionsValidatorTest.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.regex.Pattern; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.apache.commons.io.FileUtils; import org.jdom2.Document; @@ -38,8 +39,9 @@ public class DescriptionsValidatorTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, USERNAME, CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, USERNAME, + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); validator = new DescriptionsValidator(); validator.setProject(project); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/DestinationsValidatorTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/DestinationsValidatorTest.java index b1404739..0ecb12b4 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/DestinationsValidatorTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/DestinationsValidatorTest.java @@ -10,6 +10,7 @@ import java.nio.file.Paths; import java.util.List; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Assertions; @@ -38,8 +39,9 @@ public class DestinationsValidatorTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, USERNAME, CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, USERNAME, + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); validator = new DestinationsValidator(); validator.setProject(project); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/PermissionsValidatorTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/PermissionsValidatorTest.java index 643195ff..68189cb2 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/PermissionsValidatorTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/PermissionsValidatorTest.java @@ -5,6 +5,7 @@ import edu.unc.lib.boxc.migration.cdm.model.PermissionsInfo; import edu.unc.lib.boxc.migration.cdm.services.MigrationProjectFactory; import edu.unc.lib.boxc.migration.cdm.services.PermissionsService; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Assertions; @@ -32,8 +33,9 @@ public class PermissionsValidatorTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, USERNAME, CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, USERNAME, + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); validator = new PermissionsValidator(); validator.setProject(project); diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/SourceFilesValidatorTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/SourceFilesValidatorTest.java index 6dc2a9bd..44ca1e0a 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/SourceFilesValidatorTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/validators/SourceFilesValidatorTest.java @@ -9,6 +9,7 @@ import java.nio.file.Path; import java.util.List; +import edu.unc.lib.boxc.migration.cdm.test.BxcEnvironmentHelper; import edu.unc.lib.boxc.migration.cdm.test.CdmEnvironmentHelper; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Assertions; @@ -37,8 +38,9 @@ public class SourceFilesValidatorTest { @BeforeEach public void setup() throws Exception { - project = MigrationProjectFactory.createMigrationProject( - tmpFolder, PROJECT_NAME, null, USERNAME, CdmEnvironmentHelper.DEFAULT_ENV_ID); + project = MigrationProjectFactory.createCdmMigrationProject( + tmpFolder, PROJECT_NAME, null, USERNAME, + CdmEnvironmentHelper.DEFAULT_ENV_ID, BxcEnvironmentHelper.DEFAULT_ENV_ID); testHelper = new SipServiceHelper(project, tmpFolder); validator = new SourceFilesValidator();