@Test
  public void testUpdatedDataset() throws Exception {
    Dataset dataset = new Dataset();
    dataset.setTitle("Foobar");
    Endpoint endpoint = new Endpoint();
    endpoint.setUrl(URI.create("http://localhost/nmr"));
    dataset.addEndpoint(endpoint);

    when(client.execute(argThat(HttpGetMatcher.matchUrl("http://localhost/nmr?op=capabilities"))))
        .thenReturn(prepareResponse(200, "tapir/capabilities1.xml"));
    when(client.execute(argThat(HttpGetMatcher.matchUrl("http://localhost/nmr"))))
        .thenReturn(prepareResponse(200, "tapir/metadata1.xml"));
    when(client.execute(
            argThat(
                HttpGetMatcher.matchUrl(
                    "http://localhost/nmr?op=s&t=http%3A%2F%2Frs.gbif.org%2Ftemplates%2Ftapir%2Fdwc%2F1.4%2Fsci_name_range.xml&count=true&start=0&limit=1&lower=AAA&upper=zzz"))))
        .thenReturn(prepareResponse(200, "tapir/search1.xml"));

    SyncResult syncResult =
        synchroniser.syncInstallation(installation, Lists.newArrayList(dataset));
    assertThat(syncResult.deletedDatasets).describedAs("Deleted datasets").isEmpty();
    assertThat(syncResult.existingDatasets).hasSize(1);
    assertThat(syncResult.addedDatasets).isEmpty();

    assertThat(syncResult.existingDatasets.get(dataset).getTitle())
        .isEqualTo("ENGLISHNatural History Museum Rotterdam");
  }
  @Before
  public void setup() {
    synchroniser = new TapirMetadataSynchroniser(client);

    installation = new Installation();
    installation.setType(InstallationType.TAPIR_INSTALLATION);
    Endpoint endpoint = new Endpoint();
    endpoint.setUrl(URI.create("http://localhost/nmr"));
    installation.addEndpoint(endpoint);
  }
Esempio n. 3
0
 /** Populates the data, metadata and other links from the unified endpoint list. */
 private void populateLinks(@NotNull List<Endpoint> endpoints) {
   Preconditions.checkNotNull(
       endpoints, "Enpoints cannot be null - expected empty list for no endpoints");
   dataLinks.clear(); // for safety
   metaLinks.clear();
   links.clear();
   for (Endpoint p : member.getEndpoints()) {
     if (DATA_CODES.contains(p.getType())) {
       dataLinks.add(p);
     } else if (METADATA_CODES.contains(p.getType())) {
       metaLinks.add(p);
     } else {
       links.add(p);
     }
   }
 }