@Test public void testRequestWithSerializationException() throws IOException { FullHttpRequest request = createQueryRequest("?points=10&from=1&to=2"); ArgumentCaptor<FullHttpResponse> argument = ArgumentCaptor.forClass(FullHttpResponse.class); String message = "mock exception message"; when(serializer.transformRollupData(any(MetricData.class), anySet())).thenThrow(new SerializationException(message)); handler.handle(context, request); verify(channel).write(argument.capture()); String errorResponseBody = argument.getValue().content().toString(Charset.defaultCharset()); ErrorResponse errorResponse = getErrorResponse(errorResponseBody); assertEquals("Number of errors invalid", 1, errorResponse.getErrors().size()); assertEquals("Invalid error message", message, errorResponse.getErrors().get(0).getMessage()); assertEquals("Invalid tenant", TENANT, errorResponse.getErrors().get(0).getTenantId()); assertEquals("Invalid status", HttpResponseStatus.INTERNAL_SERVER_ERROR, argument.getValue().getStatus()); }
@Test public void testSetFalseToNull() throws Exception, UpdateException { set(1, 2, (Boolean) null); verify(analyzer, never()).update(anySet()); }
@Test public void testSetNullToFalse() throws Exception, UpdateException { set(2, 2, false); verify(analyzer, never()).update(anySet()); }
@Test public void testDoNotUpdateConditionWhenValueDidNotChange() throws Exception, UpdateException { ArrayList<Coordinate> coordinates = new ArrayList<Coordinate>(); coordinates.add(new Coordinate(1, 2)); updateManager.update(table52, coordinates); verify(analyzer, never()).update(anySet()); }
@Test public void testTrueDidNotChange() throws Exception, UpdateException { ArrayList<Coordinate> coordinates = new ArrayList<>(); coordinates.add(new Coordinate(0, 2)); updateManager.update(table52, coordinates); verify(analyzer, never()).update(anySet()); }
@Test public void testDoNotUpdateActionWhenValueDidNotChange() throws Exception, UpdateException { ArrayList<Coordinate> coordinates = new ArrayList<Coordinate>(); coordinates.add(new Coordinate(0, 3)); updateManager.update(table52, coordinates); verify(analyzer, never()).update(anySet()); }
@Test public void testDoNotUpdateActionWhenValueDidNotChange() throws Exception, UpdateException { ArrayList<Coordinate> coordinates = new ArrayList<Coordinate>(); coordinates.add(new Coordinate(0, 3)); updateManager.update(table52, coordinates); verify(analyzer, never()).update(anySet()); }
@Test public void testTrueDidNotChange() throws Exception, UpdateException { ArrayList<Coordinate> coordinates = new ArrayList<>(); coordinates.add(new Coordinate(0, 2)); updateManager.update(table52, coordinates); verify(analyzer, never()).update(anySet()); }
@Test public void testNullDidNotChange() throws Exception, UpdateException { ArrayList<Coordinate> coordinates = new ArrayList<>(); coordinates.add(new Coordinate(2, 2)); updateManager.update(table52, coordinates); verify(analyzer, never()).update(anySet()); }
@Test public void testDoNotUpdateConditionWhenValueDidNotChange() throws Exception, UpdateException { ArrayList<Coordinate> coordinates = new ArrayList<Coordinate>(); coordinates.add(new Coordinate(1, 2)); updateManager.update(table52, coordinates); verify(analyzer, never()).update(anySet()); }
@Test public void testDoNotUpdateActionWhenValueDidNotChange() throws Exception, UpdateException { ArrayList<Coordinate> coordinates = new ArrayList<Coordinate>(); coordinates.add(new Coordinate(0, 3)); updateManager.update(table52, coordinates); verify(analyzer, never()).update(anySet()); }
@Test public void testSetFalseToNull() throws Exception, UpdateException { set(1, 2, (Boolean) null); verify(analyzer, never()).update(anySet()); }
@Test public void testFalseDidNotChange() throws Exception, UpdateException { ArrayList<Coordinate> coordinates = new ArrayList<>(); coordinates.add(new Coordinate(1, 2)); updateManager.update(table52, coordinates); verify(analyzer, never()).update(anySet()); }
@Test public void testSetNullToTrue() throws Exception, UpdateException { set(2, 2, true); verify(analyzer).update(anySet()); }
@Test public void testSetFalseToTrue() throws Exception, UpdateException { set(1, 2, true); verify(analyzer).update(anySet()); }
@Test public void testSetTrueToNull() throws Exception, UpdateException { set(0, 2, (Boolean) null); verify(analyzer).update(anySet()); }
@Test public void testSetTrueToFalse() throws Exception, UpdateException { set(0, 2, false); verify(analyzer).update(anySet()); }
@Test public void testSetNullToTrue() throws Exception, UpdateException { set(2, 2, true); verify(analyzer).update(anySet()); }
@Test public void testSetFalseToTrue() throws Exception, UpdateException { set(1, 2, true); verify(analyzer).update(anySet()); }
@Test public void testSetTrueToFalse() throws Exception, UpdateException { set(0, 2, false); verify(analyzer).update(anySet()); }