Package org.teiid.adminapi.impl

Examples of org.teiid.adminapi.impl.VDBMetaData


 
 
  @Test
  public void testActiveVDBNameWithVersion() throws Exception {
    VDBRepository repo = Mockito.mock(VDBRepository.class);
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("name");
    vdb.setVersion(1);
    vdb.setStatus(Status.ACTIVE);
   
   
    Mockito.stub(repo.getVDB("name", 1)).toReturn(vdb);
   
    SessionServiceImpl ssi = new SessionServiceImpl();
View Full Code Here


  }
 
  @Test
  public void testActiveVDBNameWithVersionNonInteger() throws Exception {
    VDBRepository repo = Mockito.mock(VDBRepository.class);
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("name");
    vdb.setVersion(1);
    vdb.setStatus(Status.ACTIVE);
   
   
    Mockito.stub(repo.getVDB("name", 1)).toReturn(vdb);
   
    SessionServiceImpl ssi = new SessionServiceImpl();
View Full Code Here

  }
 
  @Test
  public void testActiveVDBNameWithVersionAndVersion() throws Exception {
    VDBRepository repo = Mockito.mock(VDBRepository.class);
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("name");
    vdb.setVersion(1);
    vdb.setStatus(Status.ACTIVE);
   
   
    Mockito.stub(repo.getVDB("name", 1)).toReturn(vdb);
   
    SessionServiceImpl ssi = new SessionServiceImpl();
View Full Code Here

        helpTest(exampleAuthSvc1(), "alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {"SmallA_2589"}, FakeMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
        helpTest(examplePolicyBQT(), "alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {}, FakeMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
    }
   
  private void helpTestLookupVisibility(boolean visible) throws QueryParserException, QueryValidatorException, TeiidComponentException {
    VDBMetaData vdb = FakeMetadataFactory.example1VDB();
    vdb.getModel("pm1").setVisible(visible); //$NON-NLS-1$
    AuthorizationValidationVisitor mvvv = new AuthorizationValidationVisitor(new HashMap<String, DataPolicy>(), "test"); //$NON-NLS-1$
    String sql = "select lookup('pm1.g1', 'e1', 'e2', 1)"; //$NON-NLS-1$
    Command command = QueryParser.getQueryParser().parseCommand(sql);
    Request.validateWithVisitor(mvvv, FakeMetadataFactory.example1Cached(), command);
  }
View Full Code Here

@SuppressWarnings("nls")
public class TestCompositeVDB {
 
  public static TransformationMetadata createTransformationMetadata(MetadataStore metadataStore, String vdbName) throws Exception {
      VDBMetaData vdbMetaData = new VDBMetaData();
      vdbMetaData.setName(vdbName); //$NON-NLS-1$
      vdbMetaData.setVersion(1);
      for (Schema schema : metadataStore.getSchemas().values()) {
      vdbMetaData.addModel(FakeMetadataFactory.createModel(schema.getName(), schema.isPhysical()));
    }
      MetadataStoreGroup metaGroup = new MetadataStoreGroup();
      metaGroup.addStore(metadataStore);
     
      ConnectorManagerRepository cmr = new ConnectorManagerRepository();
      cmr.addConnectorManager("source", getConnectorManager("bqt1", "FakeTranslator", "FakeConnection", getFuncsOne()));
      cmr.addConnectorManager("source2", getConnectorManager("bqt2", "FakeTranslator2", "FakeConnection2", getFuncsTwo()));
     
      CompositeVDB cvdb = new CompositeVDB(vdbMetaData, metaGroup, null, null, FakeMetadataFactory.SFM.getSystemFunctions(),cmr);
      VDBMetaData vdb = cvdb.getVDB();
      return vdb.getAttachment(TransformationMetadata.class);
  }
View Full Code Here

        caps.setFunctionSupport("fakeFunction", true); //$NON-NLS-1$
      
        ArrayList<String> bindings = new ArrayList<String>();
        bindings.add(modelName);
       
        VDBMetaData vdb = Mockito.mock(VDBMetaData.class);
        ModelMetaData model = Mockito.mock(ModelMetaData.class);
        Mockito.stub(vdb.getModel(modelName)).toReturn(model);
        Mockito.stub(model.getSourceNames()).toReturn(bindings);
       
        BasicSourceCapabilities basicSourceCapabilities = new BasicSourceCapabilities();
        basicSourceCapabilities.setFunctionSupport(functionName, true);
View Full Code Here

    }
  }
 
  @Test public void testProcVisibility() throws Exception {
    TransformationMetadata tm = exampleTransformationMetadata();
    VDBMetaData vdb = tm.getVdbMetaData();
    vdb.getModel("x").setVisible(false);
    StoredProcedureInfo spi = tm.getStoredProcedureInfoForProcedure("y"); //$NON-NLS-1$
    assertEquals("x1.y", spi.getProcedureCallableName());
    spi = tm.getStoredProcedureInfoForProcedure("x.y"); //$NON-NLS-1$
    assertEquals("x.y", spi.getProcedureCallableName());
  }
View Full Code Here

    HashMap<String, Resource> resources = new HashMap<String, Resource>();
    resources.put("/x.xsd", new Resource(Mockito.mock(VirtualFile.class), true));
   
    CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()));
   
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("vdb");
    vdb.setVersion(1);
   
    vdb.addModel(buildModel("x"));
    vdb.addModel(buildModel("x1"));
    vdb.addModel(buildModel("y"));
   
    return new TransformationMetadata(vdb, cms, resources, FakeMetadataFactory.SFM.getSystemFunctions(), null);
  }
