public static ClientResponse mockEntityClientResponse( TimelineWriter spyTimelineWriter, ClientResponse.Status status, boolean hasError, boolean hasRuntimeError) { ClientResponse response = mock(ClientResponse.class); if (hasRuntimeError) { doThrow(new ClientHandlerException(new ConnectException())).when( spyTimelineWriter).doPostingObject( any(TimelineEntities.class), any(String.class)); return response; } doReturn(response).when(spyTimelineWriter) .doPostingObject(any(TimelineEntities.class), any(String.class)); when(response.getClientResponseStatus()).thenReturn(status); TimelinePutResponse.TimelinePutError error = new TimelinePutResponse.TimelinePutError(); error.setEntityId("test entity id"); error.setEntityType("test entity type"); error.setErrorCode(TimelinePutResponse.TimelinePutError.IO_EXCEPTION); TimelinePutResponse putResponse = new TimelinePutResponse(); if (hasError) { putResponse.addError(error); } when(response.getEntity(TimelinePutResponse.class)).thenReturn(putResponse); return response; }
public static ClientResponse mockEntityClientResponse( TimelineWriter spyTimelineWriter, ClientResponse.Status status, boolean hasError, boolean hasRuntimeError) { ClientResponse response = mock(ClientResponse.class); if (hasRuntimeError) { doThrow(new ClientHandlerException(new ConnectException())).when( spyTimelineWriter).doPostingObject( any(TimelineEntities.class), any(String.class)); return response; } doReturn(response).when(spyTimelineWriter) .doPostingObject(any(TimelineEntities.class), any(String.class)); when(response.getStatusInfo()).thenReturn(status); TimelinePutResponse.TimelinePutError error = new TimelinePutResponse.TimelinePutError(); error.setEntityId("test entity id"); error.setEntityType("test entity type"); error.setErrorCode(TimelinePutResponse.TimelinePutError.IO_EXCEPTION); TimelinePutResponse putResponse = new TimelinePutResponse(); if (hasError) { putResponse.addError(error); } when(response.getEntity(TimelinePutResponse.class)).thenReturn(putResponse); return response; }
private static ClientResponse mockEntityClientResponse( TimelineClientImpl client, ClientResponse.Status status, boolean hasError, boolean hasRuntimeError) { ClientResponse response = mock(ClientResponse.class); if (hasRuntimeError) { doThrow(new ClientHandlerException(new ConnectException())).when(client) .doPostingObject(any(TimelineEntities.class), any(String.class)); return response; } doReturn(response).when(client) .doPostingObject(any(TimelineEntities.class), any(String.class)); when(response.getClientResponseStatus()).thenReturn(status); TimelinePutResponse.TimelinePutError error = new TimelinePutResponse.TimelinePutError(); error.setEntityId("test entity id"); error.setEntityType("test entity type"); error.setErrorCode(TimelinePutResponse.TimelinePutError.IO_EXCEPTION); TimelinePutResponse putResponse = new TimelinePutResponse(); if (hasError) { putResponse.addError(error); } when(response.getEntity(TimelinePutResponse.class)).thenReturn(putResponse); return response; }
error.setEntityType(entity.getEntityType()); error.setErrorCode(TimelinePutError.NO_START_TIME); response.addError(error); TimelinePutError error = new TimelinePutError(); error.setEntityId(entity.getEntityId()); error.setEntityType(entity.getEntityType()); error.setErrorCode(TimelinePutError.NO_DOMAIN); response.addError(error); error.setEntityType(entity.getEntityType()); error.setErrorCode(TimelinePutError.EXPIRED_ENTITY); response.addError(error); error.setEntityType(entity.getEntityType()); error.setErrorCode(TimelinePutError.EXPIRED_ENTITY); response.addError(error); error.setEntityType(entity.getEntityType()); error.setErrorCode(TimelinePutError.FORBIDDEN_RELATION); response.addError(error); error.setEntityType(entity.getEntityType()); error.setErrorCode(TimelinePutError.EXPIRED_ENTITY); response.addError(error); TimelinePutError error = new TimelinePutError(); error.setEntityId(entity.getEntityId()); error.setEntityType(entity.getEntityType());
TimelinePutError error = new TimelinePutError(); error.setEntityId(entityId.getId()); error.setEntityType(entityId.getType()); error.setErrorCode(TimelinePutError.NO_DOMAIN); response.addError(error); TimelinePutError error = new TimelinePutError(); error.setEntityId(entityId.getId()); error.setEntityType(entityId.getType()); error.setErrorCode(TimelinePutError.NO_START_TIME); response.addError(error); error.setEntityType(existingEntity.getEntityType()); error.setEntityId(existingEntity.getEntityId()); error.setErrorCode(TimelinePutError.FORBIDDEN_RELATION);
TimelinePutError error = new TimelinePutError(); error.setEntityId(entityId.getId()); error.setEntityType(entityId.getType()); error.setErrorCode(TimelinePutError.NO_DOMAIN); response.addError(error); TimelinePutError error = new TimelinePutError(); error.setEntityId(entityId.getId()); error.setEntityType(entityId.getType()); error.setErrorCode(TimelinePutError.NO_START_TIME); response.addError(error); error.setEntityType(existingEntity.getEntityType()); error.setEntityId(existingEntity.getEntityId()); error.setErrorCode(TimelinePutError.FORBIDDEN_RELATION);
TimelinePutError error = new TimelinePutError(); error.setEntityId(entityId.getId()); error.setEntityType(entityId.getType()); error.setErrorCode(TimelinePutError.NO_DOMAIN); response.addError(error); TimelinePutError error = new TimelinePutError(); error.setEntityId(entityId.getId()); error.setEntityType(entityId.getType()); error.setErrorCode(TimelinePutError.NO_START_TIME); response.addError(error); error.setEntityType(existingEntity.getEntityType()); error.setEntityId(existingEntity.getEntityId()); error.setErrorCode(TimelinePutError.FORBIDDEN_RELATION);
new TimelinePutResponse.TimelinePutError(); error.setEntityId(entityID.getId()); error.setEntityType(entityID.getType()); error.setErrorCode( TimelinePutResponse.TimelinePutError.ACCESS_DENIED);
new TimelinePutResponse.TimelinePutError(); error.setEntityId(entityID.getId()); error.setEntityType(entityID.getType()); error.setErrorCode( TimelinePutResponse.TimelinePutError.ACCESS_DENIED);
new TimelinePutResponse.TimelinePutError(); error.setEntityId(entity.getEntityId()); error.setEntityType(entity.getEntityType()); error.setErrorCode( TimelinePutResponse.TimelinePutError.ACCESS_DENIED);
/** * Handle error and set it in response. */ private static void handleError(TimelineEntity entity, TimelinePutResponse response, final int errorCode) { TimelinePutError error = new TimelinePutError(); error.setEntityId(entity.getEntityId()); error.setEntityType(entity.getEntityType()); error.setErrorCode(errorCode); response.addError(error); }
/** * Handle error and set it in response. */ private static void handleError(TimelineEntity entity, TimelinePutResponse response, final int errorCode) { TimelinePutError error = new TimelinePutError(); error.setEntityId(entity.getEntityId()); error.setEntityType(entity.getEntityType()); error.setErrorCode(errorCode); response.addError(error); }
/** * Handle error and set it in response. */ private static void handleError(TimelineEntity entity, TimelinePutResponse response, final int errorCode) { TimelinePutError error = new TimelinePutError(); error.setEntityId(entity.getEntityId()); error.setEntityType(entity.getEntityType()); error.setErrorCode(errorCode); response.addError(error); }