use of com.navercorp.pinpoint.rpc.server.ChannelPropertiesFactory in project pinpoint by naver.
the class AgentLifeCycleAsyncTaskServiceTest method runAndVerifyAgentLifeCycle.
private void runAndVerifyAgentLifeCycle(ManagedAgentLifeCycle managedAgentLifeCycle) {
// given
final AgentLifeCycleState expectedLifeCycleState = managedAgentLifeCycle.getMappedState();
final int expectedEventCounter = managedAgentLifeCycle.getEventCounter();
final long expectedEventIdentifier = createEventIdentifier(TEST_SOCKET_ID, expectedEventCounter);
ArgumentCaptor<AgentLifeCycleBo> argCaptor = ArgumentCaptor.forClass(AgentLifeCycleBo.class);
// when
ChannelPropertiesFactory channelPropertiesFactory = new ChannelPropertiesFactory();
ChannelProperties channelProperties = channelPropertiesFactory.newChannelProperties(TEST_CHANNEL_PROPERTIES);
AgentProperty agentProperty = new AgentPropertyChannelAdaptor(channelProperties);
long eventIdentifier = AgentLifeCycleAsyncTaskService.createEventIdentifier(TEST_SOCKET_ID, expectedEventCounter);
this.agentLifeCycleAsyncTaskService.handleLifeCycleEvent(agentProperty, TEST_EVENT_TIMESTAMP, expectedLifeCycleState, eventIdentifier);
verify(this.agentLifeCycleService, times(1)).insert(argCaptor.capture());
// then
AgentLifeCycleBo actualAgentLifeCycleBo = argCaptor.getValue();
assertEquals(AgentLifeCycleBo.CURRENT_VERSION, actualAgentLifeCycleBo.getVersion());
assertEquals(TEST_AGENT_ID, actualAgentLifeCycleBo.getAgentId());
assertEquals(TEST_START_TIMESTAMP, actualAgentLifeCycleBo.getStartTimestamp());
assertEquals(TEST_EVENT_TIMESTAMP, actualAgentLifeCycleBo.getEventTimestamp());
assertEquals(expectedLifeCycleState, actualAgentLifeCycleBo.getAgentLifeCycleState());
assertEquals(expectedEventIdentifier, actualAgentLifeCycleBo.getEventIdentifier());
}
Aggregations