use of org.apache.cayenne.gen.mock.TestClassGenerationAction in project cayenne by apache.
the class ClassGenerationActionTest method assertCallbacks.
private void assertCallbacks(boolean isClient) throws Exception {
ObjEntity testEntity1 = new ObjEntity("TE1");
testEntity1.setClassName("org.example.TestClass1");
int i = 0;
for (CallbackDescriptor cb : testEntity1.getCallbackMap().getCallbacks()) {
cb.addCallbackMethod("cb" + i++);
}
if (isClient) {
cgenConfiguration.setClient(true);
action = new TestClassGenerationAction(getUnitTestInjector().getInstance(ClassGenerationActionFactory.class).createAction(cgenConfiguration), writers);
}
cgenConfiguration.setMakePairs(true);
List<String> generated = execute(new EntityArtifact(testEntity1));
assertNotNull(generated);
assertEquals(2, generated.size());
String superclass = generated.get(0);
assertTrue(superclass, superclass.contains("public abstract class _TestClass1"));
for (int j = 0; j < i; j++) {
assertTrue(superclass, superclass.contains("protected abstract void cb" + j + "();"));
}
String subclass = generated.get(1);
for (int j = 0; j < i; j++) {
assertTrue(subclass, subclass.contains("protected void cb" + j + "() {"));
}
}
use of org.apache.cayenne.gen.mock.TestClassGenerationAction in project cayenne by apache.
the class ClassGenerationActionTest method setUp.
@Before
public void setUp() throws Exception {
writers = new ArrayList<>(3);
cgenConfiguration = new CgenConfiguration(false);
action = new TestClassGenerationAction(getUnitTestInjector().getInstance(ClassGenerationActionFactory.class).createAction(cgenConfiguration), writers);
}
Aggregations