AdapterComponentDocRepositoryOrchImpl { public RegistryResponseType documentRepositoryProvideAndRegisterDocumentSet( ProvideAndRegisterDocumentSetRequestType body) { LOG.debug("Entering docRepositoryHelper.documentRepositoryProvideAndRegisterDocumentSet method."); RegistryResponseType registryResponse = new ObjectFactory().createRegistryResponseType(); RegistryErrorList errorList = new RegistryErrorList(); if (body == null) { RegistryError error = docRepoHelper.setRegistryError(FIND_A_REQUIRED_ELEMENT, "", DocRepoConstants.XDS_ERROR_CODE_MISSING_REQUEST_MESSAGE_DATA, DocRepoConstants.XDS_MISSING_REQUEST_MESSAGE_DATA + " ProvideAndRegisterDocumentSetRequestType element is null."); errorList.getRegistryError().add(error); } else { LOG.trace("ProvideAndRegisterDocumentSetRequestType element is not null."); HashMap<String, DataHandler> docMap = docRepoHelper.getDocumentMap(body); SubmitObjectsRequest submitObjectsRequest = body.getSubmitObjectsRequest(); RegistryObjectListType regObjectList = submitObjectsRequest.getRegistryObjectList(); List<JAXBElement<? extends IdentifiableType>> identifiableObjectList = regObjectList.getIdentifiable(); LOG.debug("There is/are {} identifiableObject(s) in this registryObjectsList.", identifiableObjectList.size()); boolean requestHasReplacementAssociation = checkForReplacementAssociation(identifiableObjectList, errorList); for (JAXBElement<? extends IdentifiableType> identifiable : identifiableObjectList) { LOG.debug("Item is of DeclaredType: {}", identifiable.getDeclaredType()); IdentifiableType identType = identifiable.getValue(); if (identType instanceof ExtrinsicObjectType) { saveExtrinsicObject((ExtrinsicObjectType) identType, errorList, docMap, requestHasReplacementAssociation); } } } String responseStatus; if (errorList.getRegistryError().isEmpty()) { responseStatus = DocRepoConstants.XDS_RETRIEVE_RESPONSE_STATUS_SUCCESS; } else { responseStatus = DocRepoConstants.XDS_RETRIEVE_RESPONSE_STATUS_FAILURE; registryResponse.setRegistryErrorList(errorList); } registryResponse.setStatus(responseStatus); return registryResponse; } AdapterComponentDocRepositoryOrchImpl(); DocumentService getDocumentService(); LargeFileUtils getLargeFileUtils(); UTCDateUtil getDateUtil(); RetrieveDocumentSetResponseType documentRepositoryRetrieveDocumentSet(RetrieveDocumentSetRequestType body); RegistryResponseType registerDocumentSet(RegisterDocumentSetRequestType body); RegistryResponseType documentRepositoryProvideAndRegisterDocumentSet(
        ProvideAndRegisterDocumentSetRequestType body); DocumentMetadata saveExtrinsicObject(ExtrinsicObjectType extrinsicObject, RegistryErrorList errorList,
        Map<String, DataHandler> docMap, boolean hasReplacementRequest);  }
@Test public void testDocumentRepositoryProvideAndRegisterDocumentSet_Success() { ProvideAndRegisterDocumentSetRequestType body = mock(ProvideAndRegisterDocumentSetRequestType.class); final HashMap<String, DataHandler> docMap = new HashMap<String, DataHandler>(); SubmitObjectsRequest submitObjectsRequest = mock(SubmitObjectsRequest.class); RegistryObjectListType regObjectList = mock(RegistryObjectListType.class); List<JAXBElement<? extends IdentifiableType>> identifiableObjectList = new ArrayList<JAXBElement<? extends IdentifiableType>>(); AdapterComponentDocRepositoryOrchImpl docRepo = new AdapterComponentDocRepositoryOrchImpl(); when(body.getSubmitObjectsRequest()).thenReturn(submitObjectsRequest); when(submitObjectsRequest.getRegistryObjectList()).thenReturn(regObjectList); when(regObjectList.getIdentifiable()).thenReturn(identifiableObjectList); RegistryResponseType registryResponse = docRepo.documentRepositoryProvideAndRegisterDocumentSet(body); assertEquals(DocRepoConstants.XDS_RETRIEVE_RESPONSE_STATUS_SUCCESS, registryResponse.getStatus()); }
@Test public void testDocumentRepositoryProvideAndRegisterDocumentSet_Failure() { ProvideAndRegisterDocumentSetRequestType body = null; AdapterComponentDocRepositoryOrchImpl docRepo = new AdapterComponentDocRepositoryOrchImpl(); RegistryResponseType registryResponse = docRepo.documentRepositoryProvideAndRegisterDocumentSet(body); RegistryErrorList errorList = registryResponse.getRegistryErrorList(); RegistryError error = errorList.getRegistryError().get(0); assertEquals(DocRepoConstants.XDS_RETRIEVE_RESPONSE_STATUS_FAILURE, registryResponse.getStatus()); assertEquals(DocRepoConstants.XDS_MISSING_REQUEST_MESSAGE_DATA + " ProvideAndRegisterDocumentSetRequestType element is null.", error.getValue()); }