示例#1
0
  @Test
  public void shouldGetVdbModelSource() throws Exception {
    loadVdbs();

    // get
    Properties settings =
        _uriBuilder.createSettings(SettingNames.VDB_NAME, TestUtilities.PORTFOLIO_VDB_NAME);
    _uriBuilder.addSetting(settings, SettingNames.MODEL_NAME, "PersonalValuations");
    _uriBuilder.addSetting(settings, SettingNames.SOURCE_NAME, "excelconnector");
    URI uri = _uriBuilder.buildVdbModelSourceUri(LinkType.SELF, settings);
    this.response = request(uri).get();
    final String entity = this.response.readEntity(String.class);
    assertThat(entity, is(notNullValue()));

    // System.out.println("Response from uri " + uri + ":\n" + entity);

    RestVdbModelSource source = KomodoJsonMarshaller.unmarshall(entity, RestVdbModelSource.class);
    assertNotNull(source);

    assertEquals("excelconnector", source.getId());
    assertEquals(KomodoType.VDB_MODEL_SOURCE, source.getkType());
    assertEquals("java:/excel-file", source.getJndiName());
    assertEquals("excel", source.getTranslator());

    Collection<RestLink> links = source.getLinks();
    assertEquals(3, links.size());
  }
示例#2
0
  @Test
  public void shouldGetVdbModelSourcesIncludeReferenceForTranslator() throws Exception {
    loadVdbs();

    // get
    Properties settings =
        _uriBuilder.createSettings(SettingNames.VDB_NAME, TestUtilities.TWEET_EXAMPLE_VDB_NAME);
    _uriBuilder.addSetting(settings, SettingNames.MODEL_NAME, "twitter");
    URI uri = _uriBuilder.buildVdbModelUri(LinkType.SOURCES, settings);
    this.response = request(uri).get();
    final String entities = this.response.readEntity(String.class);
    assertThat(entities, is(notNullValue()));

    // System.out.println("Response from uri " + uri + ":\n" + entities);

    RestVdbModelSource[] sources =
        KomodoJsonMarshaller.unmarshallArray(entities, RestVdbModelSource[].class);
    assertEquals(1, sources.length);

    RestVdbModelSource source = sources[0];

    assertEquals("twitter", source.getId());
    assertEquals(KomodoType.VDB_MODEL_SOURCE, source.getkType());
    assertEquals("java:/twitterDS", source.getJndiName());
    assertEquals("rest", source.getTranslator());

    Collection<RestLink> links = source.getLinks();
    assertEquals(4, links.size());

    RestLink refLink = null;
    for (RestLink link : links) {
      if (LinkType.REFERENCE.equals(link.getRel())) refLink = link;
    }
    assertNotNull(refLink);

    URI href = refLink.getHref();
    assertTrue(href.toString().endsWith("/v1/workspace/vdbs/twitter/VdbTranslators/rest"));
  }