Search in sources :

Example 6 with LookupCoordinatorManager

use of io.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.

the class LookupCoordinatorResourceTest method testInvalidGetLookup.

@Test
public void testInvalidGetLookup() {
    final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
    EasyMock.replay(lookupCoordinatorManager);
    final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, mapper, mapper);
    Assert.assertEquals(400, lookupCoordinatorResource.getSpecificLookup("foo", null).getStatus());
    Assert.assertEquals(400, lookupCoordinatorResource.getSpecificLookup("foo", "").getStatus());
    Assert.assertEquals(400, lookupCoordinatorResource.getSpecificLookup("", "foo").getStatus());
    Assert.assertEquals(400, lookupCoordinatorResource.getSpecificLookup(null, "foo").getStatus());
    EasyMock.verify(lookupCoordinatorManager);
}
Also used : LookupCoordinatorManager(io.druid.server.lookup.cache.LookupCoordinatorManager) Test(org.junit.Test)

Example 7 with LookupCoordinatorManager

use of io.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.

the class LookupCoordinatorResourceTest method testNullLookupsGetTier.

@Test
public void testNullLookupsGetTier() {
    final String tier = "some tier";
    final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
    EasyMock.expect(lookupCoordinatorManager.getKnownLookups()).andReturn(null).once();
    EasyMock.replay(lookupCoordinatorManager);
    final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, mapper, mapper);
    final Response response = lookupCoordinatorResource.getSpecificTier(tier);
    Assert.assertEquals(404, response.getStatus());
    Assert.assertEquals(ImmutableMap.of("error", "No lookups found"), response.getEntity());
    EasyMock.verify(lookupCoordinatorManager);
}
Also used : Response(javax.ws.rs.core.Response) LookupCoordinatorManager(io.druid.server.lookup.cache.LookupCoordinatorManager) Test(org.junit.Test)

Example 8 with LookupCoordinatorManager

use of io.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.

the class LookupCoordinatorResourceTest method testSimpleDelete.

@Test
public void testSimpleDelete() {
    final String author = "some author";
    final String comment = "some comment";
    final String ip = "127.0.0.1";
    final HttpServletRequest request = EasyMock.createStrictMock(HttpServletRequest.class);
    EasyMock.expect(request.getRemoteAddr()).andReturn(ip).once();
    final Capture<AuditInfo> auditInfoCapture = Capture.newInstance();
    final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
    EasyMock.expect(lookupCoordinatorManager.deleteLookup(EasyMock.eq(LOOKUP_TIER), EasyMock.eq(LOOKUP_NAME), EasyMock.capture(auditInfoCapture))).andReturn(true).once();
    EasyMock.replay(lookupCoordinatorManager, request);
    final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, mapper, mapper);
    final Response response = lookupCoordinatorResource.deleteLookup(LOOKUP_TIER, LOOKUP_NAME, author, comment, request);
    Assert.assertEquals(202, response.getStatus());
    Assert.assertTrue(auditInfoCapture.hasCaptured());
    final AuditInfo auditInfo = auditInfoCapture.getValue();
    Assert.assertEquals(author, auditInfo.getAuthor());
    Assert.assertEquals(comment, auditInfo.getComment());
    Assert.assertEquals(ip, auditInfo.getIp());
    EasyMock.verify(lookupCoordinatorManager, request);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Response(javax.ws.rs.core.Response) LookupCoordinatorManager(io.druid.server.lookup.cache.LookupCoordinatorManager) AuditInfo(io.druid.audit.AuditInfo) Test(org.junit.Test)

Example 9 with LookupCoordinatorManager

use of io.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.

the class LookupCoordinatorResourceTest method testExceptionalDelete.

@Test
public void testExceptionalDelete() {
    final String author = "some author";
    final String comment = "some comment";
    final String ip = "127.0.0.1";
    final String errMsg = "some error";
    final HttpServletRequest request = EasyMock.createStrictMock(HttpServletRequest.class);
    EasyMock.expect(request.getRemoteAddr()).andReturn(ip).once();
    final Capture<AuditInfo> auditInfoCapture = Capture.newInstance();
    final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
    EasyMock.expect(lookupCoordinatorManager.deleteLookup(EasyMock.eq(LOOKUP_TIER), EasyMock.eq(LOOKUP_NAME), EasyMock.capture(auditInfoCapture))).andThrow(new RuntimeException(errMsg)).once();
    EasyMock.replay(lookupCoordinatorManager, request);
    final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, mapper, mapper);
    final Response response = lookupCoordinatorResource.deleteLookup(LOOKUP_TIER, LOOKUP_NAME, author, comment, request);
    Assert.assertEquals(500, response.getStatus());
    Assert.assertEquals(ImmutableMap.of("error", errMsg), response.getEntity());
    Assert.assertTrue(auditInfoCapture.hasCaptured());
    final AuditInfo auditInfo = auditInfoCapture.getValue();
    Assert.assertEquals(author, auditInfo.getAuthor());
    Assert.assertEquals(comment, auditInfo.getComment());
    Assert.assertEquals(ip, auditInfo.getIp());
    EasyMock.verify(lookupCoordinatorManager, request);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Response(javax.ws.rs.core.Response) LookupCoordinatorManager(io.druid.server.lookup.cache.LookupCoordinatorManager) AuditInfo(io.druid.audit.AuditInfo) Test(org.junit.Test)

Example 10 with LookupCoordinatorManager

use of io.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.

the class LookupCoordinatorResourceTest method testInvalidDelete.

@Test
public void testInvalidDelete() {
    final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
    EasyMock.replay(lookupCoordinatorManager);
    final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, mapper, mapper);
    Assert.assertEquals(400, lookupCoordinatorResource.deleteLookup("foo", null, null, null, null).getStatus());
    Assert.assertEquals(400, lookupCoordinatorResource.deleteLookup(null, null, null, null, null).getStatus());
    Assert.assertEquals(400, lookupCoordinatorResource.deleteLookup(null, "foo", null, null, null).getStatus());
    Assert.assertEquals(400, lookupCoordinatorResource.deleteLookup("foo", "", null, null, null).getStatus());
    Assert.assertEquals(400, lookupCoordinatorResource.deleteLookup("", "foo", null, null, null).getStatus());
    EasyMock.verify(lookupCoordinatorManager);
}
Also used : LookupCoordinatorManager(io.druid.server.lookup.cache.LookupCoordinatorManager) Test(org.junit.Test)

Aggregations

LookupCoordinatorManager (io.druid.server.lookup.cache.LookupCoordinatorManager)25 Test (org.junit.Test)25 Response (javax.ws.rs.core.Response)22 HttpServletRequest (javax.servlet.http.HttpServletRequest)10 AuditInfo (io.druid.audit.AuditInfo)9 HashMap (java.util.HashMap)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 Map (java.util.Map)3