Search in sources :

Example 6 with StringStartsWith

use of org.hamcrest.core.StringStartsWith in project flink by apache.

the class DataStreamTest method testKeyRejection.

private <K> void testKeyRejection(KeySelector<Tuple2<Integer[], String>, K> keySelector, TypeInformation<K> expectedKeyType) {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    DataStream<Tuple2<Integer[], String>> input = env.fromElements(new Tuple2<>(new Integer[] { 1, 2 }, "barfoo"));
    Assert.assertEquals(expectedKeyType, TypeExtractor.getKeySelectorTypes(keySelector, input.getType()));
    // adjust the rule
    expectedException.expect(InvalidProgramException.class);
    expectedException.expectMessage(new StringStartsWith("Type " + expectedKeyType + " cannot be used as key."));
    input.keyBy(keySelector);
}
Also used : StringStartsWith(org.hamcrest.core.StringStartsWith) Tuple2(org.apache.flink.api.java.tuple.Tuple2) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)

Example 7 with StringStartsWith

use of org.hamcrest.core.StringStartsWith in project jbosstools-openshift by jbosstools.

the class LogsTest method shouldShowLogFromApplicationPodContextMenu.

@Test
public void shouldShowLogFromApplicationPodContextMenu() {
    new WaitUntil(new OpenShiftResourceExists(Resource.POD, new StringStartsWith("eap-app-"), ResourceState.RUNNING, requiredProject.getProjectName(), requiredConnection.getConnection()), TimePeriod.VERY_LONG);
    this.consoleView = new ConsoleView();
    this.consoleView.open();
    OpenShiftResource pod = OpenShiftUtils.getOpenShiftPod(requiredProject.getProjectName(), new StringStartsWith("eap-app-"), requiredConnection.getConnection());
    String podName = pod.getName();
    pod.select();
    new ContextMenuItem(OpenShiftLabel.ContextMenu.POD_LOG).select();
    new WaitUntil(new ConsoleHasText(), TimePeriod.DEFAULT);
    new WaitUntil(new ConsoleHasNoChange(TimePeriod.getCustom(WAIT_CONSOLE_NO_CHANGE)), TimePeriod.VERY_LONG);
    assertTrue("Console label is incorrect, it should contains project name and pod name.\n" + "but label is: " + consoleView.getConsoleLabel(), consoleView.getConsoleLabel().contains(requiredProject.getProjectName() + "\\" + podName));
    assertTrue("Console text should contain output from EAP runtime", consoleView.getConsoleText().contains("Admin console is not enabled"));
}
Also used : StringStartsWith(org.hamcrest.core.StringStartsWith) ConsoleView(org.eclipse.reddeer.eclipse.ui.console.ConsoleView) ContextMenuItem(org.eclipse.reddeer.swt.impl.menu.ContextMenuItem) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) ConsoleHasText(org.eclipse.reddeer.eclipse.condition.ConsoleHasText) OpenShiftResourceExists(org.jboss.tools.openshift.reddeer.condition.OpenShiftResourceExists) ConsoleHasNoChange(org.eclipse.reddeer.eclipse.condition.ConsoleHasNoChange) OpenShiftResource(org.jboss.tools.openshift.reddeer.view.resources.OpenShiftResource) AbstractTest(org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest) Test(org.junit.Test)

Example 8 with StringStartsWith

use of org.hamcrest.core.StringStartsWith in project jbosstools-openshift by jbosstools.

the class LogsTest method shouldShowLogFromBuildPodContextMenu.

@Test
public void shouldShowLogFromBuildPodContextMenu() {
    new WaitUntil(new OpenShiftResourceExists(Resource.BUILD, new StringStartsWith("eap-app-"), ResourceState.RUNNING, requiredProject.getProjectName(), requiredConnection.getConnection()), TimePeriod.VERY_LONG);
    this.consoleView = new ConsoleView();
    this.consoleView.open();
    OpenShiftResource pod = OpenShiftUtils.getOpenShiftPod(requiredProject.getProjectName(), Resource.BUILD, new StringStartsWith("eap-app-"), requiredConnection.getConnection());
    String podName = pod.getName();
    pod.select();
    new ContextMenuItem(OpenShiftLabel.ContextMenu.BUILD_LOG).select();
    new WaitUntil(new ConsoleHasText(), TimePeriod.LONG);
    new WaitUntil(new ConsoleHasNoChange(TimePeriod.getCustom(WAIT_CONSOLE_NO_CHANGE)), TimePeriod.VERY_LONG);
    assertTrue("Console label is incorrect, it should contain project name and name of build pod.\n" + "but label is: " + consoleView.getConsoleLabel(), consoleView.getConsoleLabel().contains(requiredProject.getProjectName() + "\\" + podName));
    try {
        new WaitUntil(new ConsoleHasText("Push successful"), TimePeriod.getCustom(WAIT_CONSOLE_PUSH_SUCCESS));
    } catch (WaitTimeoutExpiredException ex) {
        fail("There should be output of succesful build in console log, but there is not.\n" + "Check whether output has not changed. Assumed output in the end of log is 'Push successful'");
    }
}
Also used : StringStartsWith(org.hamcrest.core.StringStartsWith) ConsoleView(org.eclipse.reddeer.eclipse.ui.console.ConsoleView) ContextMenuItem(org.eclipse.reddeer.swt.impl.menu.ContextMenuItem) WaitTimeoutExpiredException(org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) ConsoleHasText(org.eclipse.reddeer.eclipse.condition.ConsoleHasText) OpenShiftResourceExists(org.jboss.tools.openshift.reddeer.condition.OpenShiftResourceExists) ConsoleHasNoChange(org.eclipse.reddeer.eclipse.condition.ConsoleHasNoChange) OpenShiftResource(org.jboss.tools.openshift.reddeer.view.resources.OpenShiftResource) AbstractTest(org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest) Test(org.junit.Test)