View Full Code Here

    mf.addTable("y"); //$NON-NLS-1$
    MetadataFactory mf1 = new MetadataFactory("x1", datatypes, new Properties()); //$NON-NLS-1$
    mf1.addTable("y"); //$NON-NLS-1$
    CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()));
   
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("foo");
    vdb.setVersion(1);
   
    ModelMetaData model = new ModelMetaData();
    model.setName("x1");
    vdb.addModel(model);
   
    ModelMetaData model2 = new ModelMetaData();
    model2.setName("x");
    model2.setVisible(true);
    vdb.addModel(model2);   

    TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, FakeMetadataFactory.SFM.getSystemFunctions(), null);
    Collection result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
    assertEquals(2, result.size());
View Full Code Here

public class TestAdminObjectBuilder {

  @Test
  public void testVDB() {
   
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("myVDB");
    vdb.setDescription("vdb description");
    vdb.setVersion(1);
    vdb.addProperty("vdb-property", "vdb-value")
   
    ModelMetaData modelOne = new ModelMetaData();
    modelOne.setName("model-one");
    modelOne.addSourceMapping("s1", "translator", "java:mybinding")
    modelOne.setModelType(Model.Type.PHYSICAL);
    modelOne.addProperty("model-prop", "model-value")
    modelOne.addProperty("model-prop", "model-value-override")
    modelOne.setVisible(false);
    modelOne.addError("ERROR", "There is an error in VDB")
    modelOne.setDescription("model description");
   
    vdb.addModel(modelOne);
   
    ModelMetaData modelTwo = new ModelMetaData();
    modelTwo.setName("model-two");
    modelTwo.addSourceMapping("s1", "translator", "java:binding-one")
    modelTwo.addSourceMapping("s2", "translator", "java:binding-two")
    modelTwo.setModelType(Model.Type.VIRTUAL);
    modelTwo.addProperty("model-prop", "model-value")
   
    vdb.addModel(modelTwo);
   
    TranslatorMetaData t1 = new TranslatorMetaData();
    t1.setName("oracleOverride");
    t1.setType("oracle");
    t1.addProperty("my-property", "my-value");
    List<Translator> list = new ArrayList<Translator>();
    list.add(t1);
    vdb.setOverrideTranslators(list);
   
    DataPolicyMetadata roleOne = new DataPolicyMetadata();
    roleOne.setName("roleOne");
    roleOne.setDescription("roleOne described");
   
    PermissionMetaData perm1 = new PermissionMetaData();
    perm1.setResourceName("myTable.T1");
    perm1.setAllowRead(true);
    roleOne.addPermission(perm1);
   
    PermissionMetaData perm2 = new PermissionMetaData();
    perm2.setResourceName("myTable.T2");
    perm2.setAllowRead(false);
    perm2.setAllowDelete(true);
    roleOne.addPermission(perm2);
   
    roleOne.setMappedRoleNames(Arrays.asList("ROLE1", "ROLE2"))
   
    vdb.addDataPolicy(roleOne);
   
    // convert to managed object and build the VDB out of MO
    ManagedObjectFactory mof = ManagedObjectFactoryBuilder.create();
    ManagedObject mo = mof.initManagedObject(vdb, null, null);
    vdb = AdminObjectBuilder.buildAO(mo, VDBMetaData.class);
   
    assertEquals("myVDB", vdb.getName());
    assertEquals("vdb description", vdb.getDescription());
    assertEquals(1, vdb.getVersion());
    assertEquals("vdb-value", vdb.getPropertyValue("vdb-property"))
   
    assertNotNull(vdb.getModel("model-one"));
    assertNotNull(vdb.getModel("model-two"));
    assertNull(vdb.getModel("model-unknown"));
   
    modelOne = vdb.getModel("model-one");
    assertEquals("model-one", modelOne.getName());
    assertEquals("s1", modelOne.getSourceNames().get(0));
    assertEquals(Model.Type.PHYSICAL, modelOne.getModelType());
    assertEquals("model-value-override", modelOne.getPropertyValue("model-prop"))
    assertFalse(modelOne.isVisible());
    assertEquals("model description", modelOne.getDescription());
   
    modelTwo = vdb.getModel("model-two");
    assertEquals("model-two", modelTwo.getName());
    assertTrue(modelTwo.getSourceNames().contains("s1"));
    assertTrue(modelTwo.getSourceNames().contains("s2"));
    assertEquals(Model.Type.VIRTUAL, modelTwo.getModelType()); // this is not persisted in the XML
    assertEquals("model-value", modelTwo.getPropertyValue("model-prop"))
   
   
    assertTrue(vdb.getValidityErrors().contains("There is an error in VDB"));
   
    List<Translator> translators = vdb.getOverrideTranslators();
    assertTrue(translators.size() == 1);
   
    Translator translator = translators.get(0);
    assertEquals("oracleOverride", translator.getName());
    assertEquals("oracle", translator.getType());
    assertEquals("my-value", translator.getPropertyValue("my-property"));
       
    List<DataPolicy> roles = vdb.getDataPolicies();
   
    assertTrue(roles.size() == 1);
   
    DataPolicyMetadata role = vdb.getDataPolicy("roleOne");
    assertEquals("roleOne described", role.getDescription());
    assertNotNull(role.getMappedRoleNames());
    assertTrue(role.getMappedRoleNames().contains("ROLE1"));
    assertTrue(role.getMappedRoleNames().contains("ROLE2"));
   
View Full Code Here

TOP

Related Classes of org.teiid.adminapi.impl.VDBMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.