Package buri.ddmsence.util

Examples of buri.ddmsence.util.DDMSVersion


  }

  @Test
  public void testNameAndNamespace() throws InvalidDDMSException {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);

      assertNameAndNamespace(getInstance(getValidElement(sVersion), SUCCESS), DEFAULT_DDMS_PREFIX,
        MetacardInfo.getName(version));
      getInstance(getWrongNameElementFixture(), WRONG_NAME_MESSAGE);
    }
View Full Code Here


  }

  @Test
  public void testConstructorsMinimal() {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);

      // Element-based, no optional fields
      Element element = Util.buildDDMSElement(MetacardInfo.getName(version), null);
      for (IDDMSComponent component : getChildComponents(true))
        element.appendChild(component.getXOMElementCopy());
View Full Code Here

  }

  @Test
  public void testValidationErrors() throws InvalidDDMSException {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);

      // Null component list
      try {
        new MetacardInfo(null, null);
      }
      catch (InvalidDDMSException e) {
        expectMessage(e, "At least one");
      }

      // Invalid object in component list
      try {
        List<IDDMSComponent> components = getChildComponents(true);
        components.add(new Rights(true, true, true));
        new MetacardInfo(components, null);
      }
      catch (InvalidDDMSException e) {
        expectMessage(e, "rights is not a valid");
      }

      // Missing identifier
      MetacardInfo.Builder builder = getBaseBuilder();
      builder.getIdentifiers().clear();
      getInstance(builder, "At least one");

      // Missing publisher
      builder = getBaseBuilder();
      builder.getPublishers().clear();
      if (version.isAtLeast("5.0")) {
        builder.getContributors().clear();
        builder.getCreators().clear();
        builder.getPointOfContacts().clear();
      }
      getInstance(builder, "At least one");
View Full Code Here

  }

  @Test
  public void testEquality() throws InvalidDDMSException {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);

      // Base equality
      MetacardInfo elementComponent = getInstance(getValidElement(sVersion), SUCCESS);
      MetacardInfo builderComponent = new MetacardInfo.Builder(elementComponent).commit();
      assertEquals(elementComponent, builderComponent);
      assertEquals(elementComponent.hashCode(), builderComponent.hashCode());

      // Different values in each field
      MetacardInfo.Builder builder = getBaseBuilder();
      builder.getIdentifiers().get(0).setQualifier(DIFFERENT_VALUE);
      assertFalse(elementComponent.equals(builder.commit()));

      builder = getBaseBuilder();
      builder.getDates().setApprovedOn("2013-01-01");
      assertFalse(elementComponent.equals(builder.commit()));

      builder = getBaseBuilder();
      builder.getCreators().clear();
      assertFalse(elementComponent.equals(builder.commit()));

      builder = getBaseBuilder();
      builder.getContributors().clear();
      assertFalse(elementComponent.equals(builder.commit()));

      builder = getBaseBuilder();
      builder.getPointOfContacts().clear();
      assertFalse(elementComponent.equals(builder.commit()));

      builder = getBaseBuilder();
      builder.getPublishers().get(0).getPerson().setNames(Util.getXsListAsList("Ellen"));
      assertFalse(elementComponent.equals(builder.commit()));

      builder = getBaseBuilder();
      builder.setDescription(null);
      assertFalse(elementComponent.equals(builder.commit()));

      builder = getBaseBuilder();
      builder.getProcessingInfos().clear();
      assertFalse(elementComponent.equals(builder.commit()));

      builder = getBaseBuilder();
      builder.setRevisionRecall(null);
      assertFalse(elementComponent.equals(builder.commit()));

      builder = getBaseBuilder();
      builder.setRecordsManagementInfo(null);
      assertFalse(elementComponent.equals(builder.commit()));

      if (!version.isAtLeast("5.0")) {
        builder = getBaseBuilder();
        builder.setNoticeList(null);
        assertFalse(elementComponent.equals(builder.commit()));
      }
    }
View Full Code Here

   * Returns a builder, pre-populated with base data from the XML sample.
   *
   * This builder can then be modified to test various conditions.
   */
  private Security.Builder getBaseBuilder() {
    DDMSVersion version = DDMSVersion.getCurrentVersion();
    Security component = getInstance(getValidElement(version.getVersion()), SUCCESS);
    return (new Security.Builder(component));
  }
