@Test
public void testMonitor() throws Throwable {

    ProceedingJoinPoint mockPjp = createPjpMock(mockSignature, 2);
    expect(mockPjp.proceed()).andReturn(null).times(2);
    replay(mockPjp);
    // Test monitor without pre-existing circuit breaker.
    aspect.monitor(mockPjp, mockAnnotation);
    // Test monitor with pre-existing circuit breaker.
    aspect.monitor(mockPjp, mockAnnotation);
    String otherName = "OtherMonitor";
    ProceedingJoinPoint otherMockPjp = createPjpMock(mockSignature, 1);
    expect(otherMockPjp.proceed()).andReturn(null).times(1);
    replay(otherMockPjp);
    CircuitBreaker otherMockAnnotation = createMock(CircuitBreaker.class);
    expect(otherMockAnnotation.name()).andReturn(otherName).anyTimes();
    expect(otherMockAnnotation.limit()).andReturn(5).anyTimes();
    expect(otherMockAnnotation.resetMillis()).andReturn(30000L).anyTimes();
    expect(otherMockAnnotation.windowMillis()).andReturn(10000L).anyTimes();
    @SuppressWarnings("unchecked")
    Class<Throwable>[] ignores = new Class[0];
    expect(otherMockAnnotation.ignore()).andReturn(ignores);
    replay(otherMockAnnotation);
    // Test monitor with another circuit breaker.
    aspect.monitor(otherMockPjp, otherMockAnnotation);
    verifyBreakerExists(TEST_CIRCUIT_BREAKER);
    verifyBreakerExists(otherName);
    verify(mockPjp);
    verify(mockAnnotation);
    verify(mockSignature);
    verify(otherMockPjp);
    verify(otherMockAnnotation);
}