Package buri.ddmsence.util

Examples of buri.ddmsence.util.DDMSVersion


  /**
   * Returns the expected JSON output for this unit test
   */
  private String getExpectedJSONOutput(boolean hasFacility) {
    DDMSVersion version = DDMSVersion.getCurrentVersion();
    StringBuffer json = new StringBuffer();
    if (!hasFacility) {
      json.append("{\"name\":[\"The White House\"],\"region\":[\"Mid-Atlantic States\"],");
      json.append("\"countryCode\":").append(CountryCodeTest.getFixture().toJSON());
      if (version.isAtLeast("4.0.1")) {
        json.append(",\"subDivisionCode\":").append(SubDivisionCodeTest.getFixture().toJSON());
      }
    }
    else {
      json.append("{\"facilityIdentifier\":").append(FacilityIdentifierTest.getFixture().toJSON());
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:geographicIdentifier ").append(getXmlnsDDMS()).append(">\n\t");
    xml.append("<ddms:name>The White House</ddms:name>\n\t");
    xml.append("<ddms:region>Mid-Atlantic States</ddms:region>\n\t");
    if (version.isAtLeast("5.0")) {
      xml.append("<ddms:countryCode ddms:").append(CountryCodeTest.getTestQualifierName());
      xml.append("=\"http://api.nsgreg.nga.mil/geo-political/GENC/2/ed1\" ");
      xml.append("ddms:").append(CountryCodeTest.getTestValueName()).append("=\"US\" />\n");
    }
    else {
      xml.append("<ddms:countryCode ddms:").append(CountryCodeTest.getTestQualifierName());
      xml.append("=\"ISO-3166\" ddms:").append(CountryCodeTest.getTestValueName()).append("=\"USA\" />\n");
    }
    if (version.isAtLeast("4.0.1")) {
      xml.append("\t<ddms:subDivisionCode ddms:").append(CountryCodeTest.getTestQualifierName());
      xml.append("=\"ISO-3166\" ddms:").append(CountryCodeTest.getTestValueName()).append("=\"USA\" />\n");
    }
    xml.append("</ddms:geographicIdentifier>");
    return (xml.toString());
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,
        GeographicIdentifier.getName(version));
      getInstance(getWrongNameElementFixture(), WRONG_NAME_MESSAGE);
    }
View Full Code Here

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

      // No optional fields
      Element element = Util.buildDDMSElement(geoIdName, null);
      element.appendChild(Util.buildDDMSElement("name", TEST_NAMES.get(0)));
      GeographicIdentifier elementComponent = getInstance(element, SUCCESS);

      getInstance(new GeographicIdentifier.Builder(elementComponent), SUCCESS);
     
      element = Util.buildDDMSElement(geoIdName, null);
      element.appendChild(Util.buildDDMSElement("region", TEST_REGIONS.get(0)));
      elementComponent = getInstance(element, SUCCESS);

      getInstance(new GeographicIdentifier.Builder(elementComponent), SUCCESS);
     
      element = Util.buildDDMSElement(geoIdName, null);
      element.appendChild(CountryCodeTest.getFixture().getXOMElementCopy());
      elementComponent = getInstance(element, SUCCESS);

      getInstance(new GeographicIdentifier.Builder(elementComponent), SUCCESS);
     
      if (version.isAtLeast("4.0.1")) {
        element = Util.buildDDMSElement(geoIdName, null);
        element.appendChild(SubDivisionCodeTest.getFixture().getXOMElementCopy());
        elementComponent = getInstance(element, SUCCESS);
       
        getInstance(new GeographicIdentifier.Builder(elementComponent), SUCCESS);
View Full Code Here

  }

  @Test
  public void testValidationErrors() throws InvalidDDMSException {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);
      String geoIdName = GeographicIdentifier.getName(version);
     
      // Element-based, At least 1 name, region, countryCode, or facilityIdentifier must exist.
      Element element = Util.buildDDMSElement(geoIdName, null);
      getInstance(element, "At least 1 of ");
View Full Code Here

  }
 
  @Test
  public void testValidationWarnings() {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);
      GeographicIdentifier component = getInstance(getValidElement(sVersion), SUCCESS);

      if (!version.isAtLeast("5.0")) {
        // No warnings
        assertEquals(0, component.getValidationWarnings().size());
      }
      else {
        // No NGA search
View Full Code Here

  }

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

      // Base equality, non-facility
      GeographicIdentifier elementComponent = getInstance(getValidElement(sVersion), SUCCESS);
      GeographicIdentifier builderComponent = new GeographicIdentifier.Builder(elementComponent).commit();
      assertEquals(elementComponent, builderComponent);
      assertEquals(elementComponent.hashCode(), builderComponent.hashCode());
     
      // Wrong class
      Rights wrongComponent = new Rights(true, true, true);
      assertFalse(elementComponent.equals(wrongComponent));
     
      // Different values in each field 
      GeographicIdentifier.Builder builder = getBaseBuilder();
      builder.getNames().clear();
      assertFalse(elementComponent.equals(builder.commit()));

      builder = getBaseBuilder();
      builder.getRegions().clear();
      assertFalse(elementComponent.equals(builder.commit()));
     
      builder = getBaseBuilder();
      builder.setCountryCode(null);
      assertFalse(elementComponent.equals(builder.commit()));
     
      if (version.isAtLeast("4.0.1")) {
        builder = getBaseBuilder();
        builder.setSubDivisionCode(null);
        assertFalse(elementComponent.equals(builder.commit()));
      }
     
View Full Code Here

  /**
   * Returns a fixture object for testing.
   */
  public static Element getFixtureElement() {
    try {
      DDMSVersion version = DDMSVersion.getCurrentVersion();
      Element element = Util.buildDDMSElement(Details.getName(version), TEST_VALUE);
      element.addNamespaceDeclaration(PropertyReader.getPrefix("ddms"), version.getNamespace());
      element.addNamespaceDeclaration(PropertyReader.getPrefix("ism"), version.getIsmNamespace());
      SecurityAttributesTest.getFixture().addTo(element);
      return (element);
    }
    catch (InvalidDDMSException e) {
      fail("Could not create fixture: " + e.getMessage());
View Full Code Here

  }

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

      assertNameAndNamespace(getInstance(getFixtureElement(), SUCCESS), DEFAULT_DDMS_PREFIX,
        Details.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
      Element element = Util.buildDDMSElement(Details.getName(version), null);
      SecurityAttributesTest.getFixture().addTo(element);
      getInstance(element, SUCCESS);
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.