use of org.graylog.plugins.sidecar.rest.models.Sidecar in project graylog2-server by Graylog2.
the class SidecarServiceImplTest method testDestroy.
@Test
@MongoDBFixtures("collectorsMultipleDocuments.json")
public void testDestroy() throws Exception {
final Sidecar sidecar = mock(Sidecar.class);
when(sidecar.id()).thenReturn("581b3bff8e4dc4270055dfcb");
final int result = this.sidecarService.delete(sidecar.id());
assertEquals(1, result);
assertEquals(2, mongodb.mongoConnection().getMongoDatabase().getCollection(collectionName).count());
}
use of org.graylog.plugins.sidecar.rest.models.Sidecar in project graylog2-server by Graylog2.
the class SidecarServiceImplTest method testSaveFirstRecord.
@Test
public void testSaveFirstRecord() throws Exception {
String nodeId = "nodeId";
String nodeName = "nodeName";
String version = "0.0.1";
String os = "DummyOS 1.0";
final Sidecar sidecar = Sidecar.create(nodeId, nodeName, NodeDetails.create(os, null, null, null, null), version);
final Sidecar result = this.sidecarService.save(sidecar);
MongoCollection<Document> collection = mongodb.mongoConnection().getMongoDatabase().getCollection(collectionName);
Document document = collection.find().first();
Document nodeDetails = document.get("node_details", Document.class);
assertNotNull(result);
assertEquals(nodeId, document.get("node_id"));
assertEquals(nodeName, document.get("node_name"));
assertEquals(version, document.get("sidecar_version"));
assertEquals(os, nodeDetails.get("operating_system"));
}
use of org.graylog.plugins.sidecar.rest.models.Sidecar in project graylog2-server by Graylog2.
the class SidecarServiceImplTest method testFindByIdNonexisting.
@Test
@MongoDBFixtures("collectorsMultipleDocuments.json")
public void testFindByIdNonexisting() throws Exception {
final String collector1id = "nonexisting";
final Sidecar sidecar = this.sidecarService.findByNodeId(collector1id);
assertNull(sidecar);
}
use of org.graylog.plugins.sidecar.rest.models.Sidecar in project graylog2-server by Graylog2.
the class SidecarResourceTest method testGet.
@Test
public void testGet() throws Exception {
final Sidecar sidecar = sidecars.get(sidecars.size() - 1);
when(sidecarService.findByNodeId(sidecar.nodeId())).thenReturn(sidecar);
final SidecarSummary sidecarSummary = mock(SidecarSummary.class);
when(sidecar.toSummary(any(ActiveSidecarFilter.class))).thenReturn(sidecarSummary);
final SidecarSummary response = this.resource.get(sidecar.nodeId());
assertNotNull(response);
assertEquals(sidecarSummary, response);
}
use of org.graylog.plugins.sidecar.rest.models.Sidecar in project graylog2-server by Graylog2.
the class SidecarResourceTest method getDummyCollector.
private Sidecar getDummyCollector(String id) {
final Sidecar sidecar = mock(Sidecar.class);
when(sidecar.nodeId()).thenReturn(id);
return sidecar;
}
Aggregations