OpenMonBase implements OpenMon<T> { @Override public void exception(JoinPoint jp, Throwable throwable) { put(throwable); trackException(jp, throwable); }  @Override void stop(T context, Throwable throwable); @Override void exception(JoinPoint jp, Throwable throwable);  }
@Test public void testException() throws Exception { JoinPoint jp = mock(JoinPoint.class); RuntimeException runtimeException = new RuntimeException("my exception"); openMon.exception(jp, runtimeException); assertThat(openMon.getExceptionsMap()).containsOnlyKeys(runtimeException); Map<Throwable, Expirable> exceptionsMap = openMon.getExceptionsMap(); Expirable expirable = exceptionsMap.get(runtimeException); openMon.exception(jp, runtimeException); openMon.exception(jp, runtimeException); assertThat(openMon.getExceptionsMap()).containsOnlyKeys(runtimeException); assertThat(openMon.getExceptionsMap().get(runtimeException)). describedAs("The value object should only have been created once"). isEqualTo(expirable); Map<Throwable, AutomonExpirable> map = openMon.getExceptionsMap(); assertThat(map.get(runtimeException).getThrowable()).describedAs("Throwable should have been set").isEqualTo(runtimeException); }