View Full Code Here

  /**
   * Returns the expected output for the test instance of this component
   */
  private String getExpectedHTMLTextOutput(OutputFormat format) throws InvalidDDMSException {
    Util.requireHTMLText(format);
    DDMSVersion version = DDMSVersion.getCurrentVersion();
    String prefix = "security.";
    StringBuffer text = new StringBuffer();
    if (version.isAtLeast("3.0"))
      text.append(buildHTMLTextOutput(format, prefix + "excludeFromRollup", "true"));
    if (version.isAtLeast("4.0.1")) {
      text.append(buildHTMLTextOutput(format, prefix + "noticeList.notice.noticeText", "noticeText"));
      text.append(buildHTMLTextOutput(format, prefix + "noticeList.notice.noticeText.pocType", "DoD-Dist-B"));
      text.append(buildHTMLTextOutput(format, prefix + "noticeList.notice.noticeText.classification", "U"));
      text.append(buildHTMLTextOutput(format, prefix + "noticeList.notice.noticeText.ownerProducer", "USA"));
      text.append(buildHTMLTextOutput(format, prefix + "noticeList.notice.classification", "U"));
      text.append(buildHTMLTextOutput(format, prefix + "noticeList.notice.ownerProducer", "USA"));
      text.append(buildHTMLTextOutput(format, prefix + "noticeList.notice.noticeType", "DoD-Dist-B"));
      text.append(buildHTMLTextOutput(format, prefix + "noticeList.notice.noticeReason", "noticeReason"));
      text.append(buildHTMLTextOutput(format, prefix + "noticeList.notice.noticeDate", "2011-09-15"));
      text.append(buildHTMLTextOutput(format, prefix + "noticeList.notice.unregisteredNoticeType",
        "unregisteredNoticeType"));
      if (version.isAtLeast("4.1")) {
        text.append(buildHTMLTextOutput(format, prefix + "noticeList.notice.externalNotice", "false"));
      }
      text.append(buildHTMLTextOutput(format, prefix + "noticeList.classification", "U"));
      text.append(buildHTMLTextOutput(format, prefix + "noticeList.ownerProducer", "USA"));
      if (!version.isAtLeast("5.0"))
        text.append(AccessTest.getFixture().getHTMLTextOutput(format, "security.", ""));
    }
    text.append(SecurityAttributesTest.getFixture().getHTMLTextOutput(format, prefix));
    return (text.toString());
  }
View Full Code Here

  /**
   * Returns the expected JSON output for this unit test
   */
  private String getExpectedJSONOutput() {
    DDMSVersion version = DDMSVersion.getCurrentVersion();
    StringBuffer json = new StringBuffer();
    json.append("{");
    if (version.isAtLeast("3.0")) {
      json.append("\"excludeFromRollup\":true,");
    }
    if (version.isAtLeast("4.1")) {
      json.append("\"noticeList\":").append(NoticeListTest.getFixture().toJSON());
      json.append(",\"access\":").append(AccessTest.getFixture().toJSON()).append(",");
    }
    json.append(SecurityAttributesTest.getBasicJSON()).append("}");
    return (json.toString());
View Full Code Here

 
  /**
   * Returns the expected XML output for this unit test
   */
  private String getExpectedXMLOutput() {
    DDMSVersion version = DDMSVersion.getCurrentVersion();
    StringBuffer xml = new StringBuffer();
    xml.append("<ddms:security ").append(getXmlnsDDMS()).append(" ").append(getXmlnsISM()).append(" ");
    if (version.isAtLeast("3.0"))
      xml.append("ism:excludeFromRollup=\"true\" ");
    xml.append("ism:classification=\"U\" ism:ownerProducer=\"USA\"");
    if (!version.isAtLeast("4.0.1"))
      xml.append(" />");
    else {
      xml.append(">\n");
      xml.append("\t<ddms:noticeList ism:classification=\"U\" ism:ownerProducer=\"USA\">\n");
      xml.append("\t\t<ism:Notice ism:noticeType=\"DoD-Dist-B\" ism:noticeReason=\"noticeReason\" ism:noticeDate=\"2011-09-15\" ism:unregisteredNoticeType=\"unregisteredNoticeType\"");
      if (version.isAtLeast("4.1")) {
        xml.append(" ism:externalNotice=\"false\"");
      }
      xml.append(" ism:classification=\"U\" ism:ownerProducer=\"USA\">\n");
      xml.append("\t\t\t<ism:NoticeText ism:classification=\"U\" ism:ownerProducer=\"USA\" ism:pocType=\"DoD-Dist-B\">noticeText</ism:NoticeText>\n");
      xml.append("\t\t</ism:Notice>\n");
      xml.append("\t</ddms:noticeList>\n");
      if (!version.isAtLeast("5.0")) {
        xml.append("\t<ntk:Access xmlns:ntk=\"urn:us:gov:ic:ntk\" ism:classification=\"U\" ism:ownerProducer=\"USA\">\n");
        xml.append("\t\t<ntk:AccessIndividualList>\n");
        xml.append("\t\t\t<ntk:AccessIndividual ism:classification=\"U\" ism:ownerProducer=\"USA\">\n");
        xml.append("\t\t\t\t<ntk:AccessSystemName ism:classification=\"U\" ism:ownerProducer=\"USA\">DIAS</ntk:AccessSystemName>\n");
        xml.append("\t\t\t\t<ntk:AccessIndividualValue ism:classification=\"U\" ism:ownerProducer=\"USA\">");
View Full Code Here

  }

  @Test
  public void testNameAndNamespace() {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);

      assertNameAndNamespace(getInstance(getValidElement(sVersion), SUCCESS), DEFAULT_DDMS_PREFIX,
        Security.getName(version));
      getInstance(getWrongNameElementFixture(), WRONG_NAME_MESSAGE);
    }
View Full Code Here

  }
 
  @Test
  public void testConstructorsMinimal() throws InvalidDDMSException {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);

      // Element-based, No optional fields
      if (version.isAtLeast("4.0.1")) {
        Element element = Util.buildDDMSElement(Security.getName(version), null);
        Util.addAttribute(element, PropertyReader.getPrefix("ism"), "excludeFromRollup",
          version.getIsmNamespace(), "true");
        SecurityAttributesTest.getFixture().addTo(element);
        getInstance(element, SUCCESS);
      }
     
      // Data-based, No optional fields
View Full Code Here

TOP

Related Classes of buri.ddmsence.util.DDMSVersion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.