/** * Creates a matcher for {@link Iterable}s that only matches when a single pass over the * examined {@link Iterable} yields items that are all matched by the specified * <code>itemMatcher</code>. * <p/> * For example: * <pre>assertThat(Arrays.asList("bar", "baz"), everyItem(startsWith("ba")))</pre> * * @param itemMatcher * the matcher to apply to every item provided by the examined {@link Iterable} */ public static <U> org.hamcrest.Matcher<java.lang.Iterable<U>> everyItem(org.hamcrest.Matcher<U> itemMatcher) { return org.hamcrest.core.Every.<U>everyItem(itemMatcher); }
/** * Creates a matcher for {@link Iterable}s that only matches when a single pass over the * examined {@link Iterable} yields items that are all matched by the specified * <code>itemMatcher</code>. * <p/> * For example: * <pre>assertThat(Arrays.asList("bar", "baz"), everyItem(startsWith("ba")))</pre> * * @param itemMatcher * the matcher to apply to every item provided by the examined {@link Iterable} */ public static <U> org.hamcrest.Matcher<java.lang.Iterable<U>> everyItem(org.hamcrest.Matcher<U> itemMatcher) { return org.hamcrest.core.Every.<U>everyItem(itemMatcher); }
/** * Creates a matcher for {@link Iterable}s that only matches when a single pass over the * examined {@link Iterable} yields items that are all matched by the specified * <code>itemMatcher</code>. * <p/> * For example: * <pre>assertThat(Arrays.asList("bar", "baz"), everyItem(startsWith("ba")))</pre> * * @param itemMatcher * the matcher to apply to every item provided by the examined {@link Iterable} */ public static <U> org.hamcrest.Matcher<java.lang.Iterable<U>> everyItem(org.hamcrest.Matcher<U> itemMatcher) { return org.hamcrest.core.Every.<U>everyItem(itemMatcher); }
/** * Creates a matcher for {@link Iterable}s that only matches when a single pass over the * examined {@link Iterable} yields items that are all matched by the specified * <code>itemMatcher</code>. * For example: * <pre>assertThat(Arrays.asList("bar", "baz"), everyItem(startsWith("ba")))</pre> * * @param itemMatcher * the matcher to apply to every item provided by the examined {@link Iterable} */ public static <U> org.hamcrest.Matcher<java.lang.Iterable<? extends U>> everyItem(org.hamcrest.Matcher<U> itemMatcher) { return org.hamcrest.core.Every.everyItem(itemMatcher); }
/** * Creates a matcher for {@link Iterable}s that only matches when a single pass over the * examined {@link Iterable} yields items that are all matched by the specified * <code>itemMatcher</code>. * For example: * <pre>assertThat(Arrays.asList("bar", "baz"), everyItem(startsWith("ba")))</pre> * * @param itemMatcher * the matcher to apply to every item provided by the examined {@link Iterable} */ public static <U> org.hamcrest.Matcher<java.lang.Iterable<? extends U>> everyItem(org.hamcrest.Matcher<U> itemMatcher) { return org.hamcrest.core.Every.everyItem(itemMatcher); }
/** * Creates a matcher for {@link Iterable}s that only matches when a single pass over the * examined {@link Iterable} yields items that are all matched by the specified * <code>itemMatcher</code>. * <p/> * For example: * <pre>assertThat(Arrays.asList("bar", "baz"), everyItem(startsWith("ba")))</pre> * * @param itemMatcher * the matcher to apply to every item provided by the examined {@link Iterable} */ public static <U> org.hamcrest.Matcher<java.lang.Iterable<U>> everyItem(org.hamcrest.Matcher<U> itemMatcher) { return org.hamcrest.core.Every.<U>everyItem(itemMatcher); }
/** * Creates a matcher for {@link Iterable}s that only matches when a single pass over the * examined {@link Iterable} yields items that are all matched by the specified * <code>itemMatcher</code>. * For example: * <pre>assertThat(Arrays.asList("bar", "baz"), everyItem(startsWith("ba")))</pre> * * @param itemMatcher * the matcher to apply to every item provided by the examined {@link Iterable} */ public static <U> org.hamcrest.Matcher<java.lang.Iterable<? extends U>> everyItem(org.hamcrest.Matcher<U> itemMatcher) { return org.hamcrest.core.Every.everyItem(itemMatcher); }
/** * Creates a matcher for {@link Iterable}s that only matches when a single pass over the * examined {@link Iterable} yields items that are all matched by the specified * <code>itemMatcher</code>. * For example: * <pre>assertThat(Arrays.asList("bar", "baz"), everyItem(startsWith("ba")))</pre> * * @param itemMatcher * the matcher to apply to every item provided by the examined {@link Iterable} */ public static <U> org.hamcrest.Matcher<java.lang.Iterable<? extends U>> everyItem(org.hamcrest.Matcher<U> itemMatcher) { return org.hamcrest.core.Every.<U>everyItem(itemMatcher); }
@Test public void retryPolicyExhaustedDueToInvalidConnectionExecutingOperation() throws Exception { flowRunner("fail-operation-with-connection-exception") .runExpectingException(errorType("PETSTORE", CONNECTIVITY_ERROR_IDENTIFIER)); assertThat(getConnectionThreads(), hasSize(3)); assertThat(getConnectionThreads().stream().map(t -> t.getThreadGroup()).collect(toSet()), everyItem(sameInstance(UNIT_TEST_THREAD_GROUP))); }
@Test public void retryPolicyExhaustedDueToInvalidConnectionExecutingOperationTxFlow() throws Exception { transaction = createTransactionMock(); flowRunner("fail-operation-with-connection-exception") .transactionally(ACTION_ALWAYS_BEGIN, new TestTransactionFactory(transaction)) .runExpectingException(errorType("PETSTORE", CONNECTIVITY_ERROR_IDENTIFIER)); assertThat(getConnectionThreads(), hasSize(3)); Set<ThreadGroup> connectionThreadsSet = getConnectionThreads().stream().map(t -> t.getThreadGroup()).collect(toSet()); assertThat("Transactional retry must not change threads", connectionThreadsSet, hasSize(1)); assertThat(connectionThreadsSet, everyItem(sameInstance(currentThread().getThreadGroup()))); }
@Test public void retryPolicyExhaustedDueToInvalidConnectionAtValidateTime() throws Exception { flowRunner("fail-connection-validation").runExpectingException(errorType("PETSTORE", CONNECTIVITY_ERROR_IDENTIFIER)); assertThat(getConnectionThreads(), hasSize(3)); assertThat(getConnectionThreads().stream().map(t -> t.getThreadGroup()).collect(toSet()), everyItem(sameInstance(UNIT_TEST_THREAD_GROUP))); }
@Test public void retryPolicyExhaustedDueToInvalidConnectionExecutingOperationTxOperation() throws Exception { flowRunner("fail-operation-with-connection-exception-tx") .runExpectingException(errorType("PETSTORE", CONNECTIVITY_ERROR_IDENTIFIER)); assertThat(getConnectionThreads(), hasSize(3)); Set<ThreadGroup> connectionThreadsSet = getConnectionThreads().stream().map(t -> t.getThreadGroup()).collect(toSet()); assertThat("Transactional retry must not change threads", connectionThreadsSet, hasSize(1)); assertThat(connectionThreadsSet, everyItem(sameInstance(UNIT_TEST_THREAD_GROUP))); }
@Test public void retryPolicyExhaustedDueToInvalidConnectionAtValidateTimeTxOperation() throws Exception { flowRunner("fail-connection-validation-tx").runExpectingException(errorType("PETSTORE", CONNECTIVITY_ERROR_IDENTIFIER)); assertThat(getConnectionThreads(), hasSize(3)); Set<ThreadGroup> connectionThreadsSet = getConnectionThreads().stream().map(t -> t.getThreadGroup()).collect(toSet()); assertThat("Transactional retry must not change threads", connectionThreadsSet, hasSize(1)); assertThat(connectionThreadsSet, everyItem(sameInstance(UNIT_TEST_THREAD_GROUP))); }
@Test public void retryPolicyExhaustedDueToInvalidConnectionAtValidateTimeTxFlow() throws Exception { transaction = createTransactionMock(); flowRunner("fail-connection-validation").transactionally(ACTION_ALWAYS_BEGIN, new TestTransactionFactory(transaction)) .runExpectingException(errorType("PETSTORE", CONNECTIVITY_ERROR_IDENTIFIER)); assertThat(getConnectionThreads(), hasSize(3)); Set<ThreadGroup> connectionThreadsSet = getConnectionThreads().stream().map(t -> t.getThreadGroup()).collect(toSet()); assertThat("Transactional retry must not change threads", connectionThreadsSet, hasSize(1)); assertThat(connectionThreadsSet, everyItem(sameInstance(currentThread().getThreadGroup()))); }
@Test public void badFieldTypeReferenceReported() { //GIVEN doReturn(Optional.empty()).when(fieldTypeDefinitionRegistry).getByDefinitionType(any(Class.class)); //WHEN Collection<DefinitionProvider.Problem> problems = validator.validate(provider); //THEN assertThat(problems, hasSize(1)); assertThat(problems, everyItem(problem().withTitle(is("No field type definition found")))); }
@Test public void reportsMissingFieldTypeDefinition() { //GIVEN doReturn(Optional.empty()).when(fieldTypeDefinitionRegistry).getByDefinitionType(any(Class.class)); //WHEN Collection<DefinitionProvider.Problem> problems = validator.validate(provider); //THEN assertThat(problems, hasSize(1)); assertThat(problems, everyItem(problem().withTitle(is("No field type definition found")))); } }
@Test public void reportsMissingFieldTypeDefinition() { //GIVEN doReturn(Optional.empty()).when(fieldTypeDefinitionRegistry).getByDefinitionType(any(Class.class)); //WHEN Collection<DefinitionProvider.Problem> problems = validator.validate(provider); //THEN assertThat(problems, hasSize(1)); assertThat(problems, everyItem(problem().withTitle(is("No field type definition found")))); }
@Test public void shouldNotPrepareFilesToStageWhenFlinkMasterIsSetToLocal() throws IOException { FlinkPipelineOptions options = testPreparingResourcesToStage("[local]"); assertThat(options.getFilesToStage().size(), is(2)); assertThat(options.getFilesToStage(), everyItem(not(matches(".*\\.jar")))); }
@Test public void shouldNotPrepareFilesToStageWhenFlinkMasterIsSetToLocal() throws IOException { FlinkPipelineOptions options = testPreparingResourcesToStage("[local]"); assertThat(options.getFilesToStage().size(), is(2)); assertThat(options.getFilesToStage(), everyItem(not(matches(".*\\.jar")))); }