Java Code Examples for org.hamcrest.core.Is

The following examples show how to use org.hamcrest.core.Is. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: arctic-sea   Author: 52North   File: TsmlTVPEncoderv10Test.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldEncodeInterpolationType() throws EncodingException, XmlException {
    final InterpolationType type = TimeseriesMLConstants.InterpolationType.MinPrec;

    mv.setDefaultPointMetadata(new DefaultPointMetadata()
            .setDefaultTVPMeasurementMetadata(new DefaultTVPMeasurementMetadata().setInterpolationtype(type)));

    XmlObject encodedElement = encoder.encode(mv);

    TimeseriesTVPType.DefaultPointMetadata defaultPointMetadata =
            ((TimeseriesTVPDocument) encodedElement).getTimeseriesTVP().getDefaultPointMetadata();
    PointMetadataDocument tvpMeasurementMetadataDocument =
            PointMetadataDocument.Factory.parse(defaultPointMetadata.xmlText());
    ReferenceType interpolationType =
            tvpMeasurementMetadataDocument.getPointMetadata().getInterpolationType();
    MatcherAssert.assertThat(interpolationType.getHref(),
            Is.is("http://www.opengis.net/def/timeseries/InterpolationCode/MinPrec"));
    MatcherAssert.assertThat(interpolationType.getTitle(), Is.is("MinPrec"));
}
 
