AdapterComponentDocRepositoryOrchImpl { protected boolean checkForReplacementAssociation( List<JAXBElement<? extends IdentifiableType>> identifiableObjectList, RegistryErrorList errorList) { boolean replacementAssociationExists = false; for (int i = 0; i < identifiableObjectList.size(); i++) { Object tempObj = getIdentifiableObjectValue(identifiableObjectList, i); if (tempObj instanceof AssociationType1) { AssociationType1 associationObj = (AssociationType1) tempObj; LOG.debug("associationType object present"); if (NullChecker.isNullish(associationObj.getAssociationType())) { RegistryError error = docRepoHelper.setRegistryError("", "", DocRepoConstants.XDS_ERROR_CODE_MISSING_DOCUMENT_METADATA, DocRepoConstants.XDS_MISSING_DOCUMENT_METADATA + " associationType element is null."); errorList.getRegistryError().add(error); } else { String associationType = associationObj.getAssociationType(); LOG.debug("Association element associationType = {}", associationType); if (DocRepoConstants.XDS_ASSOCIATION_TYPE_REPLACE.equalsIgnoreCase(associationType)) { replacementAssociationExists = true; break; } else { replacementAssociationExists = false; } } } } LOG.debug("replacementAssociationExists = {}", replacementAssociationExists); return replacementAssociationExists; } 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 testCheckForReplacementAssociation_Success() { RegistryErrorList errorList = new RegistryErrorList(); List<JAXBElement<? extends IdentifiableType>> identifiableObjectList = mock(ArrayList.class); final AssociationType1 associationType1 = new AssociationType1(); associationType1.setAssociationType("urn:oasis:names:tc:ebxml-regrep:AssociationType:RPLC"); AdapterComponentDocRepositoryOrchImpl docRepo = new AdapterComponentDocRepositoryOrchImpl() { @Override protected Object getIdentifiableObjectValue( List<JAXBElement<? extends IdentifiableType>> identifiableObjectList, int i) { return associationType1; } }; when(identifiableObjectList.size()).thenReturn(1); boolean result = docRepo.checkForReplacementAssociation(identifiableObjectList, errorList); assertTrue(result); }
@Test public void testCheckForReplacementAssociation_Failure() { RegistryErrorList errorList = new RegistryErrorList(); List<JAXBElement<? extends IdentifiableType>> identifiableObjectList = mock(ArrayList.class); final AssociationType1 associationType1 = new AssociationType1(); AdapterComponentDocRepositoryOrchImpl docRepo = new AdapterComponentDocRepositoryOrchImpl() { @Override protected Object getIdentifiableObjectValue( List<JAXBElement<? extends IdentifiableType>> identifiableObjectList, int i) { return associationType1; } }; when(identifiableObjectList.size()).thenReturn(1); boolean result = docRepo.checkForReplacementAssociation(identifiableObjectList, errorList); assertFalse(result); assertEquals(DocRepoConstants.XDS_MISSING_DOCUMENT_METADATA + " associationType element is null.", errorList.getRegistryError().get(0).getValue()); }