Exemplo n.º 1
0
 public School findSchoolByName(String schoolName) {
   QueryBuilder<School> builder = qbf.newQueryBuilder(School.class);
   SchoolEntity.SchoolState template = templateFor(SchoolEntity.SchoolState.class);
   builder.where(eq(template.name(), schoolName));
   Query<School> query = builder.newQuery(uowf.currentUnitOfWork());
   return query.find();
 }
Exemplo n.º 2
0
 @Test
 public void whenTraceOnMixinImplExpectTwoEntryInEntityStore() throws Exception {
   SomeService sc =
       moduleInstance.serviceFinder().<SomeService>findService(SomeService.class).get();
   assertEquals(123, sc.doSomethingImportant());
   assertEquals(789, sc.doSomethingModeratelyImportant());
   UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
   try {
     QueryBuilder<TraceRecord> builder = queryBuilderFactory.newQueryBuilder(TraceRecord.class);
     Query<TraceRecord> query = builder.newQuery(uow);
     // IS sorting needed??
     TraceRecord template = templateFor(TraceRecord.class);
     query.orderBy(orderBy(template.methodName()));
     Iterator<TraceRecord> result = query.iterator();
     assertTrue(result.hasNext());
     TraceRecord rec1 = result.next();
     assertEquals("doSomethingImportant", rec1.methodName().get());
     assertTrue(result.hasNext());
     TraceRecord rec2 = result.next();
     assertEquals("doSomethingModeratelyImportant", rec2.methodName().get());
     assertFalse(result.hasNext());
     uow.complete();
   } catch (Exception e) {
     uow.discard();
     throw e;
   } catch (Error e) {
     uow.discard();
     throw e;
   }
 }
Exemplo n.º 3
0
 @Test
 public void whenTraceOnMixinTypeMethodExpectOneEntryInEntityStore() throws Exception {
   SomeService sc =
       moduleInstance.serviceFinder().<SomeService>findService(SomeService.class).get();
   assertEquals(123, sc.doSomethingImportant());
   assertEquals(456, sc.doSomethingLessImportant());
   UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
   QueryBuilder<TraceRecord> builder = queryBuilderFactory.newQueryBuilder(TraceRecord.class);
   Query<TraceRecord> query = builder.newQuery(uow);
   // IS sorting needed??
   //        TraceRecord template = templateFor( TraceRecord.class );
   //        query.orderBy( orderBy( template.methodName() ) );
   Iterator<TraceRecord> result = query.iterator();
   assertTrue(result.hasNext());
   TraceRecord rec1 = result.next();
   assertEquals("doSomethingImportant", rec1.methodName().get());
   assertFalse(result.hasNext());
   uow.complete();
 }
Exemplo n.º 4
0
  @Test
  public void whenTraceOnConcernExpectOneEntryInEntityStore() throws Exception {
    // It is not possible to put Annotation on Concern Methods, so it should only record one.

    SomeService sc =
        moduleInstance.serviceFinder().<SomeService>findService(SomeService.class).get();
    assertEquals(123, sc.doSomethingImportant());
    assertEquals(753, sc.doSomethingInsanelyImportant());
    UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
    QueryBuilder<TraceRecord> builder = queryBuilderFactory.newQueryBuilder(TraceRecord.class);
    Query<TraceRecord> query = builder.newQuery(uow);
    // IS sorting needed??
    //        TraceRecord template = templateFor( TraceRecord.class );
    //        query.orderBy( orderBy( template.methodName() ) );
    Iterator<TraceRecord> result = query.iterator();
    assertTrue(result.hasNext());
    TraceRecord rec1 = result.next();
    assertEquals("doSomethingImportant", rec1.methodName().get());
    assertFalse(result.hasNext());
    uow.complete();
  }