use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCountRes in project pinpoint by naver.
the class AgentActiveThreadCountFactoryTest method invalidActiveThreadCountTest1.
@Test
public void invalidActiveThreadCountTest1() throws Exception {
TCmdActiveThreadCountRes response = new TCmdActiveThreadCountRes();
response.setActiveThreadCount(Arrays.asList(1, 2, 3));
AgentActiveThreadCountFactory factory = new AgentActiveThreadCountFactory();
factory.setAgentId("test");
AgentActiveThreadCount agentActiveThreadCount = factory.create(response);
Assert.assertEquals(factory.INTERNAL_ERROR.getCode(), agentActiveThreadCount.getCode());
Assert.assertTrue(CollectionUtils.nullSafeSize(agentActiveThreadCount.getActiveThreadCountList()) == 0);
}
use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCountRes in project pinpoint by naver.
the class AgentActiveThreadCountFactoryTest method assertAgentIdTest.
@Test(expected = NullPointerException.class)
public void assertAgentIdTest() throws Exception {
AgentActiveThreadCountFactory factory = new AgentActiveThreadCountFactory();
factory.create(new TCmdActiveThreadCountRes());
}
use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCountRes in project pinpoint by naver.
the class AgentActiveThreadCountFactoryTest method invalidActiveThreadCountTest2.
@Test
public void invalidActiveThreadCountTest2() throws Exception {
TCmdActiveThreadCountRes response = new TCmdActiveThreadCountRes();
response.setActiveThreadCount(Arrays.asList(1, 2, 3, 4, 5));
AgentActiveThreadCountFactory factory = new AgentActiveThreadCountFactory();
factory.setAgentId("test");
AgentActiveThreadCount agentActiveThreadCount = factory.create(response);
Assert.assertEquals(factory.INTERNAL_ERROR.getCode(), agentActiveThreadCount.getCode());
Assert.assertTrue(CollectionUtils.nullSafeSize(agentActiveThreadCount.getActiveThreadCountList()) == 0);
}
use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCountRes in project pinpoint by naver.
the class AgentActiveThreadCountFactory method create.
public AgentActiveThreadCount create(TBase<?, ?> value) {
if (agentId == null) {
throw new NullPointerException("agentId may not be null");
}
if (value instanceof TCmdActiveThreadCountRes) {
TCmdActiveThreadCountRes response = (TCmdActiveThreadCountRes) value;
List<Integer> activeThreadCountList = response.getActiveThreadCount();
if (CollectionUtils.nullSafeSize(activeThreadCountList) == 4) {
return createSuccess0(activeThreadCountList);
} else {
return createFail(INTERNAL_ERROR.getCode(), "activeThreadCountList size must be 4");
}
} else {
StringBuilder message = new StringBuilder();
message.append("agentId:").append(agentId);
message.append("- value(").append(ClassUtils.simpleClassName(value));
message.append(") must be an instance of TCmdActiveThreadCountRes");
return createFail0(INTERNAL_ERROR.getCode(), message.toString());
}
}
use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCountRes in project pinpoint by naver.
the class AgentActiveThreadCountListTest method testName.
@Test
public void testName() throws Exception {
String hostName1 = "hostName1";
String hostName2 = "hostName2";
AgentActiveThreadCountFactory factory = new AgentActiveThreadCountFactory();
factory.setAgentId(hostName1);
AgentActiveThreadCount status1 = factory.createFail(TRouteResult.NOT_ACCEPTABLE.name());
TCmdActiveThreadCountRes response = new TCmdActiveThreadCountRes();
response.setActiveThreadCount(Arrays.asList(1, 2, 3, 4));
factory.setAgentId(hostName2);
AgentActiveThreadCount status2 = factory.create(response);
AgentActiveThreadCountList list = new AgentActiveThreadCountList(5);
list.add(status1);
list.add(status2);
ObjectMapper om = new ObjectMapper();
String listAsString = om.writeValueAsString(list);
Map map = om.readValue(listAsString, Map.class);
Assert.assertTrue(map.containsKey(hostName1));
Assert.assertTrue(map.containsKey(hostName2));
assertDataWithSerializedJsonString((Map) map.get(hostName1), TRouteResult.NOT_ACCEPTABLE, null);
assertDataWithSerializedJsonString((Map) map.get(hostName2), TRouteResult.OK, Arrays.asList(1, 2, 3, 4));
}
Aggregations