@Test
  public void testRetrieveDatasetUuidFromIdentifierNs() {
    _repo.deleteAll();

    Metadata metadata1 = newMetadata();
    metadata1 = _repoMetadata.save(metadata1);

    InspireAtomFeed feed1 = newInspireAtomFeed();
    feed1.setMetadataId(metadata1.getId());
    feed1 = _repo.save(feed1);

    String metadataUuid =
        _repo.retrieveDatasetUuidFromIdentifierNs(
            feed1.getAtomDatasetid(), feed1.getAtomDatasetns());
    assertEquals(metadata1.getUuid(), metadataUuid);

    // Test no existing values
    metadataUuid = _repo.retrieveDatasetUuidFromIdentifierNs("aaa", "aaaa");
    assertTrue(StringUtils.isEmpty(metadataUuid));
  }
  @Test
  public void testFindOne() {
    InspireAtomFeed feed1 = newInspireAtomFeed();
    feed1 = _repo.save(feed1);

    InspireAtomFeed feed2 = newInspireAtomFeed();
    feed2 = _repo.save(feed2);

    assertEquals(feed2, _repo.findOne(feed2.getId()));
    assertEquals(feed1, _repo.findOne(feed1.getId()));

    assertEquals(1, _repo.findOne(feed2.getId()).getEntryList().size());
    assertEquals(feed2.getEntryList().get(0), _repo.findOne(feed2.getId()).getEntryList().get(0));
  }
  @Test
  @Ignore("Constraint exception occurs in H2.  Has to do with entry list referencing atom feed.")
  public void testCleanAtomDocumentsByMetadataId() {
    _repo.deleteAll();

    InspireAtomFeed feed1 = newInspireAtomFeed();
    feed1.setMetadataId(1);
    feed1 = _repo.save(feed1);

    assertEquals(feed1.getMetadataId(), _repo.findOne(feed1.getId()).getMetadataId());

    InspireAtomFeed feed2 = newInspireAtomFeed();
    feed2.setMetadataId(2);
    feed2 = _repo.save(feed2);
    assertEquals(feed2.getMetadataId(), _repo.findOne(feed2.getId()).getMetadataId());

    assertEquals(2, _repo.findAll().size());

    _repo.deleteAll(InspireAtomFeedSpecs.hasMetadataId(1));

    assertEquals(1, _repo.findAll().size());
  }
  private InspireAtomFeed newInspireAtomFeed() {
    int val = _inc.incrementAndGet();
    InspireAtomFeed inspireAtomFeed = new InspireAtomFeed();
    inspireAtomFeed.setTitle("title" + val);
    inspireAtomFeed.setSubtitle("subtitle" + val);
    inspireAtomFeed.setAtomUrl("http://feed/data.xml");
    inspireAtomFeed.setLang("eng");
    inspireAtomFeed.setAuthorName("authorname");
    inspireAtomFeed.setAuthorEmail("authoremail");
    inspireAtomFeed.setAtomDatasetid("datasetid" + val);
    inspireAtomFeed.setAtomDatasetns("datasetns");
    inspireAtomFeed.setAtom("atomxml");
    inspireAtomFeed.setRights("rights");

    InspireAtomFeedEntry feedEntry1 = new InspireAtomFeedEntry();
    feedEntry1.setType("type1");
    feedEntry1.setLang("eng");
    feedEntry1.setCrs("EPSG:4326");
    feedEntry1.setUrl("http://entry1");

    inspireAtomFeed.addEntry(feedEntry1);

    return inspireAtomFeed;
  }