@Test
public void testValidateResponse() throws Exception {

    RuleDatabaseItemUpdateRunnable itemUpdateRunnable = new RuleDatabaseItemUpdateRunnable(realTask, mockContext, mock(Configuration.Item.class));
    Resources resources = mock(Resources.class);
    when(mockContext.getResources()).thenReturn(resources);
    when(resources.getString(anyInt(), anyString(), anyInt(), anyString())).thenReturn("%s %s %s");
    when(connection.getResponseCode()).thenReturn(200);
    assertTrue("200 is OK", itemUpdateRunnable.validateResponse(connection));
    assertEquals(0, realTask.errors.size());
    when(connection.getResponseCode()).thenReturn(404);
    assertFalse("404 is not OK", itemUpdateRunnable.validateResponse(connection));
    assertEquals(1, realTask.errors.size());
    when(connection.getResponseCode()).thenReturn(304);
    assertFalse("304 is not OK", itemUpdateRunnable.validateResponse(connection));
    assertEquals(1, realTask.errors.size());
}