@Test @SuppressWarnings("unchecked") public void unknownPlatformId() throws Exception { when(definition.getClassName()).thenReturn("class.one"); ClassInstrumentationChangedEvent event = new ClassInstrumentationChangedEvent(this, 10L, Arrays.asList(definition)); messageGate.onApplicationEvent(event); when(agentStatusDataProvider.getAgentStatusDataMap()).thenReturn(Collections.EMPTY_MAP); assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(1)); messageGate.flush(20L); verifyZeroInteractions(messageProvider); assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(1)); } }
@Test @SuppressWarnings("rawtypes") public void successful() throws Exception { when(definition.getClassName()).thenReturn("class.one"); ClassInstrumentationChangedEvent event = new ClassInstrumentationChangedEvent(this, 10L, Arrays.asList(definition)); messageGate.onApplicationEvent(event); when(agentStatusDataProvider.getAgentStatusDataMap()).thenReturn(ImmutableMap.of(10L, statusData)); when(statusData.getInstrumentationStatus()).thenReturn(InstrumentationStatus.PENDING); assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(1)); messageGate.flush(10L); ArgumentCaptor<IAgentMessage> messageCaptor = ArgumentCaptor.forClass(IAgentMessage.class); verify(messageProvider).provideMessage(eq(10L), messageCaptor.capture()); verify(statusData).setInstrumentationStatus(InstrumentationStatus.UP_TO_DATE); verifyNoMoreInteractions(statusData, messageProvider); assertThat(((UpdatedInstrumentationMessage) messageCaptor.getValue()).getMessageContent(), contains(definition)); assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(0)); }