@RunWith(CassandraRunner.class)
public class AgentStatusTest {
@Test
public void checkPersistence() {
new CassandraCollectorNodeStatusDataStore().store("node1", new NodeStatus(new ValidationResult[] {
new ValidationResult("v1", Status.OK, "m1"), new ValidationResult("v2", Status.KO, "m2") }, new Date()));
new CassandraCollectorNodeStatusDataStore().store("node2", new NodeStatus(new ValidationResult[] {
new ValidationResult("v3", Status.OK, "m3"), new ValidationResult("v4", Status.KO, "m4") }, new Date()));
final Map<String, NodeStatus> statuses = new CassandraCollectorNodeStatusDataStore().statuses();
assertEquals(2, statuses.size());
final NodeStatus n1 = statuses.get("node1");
assertNotNull(n1);
final ValidationResult[] result1 = n1.getResults();
assertEquals(2, result1.length);
assertEquals("v1", result1[0].getName());
assertEquals("m1", result1[0].getMessage());
assertEquals(Status.OK, result1[0].getStatus());
assertEquals("v2", result1[1].getName());
assertEquals("m2", result1[1].getMessage());
assertEquals(Status.KO, result1[1].getStatus());
final NodeStatus n2 = statuses.get("node2");
assertNotNull(n2);
final ValidationResult[] result2 = n2.getResults();
assertEquals(2, result2.length);
assertEquals("v3", result2[0].getName());
assertEquals("m3", result2[0].getMessage());
assertEquals(Status.OK, result2[0].getStatus());
assertEquals("v4", result2[1].getName());