/** * This is useful for fluently combining matchers where either may pass, for example: * <pre> * assertThat(string, either(containsString("a")).or(containsString("b"))); * </pre> * * @deprecated Please use {@link CoreMatchers#either(Matcher)} instead. */ @Deprecated public static <T> CombinableEitherMatcher<T> either(Matcher<? super T> matcher) { return CoreMatchers.either(matcher); }
/** * This is useful for fluently combining matchers where either may pass, for example: * <pre> * assertThat(string, either(containsString("a")).or(containsString("b"))); * </pre> * * @deprecated Please use {@link CoreMatchers#either(Matcher)} instead. */ @Deprecated public static <T> CombinableEitherMatcher<T> either(Matcher<? super T> matcher) { return CoreMatchers.either(matcher); }
.map(msgId -> msgId.offset()) .collect(Collectors.toList()); assertThat("Expected the emitted messages to be retries of the failed tuples from the first batch, plus the first failed tuple from the second batch", thirdRunOffsets, everyItem(either(isIn(firstRunOffsets)).or(is(secondRunMessageIds.getAllValues().get(0).offset()))));
@Test public void testPositionalParameters() { TransactionUtil2.inTransaction( sessionFactory(), session -> { Query query = session.createQuery( "select i from Item i where name = ?1 or name = ?2" ); for ( Parameter<?> parameter : query.getParameters() ) { assertThat( parameter.getPosition(), notNullValue() ); assertThat( parameter.getPosition(), either( is(1) ).or( is(2) ) ); } } ); } }
@Factory public static Matcher<AspectRatio> closeToOrInverse(AspectRatio ratio) { return either(closeTo(ratio)).or(closeTo(ratio.inverse())); }
@Test public void shouldInitialiseUnderlyingImplementation() { final int initialCapacity = 10; final float loadFactor = 0.6f; final BiInt2ObjectMap<String> map = new BiInt2ObjectMap<>(initialCapacity, loadFactor); assertThat(map.capacity(), either(is(initialCapacity)).or(greaterThan(initialCapacity))); assertThat(map.loadFactor(), is(loadFactor)); }
/** * This is useful for fluently combining matchers where either may pass, for example: * <pre> * assertThat(string, either(containsString("a")).or(containsString("b"))); * </pre> * * @deprecated Please use {@link CoreMatchers#either(Matcher)} instead. */ @Deprecated public static <T> CombinableEitherMatcher<T> either(Matcher<? super T> matcher) { return CoreMatchers.either(matcher); }
.verify(); assertThat(onNextSignals.get(), CoreMatchers.either(equalTo(2)).or(equalTo(3)));
@Test public void requiredHistoryLevelOnClass() { assertThat(currentHistoryLevel(), CoreMatchers.<String>either(is(ProcessEngineConfiguration.HISTORY_AUDIT)) .or(is(ProcessEngineConfiguration.HISTORY_FULL))); }
@Test public void requiredHistoryLevelOnSuperClass() { assertThat(currentHistoryLevel(), CoreMatchers.<String>either(is(ProcessEngineConfiguration.HISTORY_AUDIT)) .or(is(ProcessEngineConfiguration.HISTORY_FULL))); }
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT) public void testRequiredHistoryLevelAudit() { assertThat(currentHistoryLevel(), CoreMatchers.<String>either(is(ProcessEngineConfiguration.HISTORY_AUDIT)) .or(is(ProcessEngineConfiguration.HISTORY_FULL))); }
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY) public void testRequiredHistoryLevelActivity() { assertThat(currentHistoryLevel(), CoreMatchers.<String>either(is(ProcessEngineConfiguration.HISTORY_ACTIVITY)) .or(is(ProcessEngineConfiguration.HISTORY_AUDIT)) .or(is(ProcessEngineConfiguration.HISTORY_FULL))); }
@Test @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT) public void requiredHistoryLevelAudit() { assertThat(currentHistoryLevel(), CoreMatchers.<String>either(is(ProcessEngineConfiguration.HISTORY_AUDIT)) .or(is(ProcessEngineConfiguration.HISTORY_FULL))); }
@Test @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY) public void overrideRequiredHistoryLevelOnClass() { assertThat(currentHistoryLevel(), CoreMatchers.<String>either(is(ProcessEngineConfiguration.HISTORY_ACTIVITY)) .or(is(ProcessEngineConfiguration.HISTORY_AUDIT)) .or(is(ProcessEngineConfiguration.HISTORY_FULL))); }
@Test @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY) public void requiredHistoryLevelActivity() { assertThat(currentHistoryLevel(), CoreMatchers.<String>either(is(ProcessEngineConfiguration.HISTORY_ACTIVITY)) .or(is(ProcessEngineConfiguration.HISTORY_AUDIT)) .or(is(ProcessEngineConfiguration.HISTORY_FULL))); }
@Ignore @Test public void testHistoryServiceEngineAccess_HistoricDetailBinaryFile() { HistoricDetailQuery query = mock(HistoricDetailQuery.class); HistoricVariableUpdate instance = mock(HistoricVariableUpdate.class); String filename = "test.txt"; byte[] byteContent = "test".getBytes(); String encoding = "UTF-8"; FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.toString()).encoding(encoding).create(); when(instance.getTypedValue()).thenReturn(variableValue); when(query.singleResult()).thenReturn(instance); when(mockHistoryService.createHistoricDetailQuery()).thenReturn(query); given() .pathParam("name", EXAMPLE_ENGINE_NAME) .then().expect() .statusCode(Status.OK.getStatusCode()) . body(is(equalTo(new String(byteContent)))) .and() .header("Content-Disposition", "attachment; filename="+filename) .contentType(CoreMatchers.<String>either(equalTo(ContentType.TEXT.toString() + ";charset=UTF-8")).or(equalTo(ContentType.TEXT.toString() + " ;charset=UTF-8"))) .when() .get(HISTORY_BINARY_DETAIL_URL); verify(mockHistoryService).createHistoricDetailQuery(); verifyZeroInteractions(processEngine); }
@Ignore @Test public void testHistoryServiceEngineAccess_HistoricVariableInstanceBinaryFile() { HistoricVariableInstanceQuery query = mock(HistoricVariableInstanceQuery.class); HistoricVariableInstance instance = mock(HistoricVariableInstance.class); String filename = "test.txt"; byte[] byteContent = "test".getBytes(); String encoding = "UTF-8"; FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.toString()).encoding(encoding).create(); when(instance.getTypedValue()).thenReturn(variableValue); when(query.singleResult()).thenReturn(instance); when(mockHistoryService.createHistoricVariableInstanceQuery()).thenReturn(query); given() .pathParam("name", EXAMPLE_ENGINE_NAME) .pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID) .then().expect() .statusCode(Status.OK.getStatusCode()) . body(is(equalTo(new String(byteContent)))) .and() .header("Content-Disposition", "attachment; filename="+filename) .contentType(CoreMatchers.<String>either(equalTo(ContentType.TEXT.toString() + ";charset=UTF-8")).or(equalTo(ContentType.TEXT.toString() + " ;charset=UTF-8"))) .when() .get(HISTORY_BINARY_VARIABLE_INSTANCE_URL); verify(mockHistoryService).createHistoricVariableInstanceQuery(); verifyZeroInteractions(processEngine); }
@Test public void testGetBinaryDataForFileVariable() { String filename = "test.txt"; byte[] byteContent = "test".getBytes(); String encoding = "UTF-8"; FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.toString()).encoding(encoding).create(); HistoricVariableInstance variableInstanceMock = MockProvider.mockHistoricVariableInstance().typedValue(variableValue).build(); when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock); Response response = given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID) .then().expect() .statusCode(Status.OK.getStatusCode()) .and() .body(is(equalTo(new String(byteContent)))) .header("Content-Disposition", "attachment; filename="+filename) .when().get(VARIABLE_INSTANCE_BINARY_DATA_URL); //due to some problems with wildfly we gotta check this separately String contentType = response.getContentType(); assertThat(contentType, is(either(CoreMatchers.<Object>equalTo(ContentType.TEXT.toString() + "; charset=UTF-8")).or(CoreMatchers.<Object>equalTo(ContentType.TEXT.toString() + ";charset=UTF-8")))); verify(variableInstanceQueryMock, never()).disableBinaryFetching(); }
@Test public void testBinaryDataForFileVariable() { String filename = "test.txt"; byte[] byteContent = "test".getBytes(); String encoding = "UTF-8"; FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.toString()).encoding(encoding).create(); MockHistoricVariableUpdateBuilder builder = MockProvider.mockHistoricVariableUpdate(); HistoricVariableUpdate detailMock = builder .typedValue(variableValue) .build(); when(historicDetailQueryMock.detailId(detailMock.getId())).thenReturn(historicDetailQueryMock); when(historicDetailQueryMock.disableCustomObjectDeserialization()).thenReturn(historicDetailQueryMock); when(historicDetailQueryMock.singleResult()).thenReturn(detailMock); Response response = given().pathParam("id", MockProvider.EXAMPLE_HISTORIC_VAR_UPDATE_ID) .then().expect() .statusCode(Status.OK.getStatusCode()) . body(is(equalTo(new String(byteContent)))) .and() .header("Content-Disposition", "attachment; filename="+filename) .when().get(VARIABLE_INSTANCE_BINARY_DATA_URL); //due to some problems with wildfly we gotta check this separately String contentType = response.getContentType(); assertThat(contentType, is(either(CoreMatchers.<Object>equalTo(ContentType.TEXT.toString() + "; charset=UTF-8")).or(CoreMatchers.<Object>equalTo(ContentType.TEXT.toString() + ";charset=UTF-8")))); verify(historicDetailQueryMock, never()).disableBinaryFetching(); }
@Deployment public void testParallelGatewayBeforeAndInSubProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); List<Task> tasks = taskService.createTaskQuery().list(); assertThat(tasks, hasSize(3)); ActivityInstance instance = runtimeService.getActivityInstance(processInstance.getId()); assertThat(instance.getActivityName(), is("Process1")); ActivityInstance[] childActivityInstances = instance.getChildActivityInstances(); for (ActivityInstance activityInstance : childActivityInstances) { if (activityInstance.getActivityId().equals("SubProcess_1")) { ActivityInstance[] instances = activityInstance.getChildActivityInstances(); for (ActivityInstance activityInstance2 : instances) { assertThat(activityInstance2.getActivityName(), is(either(equalTo("Inner User Task 1")).or(CoreMatchers.<Object>equalTo("Inner User Task 2")))); } } else { assertThat(activityInstance.getActivityName(), is("Outer User Task")); } } }