use of org.franca.core.franca.FBasicTypeId in project joynr by bmwcarit.
the class AbstractTypeUtilTest method testMultipleOutParameters.
@Test
public void testMultipleOutParameters() throws Exception {
URL fixtureURL = AbstractTypeUtilTest.class.getResource("MultipleOutParameters.fidl");
ModelLoader loader = new ModelLoader(fixtureURL.getPath());
Resource fixtureResource = loader.getResources().iterator().next();
class MyCallsRealMethods extends CallsRealMethods {
private static final long serialVersionUID = 1L;
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
if (invocation.getMethod().getName().equals("getTypeName")) {
Class<?> parameterType0 = invocation.getMethod().getParameterTypes()[0];
if (parameterType0.equals(FBasicTypeId.class)) {
return ((FBasicTypeId) invocation.getArguments()[0]).getName();
} else if (parameterType0.equals(FType.class)) {
return ((FType) invocation.getArguments()[0]).getName();
} else {
return super.answer(invocation);
}
} else {
return super.answer(invocation);
}
}
}
AbstractTypeUtil typeUtil = mock(AbstractTypeUtil.class, new MyCallsRealMethods());
Guice.createInjector().injectMembers(typeUtil);
FModel model = (FModel) fixtureResource.getContents().get(0);
String stringDatatype = FBasicTypeId.STRING.getName();
String numberDatatype = FBasicTypeId.INT16.getName();
String complexDatatype = model.getTypeCollections().get(0).getTypes().get(0).getName();
FMethod fixture = model.getInterfaces().get(0).getMethods().get(0);
Iterator<String> result = typeUtil.getTypeNamesForOutputParameter(fixture).iterator();
assertEquals(result.next(), stringDatatype);
assertEquals(result.next(), numberDatatype);
assertEquals(result.next(), complexDatatype);
assertFalse(result.hasNext());
}
Aggregations