示例#1
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;
   }
 }
示例#2
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();
 }
示例#3
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();
  }
 @Test
 public void assertThatNiceMockAnnotationWork() {
   assertNull(someService.getData());
   assertNotNull(someService.getMoreData());
 }