Search in sources :

Example 1 with ChannelPropertiesFactory

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());
}
Also used : ChannelProperties(com.navercorp.pinpoint.rpc.server.ChannelProperties) AgentPropertyChannelAdaptor(com.navercorp.pinpoint.collector.service.async.AgentPropertyChannelAdaptor) ChannelPropertiesFactory(com.navercorp.pinpoint.rpc.server.ChannelPropertiesFactory) AgentProperty(com.navercorp.pinpoint.collector.service.async.AgentProperty) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)

Aggregations

AgentProperty (com.navercorp.pinpoint.collector.service.async.AgentProperty)1 AgentPropertyChannelAdaptor (com.navercorp.pinpoint.collector.service.async.AgentPropertyChannelAdaptor)1 AgentLifeCycleBo (com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)1 AgentLifeCycleState (com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)1 ChannelProperties (com.navercorp.pinpoint.rpc.server.ChannelProperties)1 ChannelPropertiesFactory (com.navercorp.pinpoint.rpc.server.ChannelPropertiesFactory)1