UploadHandler extends BaseHandler implements BackgroundTaskHandler { public boolean shouldDelete(int statusCode) { return statusCode != HTTP_TOO_MANY_REQUESTS && (200 == statusCode || 202 == statusCode || (statusCode >= 400 && statusCode < 500)); } UploadHandler(Context context, ConfigManager configManager, AppStateManager appStateManager, MessageManager messageManager, MParticleDBManager mparticleDBManager);  UploadHandler(Context context, Looper looper, ConfigManager configManager, AppStateManager appStateManager, MessageManager messageManager, MParticleDBManager mparticleDBManager); @Override void handleMessageImpl(Message msg); boolean shouldDelete(int statusCode); void setConnected(boolean connected); void fetchSegments(long timeout, String endpointId, SegmentListener listener); @Override void executeNetworkRequest(Runnable runnable); static final int UPLOAD_MESSAGES; static final int UPLOAD_HISTORY; static final int UPDATE_CONFIG; static final int UPLOAD_TRIGGER_MESSAGES; static final int INIT_CONFIG; }
@Test public void testShouldDelete() throws Exception { for (int i = 0 ; i < 202; i++){ if (i != 200) { assertFalse(handler.shouldDelete(i)); } } assertTrue(handler.shouldDelete(200)); assertTrue(handler.shouldDelete(202)); for (int i = 203 ; i < 400; i++){ assertFalse(handler.shouldDelete(i)); } for (int i = 400 ; i < 429; i++){ assertTrue(handler.shouldDelete(i)); } assertFalse(handler.shouldDelete(429)); for (int i = 430 ; i < 500; i++){ assertTrue(handler.shouldDelete(i)); } for (int i = 500 ; i < 600; i++){ assertFalse(handler.shouldDelete(i)); } }