Example #2
Source Project: shardingsphere-elasticjob-cloud   Author: apache   File: ReadyServiceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void assertGetAllEligibleJobContextsWithRootNode() {
    Mockito.when(regCenter.isExisted("/state/ready")).thenReturn(true);
    Mockito.when(regCenter.getChildrenKeys("/state/ready")).thenReturn(Arrays.asList("not_existed_job", "running_job", "ineligible_job", "eligible_job"));
    Mockito.when(configService.load("not_existed_job")).thenReturn(Optional.<CloudJobConfiguration>absent());
    Mockito.when(configService.load("running_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("running_job")));
    Mockito.when(configService.load("eligible_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("eligible_job")));
    Mockito.when(runningService.isJobRunning("running_job")).thenReturn(true);
    Mockito.when(runningService.isJobRunning("eligible_job")).thenReturn(false);
    Assert.assertThat(readyService.getAllEligibleJobContexts(Collections.singletonList(
            JobContext.from(CloudJobConfigurationBuilder.createCloudJobConfiguration("ineligible_job"), ExecutionType.READY))).size(), Is.is(1));
    Mockito.verify(regCenter).isExisted("/state/ready");
    Mockito.verify(regCenter, Mockito.times(1)).getChildrenKeys("/state/ready");
    Mockito.verify(configService).load("not_existed_job");
    Mockito.verify(configService).load("running_job");
    Mockito.verify(configService).load("eligible_job");
    Mockito.verify(regCenter).remove("/state/ready/not_existed_job");
}
 
Example #3
Source Project: servicecomb-pack   Author: apache   File: TccLoadBalanceSenderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void participateInterruptedFailed() throws InterruptedException {
  Thread thread = new Thread(new Runnable() {
    @Override
    public void run() {
      try {
        await().atLeast(1, SECONDS);
        tccLoadBalanceSender.participationStart(participationStartedEvent);
      } catch (OmegaException e) {
        assertThat(e.getMessage().endsWith("interruption"), Is.is(true));
      }
    }
  });
  thread.start();
  thread.interrupt();
  thread.join();
}
 
Example #4
Source Project: carnotzet   Author: swissquote   File: DefaultCommandRunnerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void test_large_output() throws Exception {

	// create temp file of about 274k
	final File tmp = File.createTempFile("carnotzet-test", null);
	tmp.deleteOnExit();
	StringBuilder sb = new StringBuilder();
	for (int i = 0; i < 10000; i++){
		sb.append("This line is repeated a lot\n");
	}
	String expected = sb.toString();
	FileUtils.write(tmp, expected);

	// When
	String actual = new SimpleTimeLimiter().callWithTimeout(
			() -> DefaultCommandRunner.INSTANCE.runCommandAndCaptureOutput("cat", tmp.getAbsolutePath()),
			2, TimeUnit.SECONDS, true);

	// Then
	Assert.assertThat(actual, Is.is(expected.trim()));
}
 
Example #5
Source Project: arctic-sea   Author: 52North   File: InsertResultRequestEncoderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldEncodeInsertResultRequest() throws EncodingException {
    String version = Sos2Constants.SERVICEVERSION;
    String service = SosConstants.SOS;
    String templateIdentifier = "test-template-identifier";
    String resultValues = "test-result-values";
    InsertResultRequest request = new InsertResultRequest(service, version);
    request.setTemplateIdentifier(templateIdentifier);
    request.setResultValues(resultValues);

    XmlObject encodedRequest = encoder.create(request);
    assertThat(encodedRequest, Matchers.instanceOf(InsertResultDocument.class));
    assertThat(((InsertResultDocument)encodedRequest).getInsertResult(), Matchers.notNullValue());
    InsertResultType xbRequest = ((InsertResultDocument)encodedRequest).getInsertResult();
    assertThat(xbRequest.getService(), Is.is(service));
    assertThat(xbRequest.getVersion(), Is.is(version));
    assertThat(xbRequest.getTemplate(), Is.is(templateIdentifier));
    assertThat(xbRequest.getResultValues(), Matchers.instanceOf(XmlString.class));
    assertThat(((XmlString)xbRequest.getResultValues()).getStringValue(), Is.is(resultValues));
}
 
Example #6
Source Project: servicecomb-saga-actuator   Author: apache   File: JacksonRestOperationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void appendsResponseToForm() throws Exception {
  ArgumentCaptor<Map> argumentCaptor = ArgumentCaptor.forClass(Map.class);
  when(transport.with(eq(address), eq(path), eq(method), argumentCaptor.capture())).thenReturn(
      SagaResponse.EMPTY_RESPONSE);

  SagaResponse response = restOperation.send(address, Operation.SUCCESSFUL_SAGA_RESPONSE);

  assertThat(response, Is.is(SagaResponse.EMPTY_RESPONSE));

  Map<String, Map<String, String>> updatedParams = argumentCaptor.getValue();
  assertThat(null == updatedParams.get("form") ? Collections.<String, String>emptyMap().get("response")
          : updatedParams.get("form").get("response")
      , Is.is(Operation.SUCCESSFUL_SAGA_RESPONSE.body()));
  assertThat(params.isEmpty(), is(true));
}
 
Example #7
Source Project: arctic-sea   Author: 52North   File: UVFEncoderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldEncodeTimeseriesIdentifierAndCenturiesFromStreamingValues() throws
        EncodingException {
    GlobalObservationResponseValues globalValues = new GlobalObservationResponseValues();
    DateTime end = new DateTime(0);
    DateTime start = new DateTime(0);
    Time phenomenonTime = new TimePeriod(start, end);
    globalValues.addPhenomenonTime(phenomenonTime);
    responseToEncode.setGlobalObservationValues(globalValues);
    final String actual = getResponseString()[7];
    final String expected = obsPropIdentifier.substring(
        obsPropIdentifier.length() - UVFConstants.MAX_IDENTIFIER_LENGTH,
        obsPropIdentifier.length()) +
        " " + unit + "     " +
        "1900 1900";

    assertThat(actual, Is.is(expected));
}
 
Example #8
Source Project: shardingsphere-elasticjob-cloud   Author: apache   File: ExecutorServiceObjectTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void assertCreateExecutorService() {
    executorServiceObject = new ExecutorServiceObject("executor-service-test", 1);
    Assert.assertThat(executorServiceObject.getActiveThreadCount(), Is.is(0));
    Assert.assertThat(executorServiceObject.getWorkQueueSize(), Is.is(0));
    Assert.assertFalse(executorServiceObject.isShutdown());
    ExecutorService executorService = executorServiceObject.createExecutorService();
    executorService.submit(new FooTask());
    BlockUtils.waitingShortTime();
    Assert.assertThat(executorServiceObject.getActiveThreadCount(), Is.is(1));
    Assert.assertThat(executorServiceObject.getWorkQueueSize(), Is.is(0));
    Assert.assertFalse(executorServiceObject.isShutdown());
    executorService.submit(new FooTask());
    BlockUtils.waitingShortTime();
    Assert.assertThat(executorServiceObject.getActiveThreadCount(), Is.is(1));
    Assert.assertThat(executorServiceObject.getWorkQueueSize(), Is.is(1));
    Assert.assertFalse(executorServiceObject.isShutdown());
    executorService.shutdownNow();
    Assert.assertThat(executorServiceObject.getWorkQueueSize(), Is.is(0));
    Assert.assertTrue(executorServiceObject.isShutdown());
}
 
Example #9
Source Project: servicecomb-pack   Author: apache   File: AlphaIntegrationWithRandomPortTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void persistsEvent() {
  asyncStub.onConnected(compensateResponseObserver).onNext(serviceConfig);
  blockingStub.onTxEvent(someGrpcEvent(TxStartedEvent));
  // use the asynchronous stub need to wait for some time
  await().atMost(1, SECONDS).until(() -> !eventRepo.findByGlobalTxId(globalTxId).isEmpty());

  assertThat(receivedCommands.isEmpty(), is(true));

  TxEvent envelope = eventRepo.findByGlobalTxId(globalTxId).get(0);

  assertThat(envelope.serviceName(), is(serviceName));
  assertThat(envelope.instanceId(), is(instanceId));
  assertThat(envelope.globalTxId(), is(globalTxId));
  assertThat(envelope.localTxId(), is(localTxId));
  assertThat(envelope.parentTxId(), is(parentTxId));
  assertThat(envelope.type(), Is.is(TxStartedEvent.name()));
  assertThat(envelope.compensationMethod(), is(compensationMethod));
  assertThat(envelope.payloads(), is(payload.getBytes()));
}
 
Example #10
Source Project: arctic-sea   Author: 52North   File: WmlTVPEncoderv20Test.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSetDefaultCumulativeProperty() throws EncodingException {
    XmlObject encodedElement = encoder.encode(mv);

    assertThat(encodedElement, CoreMatchers.instanceOf(MeasurementTimeseriesDocument.class));
    final MeasurementTimeseriesDocument measurementTimeseriesDocument =
            (MeasurementTimeseriesDocument) encodedElement;
    assertThat(measurementTimeseriesDocument.getTimeseries().isSetMetadata(), Is.is(true));
    assertThat(measurementTimeseriesDocument.getTimeseries().getMetadata().getTimeseriesMetadata(),
            CoreMatchers.instanceOf(MeasurementTimeseriesMetadataType.class));
    final MeasurementTimeseriesMetadataType measurementTimeseriesMetadataType =
            (MeasurementTimeseriesMetadataType) measurementTimeseriesDocument.getTimeseries().getMetadata()
                    .getTimeseriesMetadata();
    assertThat(measurementTimeseriesMetadataType.isSetCumulative(), Is.is(true));
    assertThat(measurementTimeseriesMetadataType.getCumulative(), Is.is(false));
}
 
Example #11
Source Project: arctic-sea   Author: 52North   File: UVFEncoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnEmptyFileWhenObservationCollectionIsEmpty() throws EncodingException {
    responseToEncode.setObservationCollection(ObservationStream.empty());

    BinaryAttachmentResponse encodedResponse = encoder.encode(responseToEncode);
    assertThat(encodedResponse.getSize(), Is.is(-1));
}
 
Example #12
Source Project: arctic-sea   Author: 52North   File: SosInsertionMetadataTypeEncoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldEncodeObservationTypes() throws EncodingException {
    SosInsertionMetadataType encoded = encoder.encode(insertionMetadata);

    MatcherAssert.assertThat(encoded.getObservationTypeArray().length, Is.is(2));
    List<String> observationTypes = Arrays.asList(encoded.getObservationTypeArray());
    Collections.sort(observationTypes);
    MatcherAssert.assertThat(observationTypes, Matchers.contains("type-1", "type-2"));
}
 
Example #13
Source Project: Flink-CEPplus   Author: ljygz   File: AkkaRpcActorTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Tests that the {@link AkkaRpcActor} discards messages until the corresponding
 * {@link RpcEndpoint} has been started.
 */
@Test
public void testMessageDiscarding() throws Exception {
	int expectedValue = 1337;

	DummyRpcEndpoint rpcEndpoint = new DummyRpcEndpoint(akkaRpcService);

	DummyRpcGateway rpcGateway = rpcEndpoint.getSelfGateway(DummyRpcGateway.class);

	// this message should be discarded and completed with an AkkaRpcException
	CompletableFuture<Integer> result = rpcGateway.foobar();

	try {
		result.get(timeout.getSize(), timeout.getUnit());
		fail("Expected an AkkaRpcException.");
	} catch (ExecutionException ee) {
		// expected this exception, because the endpoint has not been started
		assertTrue(ee.getCause() instanceof AkkaRpcException);
	}

	// set a new value which we expect to be returned
	rpcEndpoint.setFoobar(expectedValue);

	// start the endpoint so that it can process messages
	rpcEndpoint.start();

	try {
		// send the rpc again
		result = rpcGateway.foobar();

		// now we should receive a result :-)
		Integer actualValue = result.get(timeout.getSize(), timeout.getUnit());

		assertThat("The new foobar value should have been returned.", actualValue, Is.is(expectedValue));
	} finally {
		RpcUtils.terminateRpcEndpoint(rpcEndpoint, timeout);
	}
}
 
Example #14
Source Project: datax-web   Author: WeiYe-Jing   File: JacksonUtilTest.java    License: MIT License 5 votes vote down vote up
@Test
public void shouldReadValueAsObject() {
    //given
    String jsonString = "{\"aaa\":\"111\",\"bbb\":\"222\"}";

    //when
    Map result = JacksonUtil.readValue(jsonString, Map.class);

    //then
    assertThat(result.get("aaa"), Is.<Object>is("111"));
    assertThat(result.get("bbb"), Is.<Object>is("222"));

}
 
Example #15
Source Project: shardingsphere-elasticjob-cloud   Author: apache   File: StatisticManagerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void assertFindTaskResultStatisticsDailyWhenRdbIsConfigured() throws NoSuchFieldException {
    ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository);
    Mockito.when(rdbRepository.findTaskResultStatistics(Mockito.any(Date.class), Mockito.any(StatisticInterval.class)))
        .thenReturn(Lists.newArrayList(new TaskResultStatistics(10, 5, StatisticInterval.MINUTE, new Date())));
    Assert.assertThat(statisticManager.findTaskResultStatisticsDaily().size(), Is.is(1));
    Mockito.verify(rdbRepository).findTaskResultStatistics(Mockito.any(Date.class), Mockito.any(StatisticInterval.class));
}
 
Example #16
@Test
public void assertSandbox() throws Exception {
    Mockito.when(getRegCenter().getDirectly(HANode.FRAMEWORK_ID_NODE)).thenReturn("d8701508-41b7-471e-9b32-61cf824a660d-0000");
    Assert.assertThat(RestfulTestsUtil.sentGetRequest("http://127.0.0.1:19000/api/operate/sandbox?appName=foo_app"), Is.is("[{\"hostname\":\"127.0.0.1\","
            + "\"path\":\"/slaves/d8701508-41b7-471e-9b32-61cf824a660d-S0/frameworks/d8701508-41b7-471e-9b32-61cf824a660d-0000/executors/[email protected]@"
            + "d8701508-41b7-471e-9b32-61cf824a660d-S0/runs/53fb4af7-aee2-44f6-9e47-6f418d9f27e1\"}]"));
}
 
Example #17
Source Project: shardingsphere-elasticjob-cloud   Author: apache   File: TaskContextTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void assertTaskContextFrom() {
    TaskContext actual = TaskContext.from(TaskNode.builder().build().getTaskNodeValue());
    Assert.assertThat(actual.getId(), Is.is(TaskNode.builder().build().getTaskNodeValue()));
    Assert.assertThat(actual.getMetaInfo().getJobName(), Is.is("test_job"));
    Assert.assertThat(actual.getMetaInfo().getShardingItems().get(0), Is.is(0));
    Assert.assertThat(actual.getType(), Is.is(ExecutionType.READY));
    Assert.assertThat(actual.getSlaveId(), Is.is("slave-S0"));
}
 
Example #18
Source Project: shardingsphere-elasticjob-cloud   Author: apache   File: CloudJobRestfulApiTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void assertGetTaskResultStatisticsWithErrorPathParameter() throws Exception {
    String result = RestfulTestsUtil.sentGetRequest("http://127.0.0.1:19000/api/job/statistics/tasks/results/errorPath");
    TaskResultStatistics taskResultStatistics = GsonFactory.getGson().fromJson(result, TaskResultStatistics.class);
    Assert.assertThat(taskResultStatistics.getSuccessCount(), Is.is(0));
    Assert.assertThat(taskResultStatistics.getFailedCount(), Is.is(0));
}
 
Example #19
@Test
public void assertGetChildrenKeys() {
    Assert.assertThat(zkRegCenter.getChildrenKeys("/test"), Is.is(Arrays.asList("deep", "child")));
    Assert.assertThat(zkRegCenter.getChildrenKeys("/test/deep"), Is.is(Collections.singletonList("nested")));
    Assert.assertThat(zkRegCenter.getChildrenKeys("/test/child"), Is.is(Collections.<String>emptyList()));
    Assert.assertThat(zkRegCenter.getChildrenKeys("/test/notExisted"), Is.is(Collections.<String>emptyList()));
}
 
Example #20
Source Project: shardingsphere-elasticjob-cloud   Author: apache   File: FailoverServiceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void assertGetAllFailoverTasksWithRootNode() {
    String uuid1 = UUID.randomUUID().toString();
    String uuid2 = UUID.randomUUID().toString();
    String uuid3 = UUID.randomUUID().toString();
    Mockito.when(regCenter.isExisted(FailoverNode.ROOT)).thenReturn(true);
    Mockito.when(regCenter.getChildrenKeys(FailoverNode.ROOT)).thenReturn(Lists.newArrayList("test_job_1", "test_job_2"));
    Mockito.when(regCenter.getChildrenKeys(FailoverNode.getFailoverJobNodePath("test_job_1"))).thenReturn(Lists.newArrayList("[email protected]@0", "[email protected]@1"));
    Mockito.when(regCenter.getChildrenKeys(FailoverNode.getFailoverJobNodePath("test_job_2"))).thenReturn(Lists.newArrayList("[email protected]@0"));
    Mockito.when(regCenter.get(FailoverNode.getFailoverTaskNodePath("[email protected]@0"))).thenReturn(uuid1);
    Mockito.when(regCenter.get(FailoverNode.getFailoverTaskNodePath("[email protected]@1"))).thenReturn(uuid2);
    Mockito.when(regCenter.get(FailoverNode.getFailoverTaskNodePath("[email protected]@0"))).thenReturn(uuid3);
    Map<String, Collection<FailoverTaskInfo>> result = failoverService.getAllFailoverTasks();
    Assert.assertThat(result.size(), Is.is(2));
    Assert.assertThat(result.get("test_job_1").size(), Is.is(2));
    Assert.assertThat(result.get("test_job_1").toArray(new FailoverTaskInfo[]{})[0].getTaskInfo().toString(), Is.is("[email protected]@0"));
    Assert.assertThat(result.get("test_job_1").toArray(new FailoverTaskInfo[]{})[0].getOriginalTaskId(), Is.is(uuid1));
    Assert.assertThat(result.get("test_job_1").toArray(new FailoverTaskInfo[]{})[1].getTaskInfo().toString(), Is.is("[email protected]@1"));
    Assert.assertThat(result.get("test_job_1").toArray(new FailoverTaskInfo[]{})[1].getOriginalTaskId(), Is.is(uuid2));
    Assert.assertThat(result.get("test_job_2").size(), Is.is(1));
    Assert.assertThat(result.get("test_job_2").iterator().next().getTaskInfo().toString(), Is.is("[email protected]@0"));
    Assert.assertThat(result.get("test_job_2").iterator().next().getOriginalTaskId(), Is.is(uuid3));
    Mockito.verify(regCenter).isExisted(FailoverNode.ROOT);
    Mockito.verify(regCenter).getChildrenKeys(FailoverNode.ROOT);
    Mockito.verify(regCenter).getChildrenKeys(FailoverNode.getFailoverJobNodePath("test_job_1"));
    Mockito.verify(regCenter).getChildrenKeys(FailoverNode.getFailoverJobNodePath("test_job_2"));
    Mockito.verify(regCenter).get(FailoverNode.getFailoverTaskNodePath("[email protected]@0"));
    Mockito.verify(regCenter).get(FailoverNode.getFailoverTaskNodePath("[email protected]@1"));
    Mockito.verify(regCenter).get(FailoverNode.getFailoverTaskNodePath("[email protected]@0"));
}
 
Example #21
Source Project: kucoin-java-sdk   Author: Kucoin   File: KucoinRestClientTest.java    License: MIT License 5 votes vote down vote up
/**
 * Check that we can get all account balances.
 */
@Test
public void accountAPIMulti() throws Exception {
    List<AccountBalancesResponse> accountBalancesResponses
            = sandboxKucoinRestClient.accountAPI().listAccounts(null, null);
    assertThat(accountBalancesResponses.size(), Is.is(6));
}
 
Example #22
Source Project: shardingsphere-elasticjob-cloud   Author: apache   File: StatisticRdbRepositoryTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void assertFindJobRegisterStatisticsWithDifferentFromDate() {
    Date now = new Date();
    Date yesterday = getYesterday();
    Assert.assertTrue(repository.add(new JobRegisterStatistics(100, yesterday)));
    Assert.assertTrue(repository.add(new JobRegisterStatistics(100, now)));
    Assert.assertThat(repository.findJobRegisterStatistics(yesterday).size(), Is.is(2));
    Assert.assertThat(repository.findJobRegisterStatistics(now).size(), Is.is(1));
}
 
Example #23
Source Project: shardingsphere-elasticjob-cloud   Author: apache   File: CloudAppRestfulApiTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void assertFindAllJobs() throws Exception {
    Mockito.when(getRegCenter().isExisted("/config/app")).thenReturn(true);
    Mockito.when(getRegCenter().getChildrenKeys("/config/app")).thenReturn(Lists.newArrayList("test_app"));
    Mockito.when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app"));
    Assert.assertThat(RestfulTestsUtil.sentGetRequest("http://127.0.0.1:19000/api/app/list"), Is.is("[" + CloudAppJsonConstants.getAppJson("test_app") + "]"));
    Mockito.verify(getRegCenter()).isExisted("/config/app");
    Mockito.verify(getRegCenter()).getChildrenKeys("/config/app");
    Mockito.verify(getRegCenter()).get("/config/app/test_app");
}
 
Example #24
Source Project: Quicksql   Author: Qihoo360   File: Matchers.java    License: MIT License 5 votes vote down vote up
/**
 * Creates a Matcher that matches a {@link RelNode} if its string
 * representation, after converting Windows-style line endings ("\r\n")
 * to Unix-style line endings ("\n"), is equal to the given {@code value}.
 */
@Factory
public static Matcher<RelNode> hasTree(final String value) {
  return compose(Is.is(value), input -> {
    // Convert RelNode to a string with Linux line-endings
    return Util.toLinux(RelOptUtil.toString(input));
  });
}
 
Example #25
Source Project: arctic-sea   Author: 52North   File: InsertResultTemplateRequestEncoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSetOptionalIdentifier() throws EncodingException {
    ResultTemplateType template = ((InsertResultTemplateDocument) encoder.create(request))
            .getInsertResultTemplate().getProposedTemplate().getResultTemplate();

    assertThat(template.isSetIdentifier(), Is.is(true));
    assertThat(template.getIdentifier(), Is.is(templateIdentifier));
}
 
Example #26
Source Project: shardingsphere-elasticjob-cloud   Author: apache   File: StatisticRdbRepositoryTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void assertFindTaskRunningStatisticsWithDifferentFromDate() {
    Date now = new Date();
    Date yesterday = getYesterday();
    Assert.assertTrue(repository.add(new TaskRunningStatistics(100, yesterday)));
    Assert.assertTrue(repository.add(new TaskRunningStatistics(100, now)));
    Assert.assertThat(repository.findTaskRunningStatistics(yesterday).size(), Is.is(2));
    Assert.assertThat(repository.findTaskRunningStatistics(now).size(), Is.is(1));
}
 
Example #27
Source Project: nexus3-github-oauth-plugin   Author: larscheid-schmitzhermes   File: GithubApiClientTest.java    License: MIT License 5 votes vote down vote up
@Test
public void shouldAcceptOrgAnywhereInList() throws Exception {
    HttpClient mockClient = fullyFunctionalMockClient();
    config.setGithubOrg("TEST-ORG,TEST-ORG2");
    GithubApiClient clientToTest = new GithubApiClient(mockClient, config);
    GithubPrincipal authorizedPrincipal = clientToTest.authz("demo-user", "DUMMY".toCharArray());
    MatcherAssert.assertThat(authorizedPrincipal.getRoles().iterator().next(), Is.is("TEST-ORG/admin"));

    HttpClient mockClient2 = fullyFunctionalMockClient();
    config.setGithubOrg("TEST-ORG2,TEST-ORG");
    GithubApiClient clientToTest2 = new GithubApiClient(mockClient2, config);
    GithubPrincipal authorizedPrincipal2 = clientToTest2.authz("demo-user", "DUMMY".toCharArray());
    MatcherAssert.assertThat(authorizedPrincipal2.getRoles().iterator().next(), Is.is("TEST-ORG/admin"));
}
 
Example #28
Source Project: nexus3-github-oauth-plugin   Author: larscheid-schmitzhermes   File: GithubApiClientTest.java    License: MIT License 5 votes vote down vote up
@Test
public void shouldDoAuthzIfRequestStatusIs200() throws Exception {
    HttpClient mockClient = fullyFunctionalMockClient();

    GithubApiClient clientToTest = new GithubApiClient(mockClient, config);
    GithubPrincipal authorizedPrincipal = clientToTest.authz("demo-user", "DUMMY".toCharArray());

    MatcherAssert.assertThat(authorizedPrincipal.getRoles().size(), Is.is(1));
    MatcherAssert.assertThat(authorizedPrincipal.getRoles().iterator().next(), Is.is("TEST-ORG/admin"));
    MatcherAssert.assertThat(authorizedPrincipal.getUsername(), Is.is("demo-user"));

}
 
Example #29
@Test
public void assertLoadWithConfig() {
    Mockito.when(regCenter.get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson());
    Optional<CloudJobConfiguration> actual = configService.load("test_job");
    Assert.assertTrue(actual.isPresent());
    Assert.assertThat(actual.get().getJobName(), Is.is("test_job"));
}
 
Example #30
Source Project: multiapps-controller   Author: cloudfoundry-incubator   File: DetermineServiceCreateUpdateServiceActionsStepTest.java    License: Apache License 2.0 5 votes vote down vote up
private void validateActions() {
    List<ServiceAction> serviceActionsToExecute = context.getVariable(Variables.SERVICE_ACTIONS_TO_EXCECUTE);
    if (stepInput.shouldCreateService) {
        collector.checkThat("Actions should contain " + ServiceAction.CREATE, serviceActionsToExecute.contains(ServiceAction.CREATE),
                            Is.is(true));
    }
    if (stepInput.shouldRecreateService) {
        collector.checkThat("Actions should contain " + ServiceAction.RECREATE,
                            serviceActionsToExecute.contains(ServiceAction.RECREATE), Is.is(true));
    }
    if (stepInput.shouldUpdateServicePlan) {
        collector.checkThat("Actions should contain " + ServiceAction.UPDATE_PLAN,
                            serviceActionsToExecute.contains(ServiceAction.UPDATE_PLAN), Is.is(true));
    }
    if (stepInput.shouldUpdateServiceTags) {
        collector.checkThat("Actions should contain " + ServiceAction.UPDATE_TAGS,
                            serviceActionsToExecute.contains(ServiceAction.UPDATE_TAGS), Is.is(true));
    }
    if (stepInput.shouldUpdateServiceCredentials) {
        collector.checkThat("Actions should contain " + ServiceAction.UPDATE_CREDENTIALS,
                            serviceActionsToExecute.contains(ServiceAction.UPDATE_CREDENTIALS), Is.is(true));
    }
    if (stepInput.shouldUpdateServiceKeys) {
        collector.checkThat("Actions should contain " + ServiceAction.UPDATE_KEYS,
                            serviceActionsToExecute.contains(ServiceAction.UPDATE_KEYS), Is.is(true));
    }
}