@Test public void resolveConfigAttributesWithConflictingLocations() { exception.expect(AnnotationConfigurationException.class); exception.expectMessage(containsString(ConflictingLocations.class.getName())); exception.expectMessage(either( containsString("attribute 'value' and its alias 'locations'")).or( containsString("attribute 'locations' and its alias 'value'"))); exception.expectMessage(either( containsString("values of [{x}] and [{y}]")).or( containsString("values of [{y}] and [{x}]"))); exception.expectMessage(containsString("but only one is permitted")); resolveContextConfigurationAttributes(ConflictingLocations.class); }
@Test public void synthesizeAnnotationWithAttributeAliasWithMirroredAliasForWrongAttribute() throws Exception { AliasForWithMirroredAliasForWrongAttribute annotation = AliasForWithMirroredAliasForWrongAttributeClass.class.getAnnotation(AliasForWithMirroredAliasForWrongAttribute.class); exception.expect(AnnotationConfigurationException.class); exception.expectMessage(startsWith("Attribute 'bar' in")); exception.expectMessage(containsString(AliasForWithMirroredAliasForWrongAttribute.class.getName())); exception.expectMessage(either(containsString("must be declared as an @AliasFor [foo], not [quux]")). or(containsString("is declared as an @AliasFor nonexistent attribute 'quux'"))); synthesizeAnnotation(annotation); }
@Test public void getMergedAnnotationAttributesWithInvalidConventionBasedComposedAnnotation() { Class<?> element = InvalidConventionBasedComposedContextConfigClass.class; exception.expect(AnnotationConfigurationException.class); exception.expectMessage(either(containsString("attribute 'value' and its alias 'locations'")).or( containsString("attribute 'locations' and its alias 'value'"))); exception.expectMessage(either( containsString("values of [{duplicateDeclaration}] and [{requiredLocationsDeclaration}]")).or( containsString("values of [{requiredLocationsDeclaration}] and [{duplicateDeclaration}]"))); exception.expectMessage(containsString("but only one is permitted")); getMergedAnnotationAttributes(element, ContextConfig.class); }
@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(); }
@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")); } } }
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT) public void testRequiredHistoryLevelAudit() { 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))); }
@Test public void testCancelTrueWithSleep() throws Exception { InterruptibleWithSleep interruptible = getInterruptibleWithSleep(); executor.execute(interruptible); interruptible.started.await(); interruptible.cancel(true); expectedException.expect(Matchers.<Throwable>either(instanceOf(CancellationException.class)) .or(Matchers.<Throwable>both(instanceOf(ExecutionException.class)) .and(ThrowableCauseMatcher.hasCause(instanceOf(InterruptedException.class))))); interruptible.get(); }
@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_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_AUDIT) public void requiredHistoryLevelAudit() { assertThat(currentHistoryLevel(), CoreMatchers.<String>either(is(ProcessEngineConfiguration.HISTORY_AUDIT)) .or(is(ProcessEngineConfiguration.HISTORY_FULL))); }
@Test public void requiredHistoryLevelOnClass() { assertThat(currentHistoryLevel(), CoreMatchers.<String>either(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))); }
.verify(); assertThat(onNextSignals.get(), CoreMatchers.either(equalTo(2)).or(equalTo(3)));
.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 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)); }
@Factory public static Matcher<AspectRatio> closeToOrInverse(AspectRatio ratio) { return either(closeTo(ratio)).or(closeTo(ratio.inverse())); }
@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) ) ); } } ); } }
@Test public void synthesizeAnnotationWithImplicitAliasesWithDuplicateValues() throws Exception { Class<?> clazz = ImplicitAliasesWithDuplicateValuesContextConfigClass.class; Class<ImplicitAliasesWithDuplicateValuesContextConfig> annotationType = ImplicitAliasesWithDuplicateValuesContextConfig.class; ImplicitAliasesWithDuplicateValuesContextConfig config = clazz.getAnnotation(annotationType); assertNotNull(config); ImplicitAliasesWithDuplicateValuesContextConfig synthesizedConfig = synthesizeAnnotation(config, clazz); assertNotNull(synthesizedConfig); exception.expect(AnnotationConfigurationException.class); exception.expectMessage(startsWith("In annotation")); exception.expectMessage(containsString(annotationType.getName())); exception.expectMessage(containsString("declared on class")); exception.expectMessage(containsString(clazz.getName())); exception.expectMessage(containsString("and synthesized from")); exception.expectMessage(either(containsString("attribute 'location1' and its alias 'location2'")).or( containsString("attribute 'location2' and its alias 'location1'"))); exception.expectMessage(either(containsString("are present with values of [1] and [2]")).or( containsString("are present with values of [2] and [1]"))); synthesizedConfig.location1(); }
@Test public void valueAndScriptsDeclared() throws Exception { Class<?> clazz = ValueAndScriptsDeclared.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("foo")); exception.expect(AnnotationConfigurationException.class); exception.expectMessage(either( containsString("attribute 'value' and its alias 'scripts'")).or( containsString("attribute 'scripts' and its alias 'value'"))); exception.expectMessage(either(containsString("values of [{foo}] and [{bar}]")).or( containsString("values of [{bar}] and [{foo}]"))); exception.expectMessage(containsString("but only one is permitted")); listener.beforeTestMethod(testContext); }