Example 9 with StringStartsWith

use of org.hamcrest.core.StringStartsWith in project flink by apache.

the class DataStreamTest method testTupleNestedArrayKeyRejection.

// //////////////			Composite Key Tests : Tuples			////////////////
@Test
public void testTupleNestedArrayKeyRejection() {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    DataStream<Tuple2<Integer[], String>> input = env.fromElements(new Tuple2<>(new Integer[] { 1, 2 }, "test-test"));
    TypeInformation<?> expectedTypeInfo = new TupleTypeInfo<Tuple2<Integer[], String>>(BasicArrayTypeInfo.INT_ARRAY_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO);
    // adjust the rule
    expectedException.expect(InvalidProgramException.class);
    expectedException.expectMessage(new StringStartsWith("Type " + expectedTypeInfo + " cannot be used as key."));
    input.keyBy(new KeySelector<Tuple2<Integer[], String>, Tuple2<Integer[], String>>() {

        @Override
        public Tuple2<Integer[], String> getKey(Tuple2<Integer[], String> value) throws Exception {
            return value;
        }
    });
}
Also used : StringStartsWith(org.hamcrest.core.StringStartsWith) TupleTypeInfo(org.apache.flink.api.java.typeutils.TupleTypeInfo) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) ExpectedException(org.junit.rules.ExpectedException) Tuple2(org.apache.flink.api.java.tuple.Tuple2) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) Test(org.junit.Test)

Example 10 with StringStartsWith

use of org.hamcrest.core.StringStartsWith in project flink by apache.

the class DataStreamTest method assertArrayKeyRejection.

private <K> void assertArrayKeyRejection(KeySelector<Tuple2<Integer[], String>, K> keySelector, TypeInformation<K> expectedKeyType) {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    DataStream<Tuple2<Integer[], String>> input = env.fromElements(new Tuple2<>(new Integer[] { 1, 2 }, "barfoo"));
    Assert.assertEquals(expectedKeyType, TypeExtractor.getKeySelectorTypes(keySelector, input.getType()));
    // adjust the rule
    expectedException.expect(InvalidProgramException.class);
    expectedException.expectMessage(new StringStartsWith("Type " + expectedKeyType + " cannot be used as key."));
    input.keyBy(keySelector);
}
Also used : StringStartsWith(org.hamcrest.core.StringStartsWith) Tuple2(org.apache.flink.api.java.tuple.Tuple2) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)

Aggregations

StringStartsWith (org.hamcrest.core.StringStartsWith)11 Test (org.junit.Test)8 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)5 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)4 TupleTypeInfo (org.apache.flink.api.java.typeutils.TupleTypeInfo)3 WaitUntil (org.eclipse.reddeer.common.wait.WaitUntil)3 OpenShiftResourceExists (org.jboss.tools.openshift.reddeer.condition.OpenShiftResourceExists)3 OpenShiftResource (org.jboss.tools.openshift.reddeer.view.resources.OpenShiftResource)3 AbstractTest (org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest)3 InvalidProgramException (org.apache.flink.api.common.InvalidProgramException)2 WaitTimeoutExpiredException (org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException)2 ConsoleHasNoChange (org.eclipse.reddeer.eclipse.condition.ConsoleHasNoChange)2 ConsoleHasText (org.eclipse.reddeer.eclipse.condition.ConsoleHasText)2 ConsoleView (org.eclipse.reddeer.eclipse.ui.console.ConsoleView)2 ContextMenuItem (org.eclipse.reddeer.swt.impl.menu.ContextMenuItem)2 ExpectedException (org.junit.rules.ExpectedException)2 Method (java.lang.reflect.Method)1 Duration (java.time.Duration)1 List (java.util.List)1 Nullable (javax.annotation.Nullable)1