.thenReturn((long) 1); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).singleResult(eq(MockProvider.NON_EXISTING_ID)); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).singleResult(eq(MockProvider.NON_EXISTING_ID), any(Query.class)); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).list(eq(MockProvider.NON_EXISTING_ID)); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).list(eq(MockProvider.NON_EXISTING_ID), any(Query.class)); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).listPage(eq(MockProvider.NON_EXISTING_ID), anyInt(), anyInt()); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).listPage(eq(MockProvider.NON_EXISTING_ID), any(Query.class), anyInt(), anyInt()); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).count(eq(MockProvider.NON_EXISTING_ID)); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).count(eq(MockProvider.NON_EXISTING_ID), any(Query.class)); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).deleteFilter(eq(MockProvider.NON_EXISTING_ID));
@Test public void testMessageCorrelationWithoutBusinessKey() { when(messageCorrelationBuilderMock.processInstanceBusinessKey(null)) .thenThrow(new NullValueException()); String messageName = "aMessageName"; Map<String, Object> messageParameters = new HashMap<String, Object>(); messageParameters.put("messageName", messageName); given() .contentType(POST_JSON_CONTENT_TYPE) .body(messageParameters) .then() .expect().statusCode(Status.NO_CONTENT.getStatusCode()) .when().post(MESSAGE_URL); verify(runtimeServiceMock).createMessageCorrelation(eq(messageName)); verify(messageCorrelationBuilderMock, Mockito.never()).processInstanceBusinessKey(anyString()); verify(messageCorrelationBuilderMock).correlateWithResult(); verifyNoMoreInteractions(messageCorrelationBuilderMock); }
@Test public void deleteNotExistingJob() { String jobId = MockProvider.NON_EXISTING_JOB_ID; String expectedMessage = "No job found with id '" + jobId + "'."; doThrow(new NullValueException(expectedMessage)) .when(mockManagementService).deleteJob(jobId); given() .pathParam("id", jobId) .then().expect() .statusCode(Status.NOT_FOUND.getStatusCode()) .body("type", equalTo(InvalidRequestException.class.getSimpleName())) .body("message", equalTo(expectedMessage)) .when() .delete(SINGLE_JOB_RESOURCE_URL); verify(mockManagementService).deleteJob(jobId); verifyNoMoreInteractions(mockManagementService); }
public class TypeSensor { public String inferType(String value) throws NullValueException { int formatIndex = -1; if (null == value) { throw new NullValueException("Value provided for type inference was null"); }else if (this.isIntegerType(value)) { return "Integer"; }else{ LOGGER.info("Value " + value + " doesnt fit to any predefined types. Defaulting to String."); return "String"; } } } private boolean isIntegerType(String value) { boolean isParseable = false; try { Integer.parseInt(value); LOGGER.info("Parsing successful for " + value + " to Integer."); isParseable = true; } catch (NumberFormatException e) { LOGGER.error("Value " + value + " doesn't seem to be of type Integer. This is not fatal. Exception message is->" + e.getMessage()); } return isParseable; } }