use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestODataSQLBuilder method setup.
private BaseState setup(String ddl, String url, String method, ServletInputStream stream, BaseState state) throws Exception {
Client client = Mockito.mock(Client.class);
DDLHolder model = new DDLHolder("PM1", ddl);
TransformationMetadata metadata = RealMetadataFactory.fromDDL("vdb", model);
MetadataStore store = metadata.getMetadataStore();
// TranslationUtility utility = new TranslationUtility(metadata);
OData odata = OData4Impl.newInstance();
org.teiid.metadata.Schema teiidSchema = store.getSchema("PM1");
CsdlSchema schema = ODataSchemaBuilder.buildMetadata("vdb", teiidSchema);
TeiidEdmProvider edmProvider = new TeiidEdmProvider("baseuri", schema, "x");
ServiceMetadata serviceMetadata = odata.createServiceMetadata(edmProvider, Collections.<EdmxReference>emptyList());
ODataHttpHandler handler = odata.createHandler(serviceMetadata);
Hashtable<String, String> headers = new Hashtable<String, String>();
headers.put("Content-Type", "application/json");
Mockito.stub(client.getMetadataStore()).toReturn(store);
Mockito.stub(client.executeCount(Mockito.any(Query.class), Mockito.anyListOf(SQLParameter.class))).toReturn(new CountResponse() {
@Override
public int getCount() {
return 10;
}
});
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
Mockito.stub(request.getHeaderNames()).toReturn(headers.keys());
Mockito.stub(request.getHeaders("Content-Type")).toReturn(headers.elements());
Mockito.stub(request.getMethod()).toReturn(method);
String requestURL = url;
String queryString = "";
int idx = url.indexOf("?");
if (idx != -1) {
requestURL = url.substring(0, idx);
queryString = url.substring(idx + 1);
}
Mockito.stub(request.getRequestURL()).toReturn(new StringBuffer(requestURL));
Mockito.stub(request.getQueryString()).toReturn(queryString);
Mockito.stub(request.getServletPath()).toReturn("");
Mockito.stub(request.getContextPath()).toReturn("/odata4/vdb/PM1");
Mockito.stub(request.getInputStream()).toReturn(stream);
final StringBuffer sb = new StringBuffer();
ServletOutputStream out = new ServletOutputStream() {
@Override
public void write(int b) throws IOException {
sb.append((char) b);
}
@Override
public boolean isReady() {
return true;
}
@Override
public void setWriteListener(WriteListener writeListener) {
}
};
HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
Mockito.stub(response.getOutputStream()).toReturn(out);
try {
TeiidServiceHandler tsh = new TeiidServiceHandler("PM1");
tsh.setPrepared(false);
TeiidServiceHandler.setClient(client);
handler.register(tsh);
handler.process(request, response);
} finally {
TeiidServiceHandler.setClient(null);
}
ArgumentCaptor<Integer> statusCapture = ArgumentCaptor.forClass(Integer.class);
Mockito.verify(response).setStatus(statusCapture.capture());
state.client = client;
state.response = sb.toString();
state.status = statusCapture.getValue();
return state;
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestMultipleModelIndexes method testSchemaLoad.
@Test
public void testSchemaLoad() throws Exception {
TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/Test.vdb");
// ensure that datatypes are set
Table t = tm.getGroupID("Northwind.Northwind.dbo.Employees");
assertFalse(t.isVirtual());
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestMultipleModelIndexes method testIndex.
@Test
public void testIndex() throws Exception {
TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/ora.vdb");
Collection indexes = tm.getIndexesInGroup(tm.getGroupID("ORACLE_BQT.SMALLA"));
assertEquals(1, indexes.size());
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestStagingTable method testStagingTables.
@Test
public void testStagingTables() throws Exception {
TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/other/test.vdb");
assertEquals(1, tm.getXMLTempGroups(tm.getGroupID("doc.newxmldocument")).size());
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestMongoDBQueryExecution method setUp.
@Before
public void setUp() throws Exception {
this.translator = new MongoDBExecutionFactory();
this.translator.setDatabaseVersion("2.6");
this.translator.start();
MetadataFactory mf = TestDDLParser.helpParse(ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("northwind.ddl")), "northwind");
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "sakila", new FunctionTree("mongo", new UDFSource(translator.getPushDownFunctions())));
ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore());
if (report.hasItems()) {
throw new RuntimeException(report.getFailureMessage());
}
this.utility = new TranslationUtility(metadata);
}
Aggregations