use of org.teiid.metadata.Procedure in project teiid by teiid.
the class TestWSTranslator method testPre81Procedure.
@Test
public void testPre81Procedure() throws Exception {
WSExecutionFactory ef = new WSExecutionFactory();
WSConnection mockConnection = Mockito.mock(WSConnection.class);
MetadataFactory mf = new MetadataFactory("vdb", 1, "x", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
ef.getMetadata(mf, mockConnection);
Procedure p = mf.getSchema().getProcedure(WSExecutionFactory.INVOKE_HTTP);
assertEquals(7, p.getParameters().size());
p.getParameters().remove(4);
p.getParameters().remove(5);
// designer treated the result as an out parameter
p.getParameters().get(0).setType(Type.Out);
p.getParameters().add(3, p.getParameters().remove(0));
for (int i = 0; i < p.getParameters().size(); i++) {
p.getParameters().get(i).setPosition(i + 1);
}
p = mf.getSchema().getProcedure("invoke");
assertEquals(6, p.getParameters().size());
p.getParameters().remove(5);
// designer treated the result as an out parameter
p.getParameters().get(0).setType(Type.Out);
p.getParameters().add(p.getParameters().remove(0));
for (int i = 0; i < p.getParameters().size(); i++) {
p.getParameters().get(i).setPosition(i + 1);
}
TransformationMetadata tm = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "vdb");
RuntimeMetadataImpl rm = new RuntimeMetadataImpl(tm);
Dispatch<Object> mockDispatch = mockDispatch();
DataSource source = Mockito.mock(DataSource.class);
Mockito.stub(mockDispatch.invoke(Mockito.any(DataSource.class))).toReturn(source);
Mockito.stub(mockConnection.createDispatch(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(Class.class), Mockito.any(Service.Mode.class))).toReturn(mockDispatch);
CommandBuilder cb = new CommandBuilder(tm);
Call call = (Call) cb.getCommand("call invokeHttp('GET', null, null)");
BinaryWSProcedureExecution pe = new BinaryWSProcedureExecution(call, rm, Mockito.mock(ExecutionContext.class), ef, mockConnection);
pe.execute();
pe.getOutputParameterValues();
mockConnection = Mockito.mock(WSConnection.class);
mockDispatch = Mockito.mock(Dispatch.class);
StAXSource ssource = Mockito.mock(StAXSource.class);
Mockito.stub(mockDispatch.invoke(Mockito.any(StAXSource.class))).toReturn(ssource);
Mockito.stub(mockConnection.createDispatch(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(Class.class), Mockito.any(Service.Mode.class))).toReturn(mockDispatch);
call = (Call) cb.getCommand("call invoke()");
WSProcedureExecution wpe = new WSProcedureExecution(call, rm, Mockito.mock(ExecutionContext.class), ef, mockConnection);
wpe.execute();
wpe.getOutputParameterValues();
}
use of org.teiid.metadata.Procedure in project teiid by teiid.
the class TestSwaggerMetadataProcessor method testRefParameter.
@Test
public void testRefParameter() throws Exception {
SwaggerExecutionFactory translator = new SwaggerExecutionFactory();
translator.start();
MetadataFactory mf = getMetadata(translator, UnitTestUtil.getTestDataPath() + "/redis-swagger.json");
Procedure p = mf.getSchema().getProcedure("Operations_List");
assertNotNull(p);
assertEquals("GET", p.getProperty(RestMetadataExtension.METHOD, false).toUpperCase());
assertEquals("https://management.azure.comnull/providers/Microsoft.Cache/operations", p.getProperty(RestMetadataExtension.URI, false));
assertNotNull(p.getResultSet());
assertNotNull(p.getParameterByName("api-version"));
}
use of org.teiid.metadata.Procedure in project teiid by teiid.
the class TestSwaggerMetadataProcessor method testEndpointAsName.
@Test
public void testEndpointAsName() throws Exception {
SwaggerExecutionFactory translator = new SwaggerExecutionFactory();
translator.start();
MetadataFactory mf = getMetadata(translator, UnitTestUtil.getTestDataPath() + "/fahrplan-swagger.json");
Procedure p = mf.getSchema().getProcedure("arrivalBoard/id");
assertNotNull(p);
assertEquals("GET", p.getProperty(RestMetadataExtension.METHOD, false).toUpperCase());
assertEquals("http://api.deutschebahn.com/freeplan/v1/arrivalBoard/{id}", p.getProperty(RestMetadataExtension.URI, false));
assertNotNull(p.getResultSet());
}
use of org.teiid.metadata.Procedure in project teiid by teiid.
the class TestSwaggerMetadataProcessor method testReftoResponse.
@Test
public void testReftoResponse() throws TranslatorException {
SwaggerExecutionFactory translator = new SwaggerExecutionFactory();
translator.start();
MetadataFactory mf = petstoreMetadata(translator);
Procedure p = mf.getSchema().getProcedure("findPetsByTags");
assertNotNull(p);
assertEquals("GET", p.getProperty(RestMetadataExtension.METHOD, false).toUpperCase());
assertEquals("http://petstore.swagger.io/v2/pet/findByTags", p.getProperty(RestMetadataExtension.URI, false));
assertNotNull(p.getResultSet());
List<Column> columns = p.getResultSet().getColumns();
assertEquals(8, columns.size());
Column pa = p.getResultSet().getColumnByName("id");
assertNull(pa.getNameInSource());
pa = p.getResultSet().getColumnByName("category_id");
assertEquals("category/id", pa.getNameInSource());
pa = p.getResultSet().getColumnByName("tags_Tag_id");
assertEquals("tags[]/Tag/id", pa.getNameInSource());
}
use of org.teiid.metadata.Procedure in project teiid by teiid.
the class TestSwaggerMetadataProcessor method testSchema.
@Test
public void testSchema() throws Exception {
SwaggerExecutionFactory translator = new SwaggerExecutionFactory();
translator.start();
MetadataFactory mf = swaggerMetadata(translator);
// TransformationMetadata metadata = getTransformationMetadata(mf, translator);
String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
// System.out.println(ddl);
MetadataFactory mf2 = new MetadataFactory("vdb", 1, "x", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
QueryParser.getQueryParser().parseDDL(mf2, ddl);
Set<String> procSet = new HashSet<String>();
for (Procedure p : mf.getSchema().getProcedures().values()) {
procSet.add(p.getName());
}
assertEquals(29, procSet.size());
assertTrue(procSet.contains("addCustomer"));
assertTrue(procSet.contains("addOneCustomer"));
assertTrue(procSet.contains("addCustomerList"));
assertTrue(procSet.contains("getCustomers"));
assertTrue(procSet.contains("getCustomerList"));
assertTrue(procSet.contains("getCustomerByCity"));
assertTrue(procSet.contains("getCustomerByCountry"));
assertTrue(procSet.contains("getCustomerByName"));
assertTrue(procSet.contains("getCustomerByNumber"));
assertTrue(procSet.contains("getByNumCityCountry"));
assertTrue(procSet.contains("size"));
assertTrue(procSet.contains("removeCustomer"));
assertTrue(procSet.contains("removeCustomerByCity"));
assertTrue(procSet.contains("removeCustomerByCountry"));
assertTrue(procSet.contains("removeCustomerByName"));
assertTrue(procSet.contains("removeCustomerByNumber"));
assertTrue(procSet.contains("removeCustomerByNumCityCountry"));
assertTrue(procSet.contains("updateCustomer"));
assertTrue(procSet.contains("updateCustomerByCity"));
assertTrue(procSet.contains("updateCustomerByCountry"));
assertTrue(procSet.contains("updateCustomerByName"));
assertTrue(procSet.contains("updateCustomerByNumber"));
assertTrue(procSet.contains("updateCustomerByNumCityCountry"));
// test preferences
Procedure p = mf.getSchema().getProcedures().get("updateCustomer");
assertEquals("application/json", p.getProperty(RestMetadataExtension.PRODUCES, false));
}
Aggregations