@Test
  public void testNoIdNoSourceId()
      throws CatalogTransformerException, IOException, XpathException, SAXException {

    // given
    XmlResponseQueueTransformer transformer = new XmlResponseQueueTransformer();

    SourceResponse response = givenSourceResponse(null, null);

    // when
    BinaryContent binaryContent = transformer.transform(response, null);

    // then
    assertThat(binaryContent.getMimeType(), is(XmlResponseQueueTransformer.MIME_TYPE));

    byte[] bytes = binaryContent.getByteArray();

    String output = new String(bytes);

    print(output, verboseDebug);

    assertXpathNotExists("/mc:metacards/mc:metacard/mc:source", output);

    assertXpathNotExists("/mc:metacards/mc:metacard/@gml:id", output);

    verifyDefaults("1", output);
  }
  @Test
  public void testGMLAttributeMapping() throws Exception {
    WFSInfo wfs = getWFS();
    GMLInfo gml = wfs.getGML().get(WFSInfo.Version.V_11);
    gml.setOverrideGMLAttributes(false);
    getGeoServer().save(wfs);

    Document dom =
        getAsDOM(
            "ows?service=WFS&version=1.1.0&request=GetFeature"
                + "&typename="
                + getLayerId(SystemTestData.PRIMITIVEGEOFEATURE));
    XMLAssert.assertXpathExists("//gml:name", dom);
    XMLAssert.assertXpathExists("//gml:description", dom);
    XMLAssert.assertXpathNotExists("//sf:name", dom);
    XMLAssert.assertXpathNotExists("//sf:description", dom);

    gml.setOverrideGMLAttributes(true);
    getGeoServer().save(wfs);

    dom =
        getAsDOM(
            "ows?service=WFS&version=1.1.0&request=GetFeature"
                + "&typename="
                + getLayerId(SystemTestData.PRIMITIVEGEOFEATURE));
    XMLAssert.assertXpathNotExists("//gml:name", dom);
    XMLAssert.assertXpathNotExists("//gml:description", dom);
    XMLAssert.assertXpathExists("//sf:name", dom);
    XMLAssert.assertXpathExists("//sf:description", dom);

    gml.setOverrideGMLAttributes(false);
    getGeoServer().save(wfs);
  }
  @Test
  public void testDescribeDefaultStoredQuery() throws Exception {
    Document dom =
        getAsDOM(
            "wfs?request=DescribeStoredQueries&storedQueryId=" + StoredQuery.DEFAULT.getName());
    assertEquals("wfs:DescribeStoredQueriesResponse", dom.getDocumentElement().getNodeName());

    XMLAssert.assertXpathExists(
        "//wfs:StoredQueryDescription[@id = '" + StoredQuery.DEFAULT.getName() + "']", dom);
    XMLAssert.assertXpathExists("//wfs:Parameter[@name = 'ID']", dom);
    XMLAssert.assertXpathExists("//wfs:QueryExpressionText[@isPrivate = 'true']", dom);
    XMLAssert.assertXpathNotExists("//wfs:QueryExpressionText/*", dom);
  }
  @Test
  public void testEncodeSrsDimension() throws Exception {
    Document dom =
        getAsDOM(
            "wfs?request=GetFeature&version=1.1.0&service=wfs&typename="
                + getLayerId(SystemTestData.PRIMITIVEGEOFEATURE));
    XMLAssert.assertXpathExists("//gml:Point[@srsDimension = '2']", dom);

    WFSInfo wfs = getWFS();
    wfs.setCiteCompliant(true);
    getGeoServer().save(wfs);

    dom =
        getAsDOM(
            "wfs?request=GetFeature&version=1.1.0&service=wfs&typename="
                + getLayerId(SystemTestData.PRIMITIVEGEOFEATURE));
    XMLAssert.assertXpathNotExists("//gml:Point[@srsDimension = '2']", dom);
  }
  /**
   * generate the relative objects and make sure the short serialization can work
   *
   * @throws Exception
   */
  @Test
  @SkipBaseSetup
  public void shouldPersonShortSerialization() throws Exception {
    // prepare the necessary data
    initializeInMemoryDatabase();
    executeDataSet("org/openmrs/module/xstream/include/PersonShortSerializationTest.xml");
    authenticate();

    PersonAddress pa =
        Context.getPersonService().getPersonAddressByUuid("3350d0b5-821c-4e5e-ad1d-a9bce331e118");
    String xmlOutput =
        Context.getSerializationService().serialize(pa, XStreamShortSerializer.class);
    // should only serialize "uuid"
    XMLAssert.assertXpathEvaluatesTo(
        "da7f524f-27ce-4bb2-86d6-6d1d05312bd5", "/personAddress/person/@uuid", xmlOutput);
    // with short serialization, the "person" element shouldn't contain any child element in the
    // serialized xml
    XMLAssert.assertXpathNotExists("/personAddress/person/*", xmlOutput);
  }
  @Test
  public void testNonAdvertisedLayer() throws Exception {
    String layerId = getLayerId(MockData.TASMANIA_DEM);
    LayerInfo layer = getCatalog().getLayerByName(layerId);
    try {
      // now you see me
      Document dom = getAsDOM("wcs?request=GetCapabilities");
      assertXpathExists("//wcs:CoverageSummary[ows:Title='DEM']", dom);

      // now you don't!
      layer.setAdvertised(false);
      getCatalog().save(layer);
      dom = getAsDOM("wcs?request=GetCapabilities");
      assertXpathNotExists("//wcs:CoverageSummary[ows:Title='DEM']", dom);
    } finally {
      layer.setAdvertised(true);
      getCatalog().save(layer);
    }
  }
 @Test
 public void content_empty() throws Exception {
   assertXpathNotExists("/:entry/:content/*", newXML(null));
 }