static final String VDB = "metadata";
@BeforeClass public static void setUp() throws Exception {
FakeServer server = new FakeServer();
MetadataRepository repo = Mockito.mock(MetadataRepository.class);
server.setMetadataRepository(repo);
Mockito.stub(repo.getViewDefinition(Mockito.anyString(), Mockito.anyInt(), (Table)Mockito.anyObject())).toAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
Table t = (Table)invocation.getArguments()[2];
if (t.getName().equals("vw")) {
return "select '2011'";
}
return null;
}
});
Mockito.stub(repo.getProcedureDefinition(Mockito.anyString(), Mockito.anyInt(), (Procedure)Mockito.anyObject())).toAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
Procedure t = (Procedure)invocation.getArguments()[2];
if (t.getName().equals("proc")) {
return "create virtual procedure begin select '2011'; end";
}
return null;
}
});
Mockito.stub(repo.getInsteadOfTriggerDefinition(Mockito.anyString(), Mockito.anyInt(), (Table)Mockito.anyObject(), (Table.TriggerEvent) Mockito.anyObject())).toAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return "for each row select 1/0;";
}
});
Mockito.stub(repo.isInsteadOfTriggerEnabled(Mockito.anyString(), Mockito.anyInt(), (Table)Mockito.anyObject(), (Table.TriggerEvent) Mockito.anyObject())).toAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
return Boolean.TRUE;
}
});