@SuppressWarnings("unchecked") @Test public void test_submission_of_wct_sip() throws Exception { FileInputStream fis = new FileInputStream(wctMetsPath); int fileSize = fis.available(); byte[] binaryData = new byte[fileSize]; fis.read(binaryData); String wctSip = new String(binaryData); Mockery mockContext = constructMockContext(); final DepositWebServicesFactory depositWebServicesFactory = mockContext.mock(DepositWebServicesFactory.class); final DepositWebServices depositWebServices = mockContext.mock(DepositWebServices.class); final PdsClientFactory pdsClientFactory = mockContext.mock(PdsClientFactory.class); final PdsClient pdsClient = mockContext.mock(PdsClient.class); final DnxMapper dnxMapper = new DnxMapperImpl(new MetsWriterFactoryImpl()); final FileMover fileMover = mockContext.mock(FileMover.class); final PreDepositProcessor preDepositProcessor = new ArcIndexProcessor(); final DpsDepositFacade dpsDeposit = new DpsDepositFacadeImpl(depositWebServicesFactory, pdsClientFactory, fileMover, dnxMapper, preDepositProcessor); final String pdsSessionId = "pdsSessionId"; populateArcFileContents(); List<File> fileList = extractFileDetailsFrom(); final Map<String, String> parameters = populateDepositParameter(wctSip); mockContext.checking(new Expectations() { { one(depositWebServicesFactory).createInstance(with(any(WctDepositParameter.class))); will(returnValue(depositWebServices)); one(depositWebServices).submitDepositActivity(with(any(String.class)), with(any(String.class)), with(any(String.class)), with(any(String.class)), with(any(String.class))); will(returnValue(DepositResultConverterTest.buildMessage(false))); one(fileMover).move(with(any(MetsDocument.class)), with(any(List.class)), with(any(WctDepositParameter.class))); allowing(pdsClientFactory).createInstance(); will(returnValue(pdsClient)); allowing(pdsClient).init(with(any(String.class)), with(any(boolean.class))); allowing(pdsClient).login(with(any(String.class)), with(any(String.class)), with(any(String.class))); will(returnValue(pdsSessionId)); } }); DepositResult depositResult = dpsDeposit.deposit(parameters, fileList); if (depositResult.isError()) throw new RuntimeException("Submission to DPS failed, message from DPS: " + depositResult.getMessageDesciption()); mockContext.assertIsSatisfied(); assertThat(depositResult.getSipId(), is(notNullValue())); }
public DepositResult deposit(Map<String, String> parameters, List<File> fileList) throws WctDepositParameterValidationException { DepositResult depositResultAdapter = null; try { String targetInstanceOID = parameters.get(DpsDepositFacade.TARGET_INSTANCE_ID); String finalSIP = parameters.get(DpsDepositFacade.WCT_METS_XML_DOCUMENT); String ilsReference = parameters.get(DpsDepositFacade.ILS_REFERENCE); String accessRestriction = parameters.get(DpsDepositFacade.ACCESS_RESTRICTION); FileArchiveBuilder archiveBuilder = populateFileArchiveBuilderFrom(fileList); XPathWctMetsExtractor wctDataExtractor = new XPathWctMetsExtractor(); String metsFileName = "METS-" + targetInstanceOID + ".xml"; wctDataExtractor.parseFile(finalSIP.getBytes(), metsFileName, archiveBuilder); setHarvestType(wctDataExtractor, parameters.get(HARVEST_TYPE)); setAdditionalDublinCoreElements(wctDataExtractor, parameters); wctDataExtractor.setIeEntityType(parameters.get(IE_ENTITY_TYPE)); wctDataExtractor.setWctTargetInstanceID(targetInstanceOID); wctDataExtractor.setILSReference(ilsReference); wctDataExtractor.setAccessRestriction(accessRestriction); wctDataExtractor.setCmsSection(parameters.get(CMS_SECTION)); wctDataExtractor.setCmsSystem(parameters.get(CMS_SYSTEM)); wctDataExtractor.setDCTitleSource(parameters.get(TITLE_SOURCE)); WctDepositParameter depositParameter = populateDepositParameterFromMap(parameters); depositResultAdapter = deposit(wctDataExtractor, depositParameter); } finally { } return depositResultAdapter; }
DpsDepositFacadeImpl implements DpsDepositFacade { public DepositResult deposit(Map<String, String> parameters, List<File> fileList) throws WctDepositParameterValidationException { DepositResult depositResultAdapter = null; try { String targetInstanceOID = parameters.get(DpsDepositFacade.TARGET_INSTANCE_ID); String finalSIP = parameters.get(DpsDepositFacade.WCT_METS_XML_DOCUMENT); String ilsReference = parameters.get(DpsDepositFacade.ILS_REFERENCE); String accessRestriction = parameters.get(DpsDepositFacade.ACCESS_RESTRICTION); FileArchiveBuilder archiveBuilder = populateFileArchiveBuilderFrom(fileList); XPathWctMetsExtractor wctDataExtractor = new XPathWctMetsExtractor(); String metsFileName = "METS-" + targetInstanceOID + ".xml"; wctDataExtractor.parseFile(finalSIP.getBytes(), metsFileName, archiveBuilder); setHarvestType(wctDataExtractor, parameters.get(HARVEST_TYPE)); setAdditionalDublinCoreElements(wctDataExtractor, parameters); wctDataExtractor.setIeEntityType(parameters.get(IE_ENTITY_TYPE)); wctDataExtractor.setWctTargetInstanceID(targetInstanceOID); wctDataExtractor.setILSReference(ilsReference); wctDataExtractor.setAccessRestriction(accessRestriction); wctDataExtractor.setCmsSection(parameters.get(CMS_SECTION)); wctDataExtractor.setCmsSystem(parameters.get(CMS_SYSTEM)); wctDataExtractor.setDCTitleSource(parameters.get(TITLE_SOURCE)); WctDepositParameter depositParameter = populateDepositParameterFromMap(parameters); depositResultAdapter = deposit(wctDataExtractor, depositParameter); } finally { } return depositResultAdapter; } }
DpsDepositFacadeImpl implements DpsDepositFacade { public DepositResult deposit(Map<String, String> parameters, List<File> fileList) throws WctDepositParameterValidationException { DepositResult depositResultAdapter = null; try { String targetInstanceOID = parameters.get(DpsDepositFacade.TARGET_INSTANCE_ID); String finalSIP = parameters.get(DpsDepositFacade.WCT_METS_XML_DOCUMENT); String ilsReference = parameters.get(DpsDepositFacade.ILS_REFERENCE); String accessRestriction = parameters.get(DpsDepositFacade.ACCESS_RESTRICTION); FileArchiveBuilder archiveBuilder = populateFileArchiveBuilderFrom(fileList); XPathWctMetsExtractor wctDataExtractor = new XPathWctMetsExtractor(); String metsFileName = "METS-" + targetInstanceOID + ".xml"; wctDataExtractor.parseFile(finalSIP.getBytes(), metsFileName, archiveBuilder); setHarvestType(wctDataExtractor, parameters.get(HARVEST_TYPE)); setAdditionalDublinCoreElements(wctDataExtractor, parameters); wctDataExtractor.setIeEntityType(parameters.get(IE_ENTITY_TYPE)); wctDataExtractor.setWctTargetInstanceID(targetInstanceOID); wctDataExtractor.setILSReference(ilsReference); wctDataExtractor.setAccessRestriction(accessRestriction); wctDataExtractor.setCmsSection(parameters.get(CMS_SECTION)); wctDataExtractor.setCmsSystem(parameters.get(CMS_SYSTEM)); wctDataExtractor.setDCTitleSource(parameters.get(TITLE_SOURCE)); WctDepositParameter depositParameter = populateDepositParameterFromMap(parameters); depositResultAdapter = deposit(wctDataExtractor, depositParameter); } finally { } return depositResultAdapter; } @Inject  DpsDepositFacadeImpl(DepositWebServicesFactory dwsFactory, PdsClientFactory pdsClientFactory, FileMover fileMover, DnxMapper dnxMapper, PreDepositProcessor preDepositProcessor); }
DpsDepositFacadeImpl implements DpsDepositFacade { public DepositResult deposit(Map<String, String> parameters, List<File> fileList) throws WctDepositParameterValidationException { DepositResult depositResultAdapter = null; try { String targetInstanceOID = parameters.get(DpsDepositFacade.TARGET_INSTANCE_ID); String finalSIP = parameters.get(DpsDepositFacade.WCT_METS_XML_DOCUMENT); String ilsReference = parameters.get(DpsDepositFacade.ILS_REFERENCE); String accessRestriction = parameters.get(DpsDepositFacade.ACCESS_RESTRICTION); FileArchiveBuilder archiveBuilder = populateFileArchiveBuilderFrom(fileList); XPathWctMetsExtractor wctDataExtractor = new XPathWctMetsExtractor(); String metsFileName = "METS-" + targetInstanceOID + ".xml"; wctDataExtractor.parseFile(finalSIP.getBytes(), metsFileName, archiveBuilder); setHarvestType(wctDataExtractor, parameters.get(HARVEST_TYPE)); setAdditionalDublinCoreElements(wctDataExtractor, parameters); wctDataExtractor.setIeEntityType(parameters.get(IE_ENTITY_TYPE)); wctDataExtractor.setWctTargetInstanceID(targetInstanceOID); wctDataExtractor.setILSReference(ilsReference); wctDataExtractor.setAccessRestriction(accessRestriction); wctDataExtractor.setCmsSection(parameters.get(CMS_SECTION)); wctDataExtractor.setCmsSystem(parameters.get(CMS_SYSTEM)); wctDataExtractor.setDCTitleSource(parameters.get(TITLE_SOURCE)); WctDepositParameter depositParameter = populateDepositParameterFromMap(parameters); depositResultAdapter = deposit(wctDataExtractor, depositParameter); } finally { } return depositResultAdapter; } @Inject  DpsDepositFacadeImpl(DepositWebServicesFactory dwsFactory, PdsClientFactory pdsClientFactory, FileMover fileMover, DnxMapper dnxMapper, PreDepositProcessor preDepositProcessor); DepositResult deposit(Map<String, String> parameters, List<File> fileList); String loginToPDS(Map<String, String> parameters); void setCustomDepositFormMapping(CustomDepositFormMapping customDepositFormMapping); }
DpsDepositFacadeImpl implements DpsDepositFacade { public DepositResult deposit(Map<String, String> parameters, List<File> fileList) throws WctDepositParameterValidationException { DepositResult depositResultAdapter = null; try { String targetInstanceOID = parameters.get(DpsDepositFacade.TARGET_INSTANCE_ID); String finalSIP = parameters.get(DpsDepositFacade.WCT_METS_XML_DOCUMENT); String ilsReference = parameters.get(DpsDepositFacade.ILS_REFERENCE); String accessRestriction = parameters.get(DpsDepositFacade.ACCESS_RESTRICTION); FileArchiveBuilder archiveBuilder = populateFileArchiveBuilderFrom(fileList); XPathWctMetsExtractor wctDataExtractor = new XPathWctMetsExtractor(); String metsFileName = "METS-" + targetInstanceOID + ".xml"; wctDataExtractor.parseFile(finalSIP.getBytes(), metsFileName, archiveBuilder); setHarvestType(wctDataExtractor, parameters.get(HARVEST_TYPE)); setAdditionalDublinCoreElements(wctDataExtractor, parameters); wctDataExtractor.setIeEntityType(parameters.get(IE_ENTITY_TYPE)); wctDataExtractor.setWctTargetInstanceID(targetInstanceOID); wctDataExtractor.setILSReference(ilsReference); wctDataExtractor.setAccessRestriction(accessRestriction); wctDataExtractor.setCmsSection(parameters.get(CMS_SECTION)); wctDataExtractor.setCmsSystem(parameters.get(CMS_SYSTEM)); wctDataExtractor.setDCTitleSource(parameters.get(TITLE_SOURCE)); WctDepositParameter depositParameter = populateDepositParameterFromMap(parameters); depositResultAdapter = deposit(wctDataExtractor, depositParameter); } finally { } return depositResultAdapter; } @Inject  DpsDepositFacadeImpl(DepositWebServicesFactory dwsFactory, PdsClientFactory pdsClientFactory, FileMover fileMover, DnxMapper dnxMapper, PreDepositProcessor preDepositProcessor); DepositResult deposit(Map<String, String> parameters, List<File> fileList); String loginToPDS(Map<String, String> parameters); void setCustomDepositFormMapping(CustomDepositFormMapping customDepositFormMapping);  }