@Test public void should_map_unit_with_empty_fields() throws Exception { ArchiveUnitMapper archiveUnitMapper = new ArchiveUnitMapper(); ArchiveUnitModel archiveUnitModel = new ArchiveUnitModel(); archiveUnitModel.setId("1234564"); archiveUnitModel.setDescriptiveMetadataModel(new DescriptiveMetadataModel()); RuleCategoryModel rule; rule = generateRule(SedaConstants.TAG_RULE_ACCESS); archiveUnitModel.getManagement().setRuleCategoryModel(rule, SedaConstants.TAG_RULE_ACCESS); rule = generateRule(SedaConstants.TAG_RULE_APPRAISAL); archiveUnitModel.getManagement().setRuleCategoryModel(rule, SedaConstants.TAG_RULE_APPRAISAL); rule = generateRule(SedaConstants.TAG_RULE_CLASSIFICATION); rule.setClassificationLevel("fakeClassificationLevel"); rule.setClassificationOwner("fakeClassificationOwner"); rule.setNeedReassessingAuthorization(true); rule.setClassificationReassessingDate("2000-01-02"); archiveUnitModel.getManagement().setRuleCategoryModel(rule, SedaConstants.TAG_RULE_CLASSIFICATION); rule = generateRule(SedaConstants.TAG_RULE_DISSEMINATION); archiveUnitModel.getManagement().setRuleCategoryModel(rule, SedaConstants.TAG_RULE_DISSEMINATION); rule = generateRule(SedaConstants.TAG_RULE_REUSE); archiveUnitModel.getManagement().setRuleCategoryModel(rule, SedaConstants.TAG_RULE_REUSE); rule = generateRule(SedaConstants.TAG_RULE_STORAGE); archiveUnitModel.getManagement().setRuleCategoryModel(rule, SedaConstants.TAG_RULE_STORAGE); OrganizationType organizationType = getOrganizationTye(); archiveUnitModel.getDescriptiveMetadataModel().setOriginatingAgency(organizationType); ArchiveUnitType archiveUnitType = archiveUnitMapper.map(archiveUnitModel); assertThat(archiveUnitType.getId()).isEqualTo("1234564"); ManagementType management = archiveUnitType.getManagement(); assertThat(management).isNotNull(); assertThat(management.getAccessRule()).isNotNull(); assertThat(management.getAccessRule().isPreventInheritance()).isNull(); assertThat(management.getAccessRule().getRefNonRuleId()).hasSize(2); assertThat(management.getAccessRule().getRefNonRuleId().get(0).getValue()).isIn("R1", "R2"); assertThat(management.getAccessRule().getRefNonRuleId().get(1).getValue()).isIn("R1", "R2"); assertThat(management.getAccessRule().getRuleAndStartDate()).hasSize(1); assertThat(management.getAccessRule().getRuleAndStartDate().get(0)).isInstanceOf(RuleIdType.class); RuleIdType ruleIdType = (RuleIdType) management.getAccessRule().getRuleAndStartDate().get(0); assertThat(ruleIdType.getValue()).isEqualTo("R3"); assertThat(management.getAppraisalRule()).isNotNull(); assertThat(management.getAppraisalRule().isPreventInheritance()).isNull(); assertThat(management.getAppraisalRule().getRefNonRuleId()).hasSize(2); assertThat(management.getAppraisalRule().getRefNonRuleId().get(0).getValue()).isIn("R1", "R2"); assertThat(management.getAppraisalRule().getRefNonRuleId().get(1).getValue()).isIn("R1", "R2"); assertThat(management.getAppraisalRule().getRuleAndStartDate().get(0)).isInstanceOf(RuleIdType.class); ruleIdType = (RuleIdType) management.getAppraisalRule().getRuleAndStartDate().get(0); assertThat(ruleIdType.getValue()).isEqualTo("R3"); assertThat(management.getAppraisalRule().getRuleAndStartDate().get(1)).isInstanceOf(XMLGregorianCalendar.class); XMLGregorianCalendar date = (XMLGregorianCalendar) management.getAppraisalRule().getRuleAndStartDate().get(1); assertThat(date.getYear()).isEqualTo(2000); assertThat(date.getMonth()).isEqualTo(1); assertThat(date.getDay()).isEqualTo(1); assertThat(management.getAppraisalRule().getFinalAction().value()).isEqualTo("Keep"); assertThat(management.getClassificationRule()).isNotNull(); assertThat(management.getClassificationRule().isPreventInheritance()).isNull(); assertThat(management.getClassificationRule().getRefNonRuleId()).hasSize(2); assertThat(management.getClassificationRule().getRefNonRuleId().get(0).getValue()).isIn("R1", "R2"); assertThat(management.getClassificationRule().getRefNonRuleId().get(1).getValue()).isIn("R1", "R2"); assertThat(management.getClassificationRule().getRuleAndStartDate().get(0)).isInstanceOf(RuleIdType.class); ruleIdType = (RuleIdType) management.getClassificationRule().getRuleAndStartDate().get(0); assertThat(ruleIdType.getValue()).isEqualTo("R3"); assertThat(management.getClassificationRule().getRuleAndStartDate().get(1)) .isInstanceOf(XMLGregorianCalendar.class); date = (XMLGregorianCalendar) management.getClassificationRule().getRuleAndStartDate().get(1); assertThat(date.getYear()).isEqualTo(2000); assertThat(date.getMonth()).isEqualTo(1); assertThat(date.getDay()).isEqualTo(1); assertThat(management.getClassificationRule().isNeedReassessingAuthorization()).isTrue(); date = management.getClassificationRule().getClassificationReassessingDate(); assertThat(date.getYear()).isEqualTo(2000); assertThat(date.getMonth()).isEqualTo(1); assertThat(date.getDay()).isEqualTo(2); assertThat(management.getDisseminationRule()).isNotNull(); assertThat(management.getDisseminationRule().isPreventInheritance()).isNull(); assertThat(management.getDisseminationRule().getRefNonRuleId()).hasSize(2); assertThat(management.getDisseminationRule().getRefNonRuleId().get(0).getValue()).isIn("R1", "R2"); assertThat(management.getDisseminationRule().getRefNonRuleId().get(1).getValue()).isIn("R1", "R2"); assertThat(management.getDisseminationRule().getRuleAndStartDate().get(0)).isInstanceOf(RuleIdType.class); ruleIdType = (RuleIdType) management.getDisseminationRule().getRuleAndStartDate().get(0); assertThat(ruleIdType.getValue()).isEqualTo("R3"); assertThat(management.getDisseminationRule().getRuleAndStartDate().get(1)) .isInstanceOf(XMLGregorianCalendar.class); date = (XMLGregorianCalendar) management.getDisseminationRule().getRuleAndStartDate().get(1); assertThat(date.getYear()).isEqualTo(2000); assertThat(date.getMonth()).isEqualTo(1); assertThat(date.getDay()).isEqualTo(1); assertThat(management.getReuseRule()).isNotNull(); assertThat(management.getReuseRule().isPreventInheritance()).isNull(); assertThat(management.getReuseRule().getRefNonRuleId()).hasSize(2); assertThat(management.getReuseRule().getRefNonRuleId().get(0).getValue()).isIn("R1", "R2"); assertThat(management.getReuseRule().getRefNonRuleId().get(1).getValue()).isIn("R1", "R2"); assertThat(management.getReuseRule().getRuleAndStartDate().get(0)).isInstanceOf(RuleIdType.class); ruleIdType = (RuleIdType) management.getReuseRule().getRuleAndStartDate().get(0); assertThat(ruleIdType.getValue()).isEqualTo("R3"); assertThat(management.getReuseRule().getRuleAndStartDate().get(1)).isInstanceOf(XMLGregorianCalendar.class); date = (XMLGregorianCalendar) management.getReuseRule().getRuleAndStartDate().get(1); assertThat(date.getYear()).isEqualTo(2000); assertThat(date.getMonth()).isEqualTo(1); assertThat(date.getDay()).isEqualTo(1); assertThat(management.getStorageRule()).isNotNull(); assertThat(management.getStorageRule().isPreventInheritance()).isNull(); assertThat(management.getStorageRule().getRefNonRuleId()).hasSize(2); assertThat(management.getStorageRule().getRefNonRuleId().get(0).getValue()).isIn("R1", "R2"); assertThat(management.getStorageRule().getRefNonRuleId().get(1).getValue()).isIn("R1", "R2"); assertThat(management.getStorageRule().getRuleAndStartDate().get(0)).isInstanceOf(RuleIdType.class); ruleIdType = (RuleIdType) management.getStorageRule().getRuleAndStartDate().get(0); assertThat(ruleIdType.getValue()).isEqualTo("R3"); assertThat(management.getStorageRule().getRuleAndStartDate().get(1)).isInstanceOf(XMLGregorianCalendar.class); date = (XMLGregorianCalendar) management.getStorageRule().getRuleAndStartDate().get(1); assertThat(date.getYear()).isEqualTo(2000); assertThat(date.getMonth()).isEqualTo(1); assertThat(date.getDay()).isEqualTo(1); assertThat(management.getStorageRule().getFinalAction().value()).isEqualTo("Copy"); Assert .assertEquals(archiveUnitType.getContent().getOriginatingAgency().getIdentifier().getValue(), "Identifier"); Assert.assertEquals( archiveUnitType.getContent().getOriginatingAgency().getOrganizationDescriptiveMetadata().getAny().size(), 3); }
public ArchiveUnitType map(ArchiveUnitModel model) throws DatatypeConfigurationException { ArchiveUnitType archiveUnitType = new ArchiveUnitType(); archiveUnitType.setId(model.getId()); if (model.getArchiveUnitProfile() != null) { IdentifierType identifierType = new IdentifierType(); identifierType.setValue(model.getArchiveUnitProfile()); archiveUnitType.setArchiveUnitProfile(identifierType); } archiveUnitType.setContent(descriptiveMetadataMapper.map(model.getDescriptiveMetadataModel(), model.getHistory())); archiveUnitType.setManagement(managementMapper.map(model.getManagement())); return archiveUnitType; }
ArchiveUnitMapper { public ArchiveUnitType map(ArchiveUnitModel model) throws DatatypeConfigurationException { ArchiveUnitType archiveUnitType = new ArchiveUnitType(); archiveUnitType.setId(model.getId()); if (model.getArchiveUnitProfile() != null) { IdentifierType identifierType = new IdentifierType(); identifierType.setValue(model.getArchiveUnitProfile()); archiveUnitType.setArchiveUnitProfile(identifierType); } archiveUnitType.setContent(descriptiveMetadataMapper.map(model.getDescriptiveMetadataModel(), model.getHistory())); archiveUnitType.setManagement(managementMapper.map(model.getManagement())); return archiveUnitType; } }
ArchiveUnitMapper { public ArchiveUnitType map(ArchiveUnitModel model) throws DatatypeConfigurationException { ArchiveUnitType archiveUnitType = new ArchiveUnitType(); archiveUnitType.setId(model.getId()); if (model.getArchiveUnitProfile() != null) { IdentifierType identifierType = new IdentifierType(); identifierType.setValue(model.getArchiveUnitProfile()); archiveUnitType.setArchiveUnitProfile(identifierType); } archiveUnitType.setContent(descriptiveMetadataMapper.map(model.getDescriptiveMetadataModel(), model.getHistory())); archiveUnitType.setManagement(managementMapper.map(model.getManagement())); return archiveUnitType; } ArchiveUnitMapper(); }
ArchiveUnitMapper { public ArchiveUnitType map(ArchiveUnitModel model) throws DatatypeConfigurationException { ArchiveUnitType archiveUnitType = new ArchiveUnitType(); archiveUnitType.setId(model.getId()); if (model.getArchiveUnitProfile() != null) { IdentifierType identifierType = new IdentifierType(); identifierType.setValue(model.getArchiveUnitProfile()); archiveUnitType.setArchiveUnitProfile(identifierType); } archiveUnitType.setContent(descriptiveMetadataMapper.map(model.getDescriptiveMetadataModel(), model.getHistory())); archiveUnitType.setManagement(managementMapper.map(model.getManagement())); return archiveUnitType; } ArchiveUnitMapper(); ArchiveUnitType map(ArchiveUnitModel model); }
ArchiveUnitMapper { public ArchiveUnitType map(ArchiveUnitModel model) throws DatatypeConfigurationException { ArchiveUnitType archiveUnitType = new ArchiveUnitType(); archiveUnitType.setId(model.getId()); if (model.getArchiveUnitProfile() != null) { IdentifierType identifierType = new IdentifierType(); identifierType.setValue(model.getArchiveUnitProfile()); archiveUnitType.setArchiveUnitProfile(identifierType); } archiveUnitType.setContent(descriptiveMetadataMapper.map(model.getDescriptiveMetadataModel(), model.getHistory())); archiveUnitType.setManagement(managementMapper.map(model.getManagement())); return archiveUnitType; } ArchiveUnitMapper(); ArchiveUnitType map(ArchiveUnitModel model);  }