예제 #1
0
  @Test
  public void shouldGetVdbMask() throws Exception {
    loadVdbs();

    // get
    Properties settings =
        _uriBuilder.createSettings(
            SettingNames.VDB_NAME, TestUtilities.ALL_ELEMENTS_EXAMPLE_VDB_NAME);
    _uriBuilder.addSetting(settings, SettingNames.DATA_ROLE_ID, "roleOne");
    _uriBuilder.addSetting(settings, SettingNames.PERMISSION_ID, "myTable.T2.col1");
    _uriBuilder.addSetting(settings, SettingNames.PERMISSION_CHILD_TYPE, LinkType.MASKS.uriName());
    _uriBuilder.addSetting(settings, SettingNames.PERMISSION_CHILD_ID, "col2");
    URI uri = _uriBuilder.buildVdbPermissionChildUri(LinkType.SELF, settings);
    this.response = request(uri).get();
    final String entity = this.response.readEntity(String.class);
    assertThat(entity, is(notNullValue()));

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

    RestVdbMask mask = KomodoJsonMarshaller.unmarshall(entity, RestVdbMask.class);
    assertNotNull(mask);

    assertEquals("col2", mask.getName());
    assertEquals("1", mask.getOrder());

    Collection<RestLink> links = mask.getLinks();
    assertEquals(3, links.size());
  }
예제 #2
0
  @Test
  public void shouldGetVdbImport() throws Exception {
    loadVdbs();

    // get
    Properties settings =
        _uriBuilder.createSettings(
            SettingNames.VDB_NAME, TestUtilities.ALL_ELEMENTS_EXAMPLE_VDB_NAME);
    _uriBuilder.addSetting(settings, SettingNames.IMPORT_NAME, "x");
    URI uri = _uriBuilder.buildVdbImportUri(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);

    RestVdbImport vdbImport = KomodoJsonMarshaller.unmarshall(entity, RestVdbImport.class);
    assertNotNull(vdbImport);

    assertEquals(KomodoType.VDB_IMPORT, vdbImport.getkType());
    assertEquals("x", vdbImport.getName());
    assertEquals(2, vdbImport.getVersion());
    assertEquals(false, vdbImport.isImportDataPolicies());

    Collection<RestLink> links = vdbImport.getLinks();
    assertEquals(3, links.size());
  }
예제 #3
0
  @Test
  public void shouldGetVdbPermission() throws Exception {
    loadVdbs();

    // get
    Properties settings =
        _uriBuilder.createSettings(
            SettingNames.VDB_NAME, TestUtilities.ALL_ELEMENTS_EXAMPLE_VDB_NAME);
    _uriBuilder.addSetting(settings, SettingNames.DATA_ROLE_ID, "roleOne");
    _uriBuilder.addSetting(settings, SettingNames.PERMISSION_ID, "myTable.T1");
    URI uri = _uriBuilder.buildVdbPermissionUri(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);

    RestVdbPermission permission = KomodoJsonMarshaller.unmarshall(entity, RestVdbPermission.class);
    assertNotNull(permission);

    assertEquals(KomodoType.VDB_PERMISSION, permission.getkType());
    assertEquals("myTable.T1", permission.getId());
    assertFalse(permission.hasChildren());
    assertFalse(permission.isAllowAlter());
    assertFalse(permission.isAllowCreate());
    assertFalse(permission.isAllowDelete());
    assertFalse(permission.isAllowExecute());
    assertFalse(permission.isAllowLanguage());
    assertTrue(permission.isAllowRead());
    assertFalse(permission.isAllowUpdate());

    Collection<RestLink> links = permission.getLinks();
    assertEquals(5, links.size());
  }
예제 #4
0
  @Test
  public void shouldGetVdbTranslator() throws Exception {
    loadVdbs();

    // get
    Properties settings =
        _uriBuilder.createSettings(SettingNames.VDB_NAME, TestUtilities.TWEET_EXAMPLE_VDB_NAME);
    _uriBuilder.addSetting(settings, SettingNames.TRANSLATOR_NAME, "rest");
    URI uri = _uriBuilder.buildVdbTranslatorUri(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);

    RestVdbTranslator translator = KomodoJsonMarshaller.unmarshall(entity, RestVdbTranslator.class);
    assertNotNull(translator);

    assertEquals(KomodoType.VDB_TRANSLATOR, translator.getkType());
    assertEquals("ws", translator.getType());
    assertEquals("Rest Web Service translator", translator.getDescription());

    Collection<RestLink> links = translator.getLinks();
    assertEquals(3, links.size());
  }
예제 #5
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());
  }
예제 #6
0
  @Test
  public void shouldGetVdbModel() throws Exception {
    loadVdbs();

    // get
    Properties settings =
        _uriBuilder.createSettings(SettingNames.VDB_NAME, TestUtilities.PORTFOLIO_VDB_NAME);
    _uriBuilder.addSetting(settings, SettingNames.MODEL_NAME, "PersonalValuations");
    URI uri = _uriBuilder.buildVdbModelUri(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);

    RestVdbModel model = KomodoJsonMarshaller.unmarshall(entity, RestVdbModel.class);
    assertNotNull(model);

    assertEquals("PersonalValuations", model.getId());
    assertEquals(KomodoType.MODEL, model.getkType());
    assertEquals(true, model.isVisible());
    assertEquals(Type.PHYSICAL, model.getModelType());

    Collection<RestLink> links = model.getLinks();
    assertEquals(4, links.size());
  }
예제 #7
0
  @Test
  public void shouldGetVdb() throws Exception {
    loadVdbs();

    // get
    Properties settings =
        _uriBuilder.createSettings(SettingNames.VDB_NAME, TestUtilities.PORTFOLIO_VDB_NAME);
    this.response = request(_uriBuilder.buildVdbUri(LinkType.SELF, settings)).get();
    final String entity = this.response.readEntity(String.class);
    assertThat(entity, is(notNullValue()));

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

    RestVdb vdb = KomodoJsonMarshaller.unmarshall(entity, RestVdb.class);
    assertNotNull(vdb);

    assertPortfolio(vdb);
  }
예제 #8
0
  @Test
  public void shouldGetVdbDataRole() throws Exception {
    loadVdbs();

    // get
    Properties settings =
        _uriBuilder.createSettings(
            SettingNames.VDB_NAME, TestUtilities.ALL_ELEMENTS_EXAMPLE_VDB_NAME);
    _uriBuilder.addSetting(settings, SettingNames.DATA_ROLE_ID, "roleOne");
    URI uri = _uriBuilder.buildVdbDataRoleUri(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);

    RestVdbDataRole dataRole = KomodoJsonMarshaller.unmarshall(entity, RestVdbDataRole.class);
    assertNotNull(dataRole);

    assertEquals(KomodoType.VDB_DATA_ROLE, dataRole.getkType());
    assertEquals("roleOne", dataRole.getName());
    assertEquals("roleOne described", dataRole.getDescription());
    assertEquals(true, dataRole.isAllowCreateTempTables());
    assertEquals(false, dataRole.isAnyAuthenticated());
    assertEquals(true, dataRole.isGrantAll());
    assertEquals(2, dataRole.getMappedRoles().length);
    assertTrue(
        dataRole.getMappedRoles()[0].equals("ROLE1")
            || dataRole.getMappedRoles()[0].equals("ROLE2"));
    assertTrue(
        dataRole.getMappedRoles()[1].equals("ROLE1")
            || dataRole.getMappedRoles()[1].equals("ROLE2"));

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