Search in sources :

Example 11 with Sidecar

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());
}
Also used : Sidecar(org.graylog.plugins.sidecar.rest.models.Sidecar) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 12 with Sidecar

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"));
}
Also used : Document(org.bson.Document) Sidecar(org.graylog.plugins.sidecar.rest.models.Sidecar) Test(org.junit.Test)

Example 13 with Sidecar

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);
}
Also used : Sidecar(org.graylog.plugins.sidecar.rest.models.Sidecar) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 14 with 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);
}
Also used : SidecarSummary(org.graylog.plugins.sidecar.rest.models.SidecarSummary) ActiveSidecarFilter(org.graylog.plugins.sidecar.filter.ActiveSidecarFilter) Sidecar(org.graylog.plugins.sidecar.rest.models.Sidecar) RestResourceBaseTest(org.graylog.plugins.sidecar.collectors.rest.resources.RestResourceBaseTest) Test(org.junit.Test)

Example 15 with Sidecar

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;
}
Also used : Sidecar(org.graylog.plugins.sidecar.rest.models.Sidecar)

Aggregations

Sidecar (org.graylog.plugins.sidecar.rest.models.Sidecar)15 Timed (com.codahale.metrics.annotation.Timed)5 ApiOperation (io.swagger.annotations.ApiOperation)5 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)5 Path (javax.ws.rs.Path)4 SidecarSummary (org.graylog.plugins.sidecar.rest.models.SidecarSummary)4 Test (org.junit.Test)4 ApiResponses (io.swagger.annotations.ApiResponses)3 BadRequestException (javax.ws.rs.BadRequestException)3 GET (javax.ws.rs.GET)3 PUT (javax.ws.rs.PUT)3 Produces (javax.ws.rs.Produces)3 Response (javax.ws.rs.core.Response)3 ActiveSidecarFilter (org.graylog.plugins.sidecar.filter.ActiveSidecarFilter)3 CollectorAction (org.graylog.plugins.sidecar.rest.models.CollectorAction)3 CollectorActions (org.graylog.plugins.sidecar.rest.models.CollectorActions)3 Configuration (org.graylog.plugins.sidecar.rest.models.Configuration)3 ConfigurationAssignment (org.graylog.plugins.sidecar.rest.requests.ConfigurationAssignment)3 NoAuditEvent (org.graylog2.audit.jersey.NoAuditEvent)3 SearchQuery (org.graylog2.search.SearchQuery)3