当前位置: 首页>>代码示例>>Java>>正文


Java IsIterableContainingInOrder类代码示例

本文整理汇总了Java中org.hamcrest.collection.IsIterableContainingInOrder的典型用法代码示例。如果您正苦于以下问题:Java IsIterableContainingInOrder类的具体用法?Java IsIterableContainingInOrder怎么用?Java IsIterableContainingInOrder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IsIterableContainingInOrder类属于org.hamcrest.collection包,在下文中一共展示了IsIterableContainingInOrder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transactionsAreRunSuccessfully

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
@Test
public void transactionsAreRunSuccessfully() {
  saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition);
  saga.run();

  assertThat(eventStore, IsIterableContainingInOrder.contains(
      SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction2, TransactionEndedEvent.class),
      SagaEventMatcher.eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class)
  ));

  verify(transaction1).send(request1.serviceName(), SagaResponse.EMPTY_RESPONSE);
  verify(transaction2).send(request2.serviceName(), transactionResponse1);

  verify(compensation1, never()).send(request1.serviceName());
  verify(compensation2, never()).send(request2.serviceName());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-saga,代码行数:21,代码来源:ActorBasedSagaIntegrationTest.java

示例2: skipIgnoredTransaction

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
@Test
public void skipIgnoredTransaction() throws Exception {
  when(sagaDefinition.requests()).thenReturn(new SagaRequest[]{request1, request2, request3});
  saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition);

  when(childrenExtractor.fromJson(transactionResponse1.body())).thenReturn(setOf(request3.id()));

  saga.run();

  assertThat(eventStore, IsIterableContainingInOrder.contains(
      SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction3, TransactionStartedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction3, TransactionEndedEvent.class),
      SagaEventMatcher.eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class)
  ));

  verify(transaction1).send(request1.serviceName(), SagaResponse.EMPTY_RESPONSE);
  verify(transaction3).send(request3.serviceName(), transactionResponse1);
  verify(transaction2, never()).send(anyString(), any(SagaResponse.class));

  verify(compensation1, never()).send(request1.serviceName());
  verify(compensation2, never()).send(request2.serviceName());
  verify(compensation3, never()).send(request3.serviceName());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-saga,代码行数:27,代码来源:ActorBasedSagaIntegrationTest.java

示例3: skipAllIgnoredTransactions

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
@Test
public void skipAllIgnoredTransactions() throws Exception {
  when(sagaDefinition.requests()).thenReturn(new SagaRequest[]{request1, request2, request3, request4});
  saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition);

  when(childrenExtractor.fromJson(transactionResponse1.body())).thenReturn(setOf("none"));

  saga.run();

  assertThat(eventStore, IsIterableContainingInOrder.contains(
      SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class),
      SagaEventMatcher.eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class)
  ));

  verify(transaction1).send(request1.serviceName(), SagaResponse.EMPTY_RESPONSE);
  verify(transaction2, never()).send(anyString(), any(SagaResponse.class));
  verify(transaction3, never()).send(anyString(), any(SagaResponse.class));
  verify(transaction4, never()).send(anyString(), any(SagaResponse.class));

  verify(compensation1, never()).send(request1.serviceName());
  verify(compensation2, never()).send(request2.serviceName());
  verify(compensation3, never()).send(request3.serviceName());
  verify(compensation4, never()).send(request4.serviceName());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-saga,代码行数:27,代码来源:ActorBasedSagaIntegrationTest.java

示例4: retriesFailedTransactionTillSuccess

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
@Test
public void retriesFailedTransactionTillSuccess() {
  when(sagaDefinition.policy()).thenReturn(new ForwardRecovery());
  saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition);

  when(transaction2.send(request2.serviceName(), transactionResponse1))
      .thenThrow(exception).thenThrow(exception).thenReturn(transactionResponse2);

  saga.run();

  assertThat(eventStore, IsIterableContainingInOrder.contains(
      SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class),
      SagaEventMatcher.eventWith(sagaId, transaction2, TransactionEndedEvent.class),
      SagaEventMatcher.eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class)
  ));

  verify(transaction1).send(request1.serviceName(), SagaResponse.EMPTY_RESPONSE);
  verify(transaction2, times(3)).send(request2.serviceName(), transactionResponse1);

  verify(compensation1, never()).send(anyString(), any(SagaResponse.class));
  verify(compensation2, never()).send(anyString(), any(SagaResponse.class));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-saga,代码行数:26,代码来源:ActorBasedSagaIntegrationTest.java

示例5: buildsGraphOfParallelRequests

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
@Test
public void buildsGraphOfParallelRequests() {
  SingleLeafDirectedAcyclicGraph<SagaRequest> tasks = graphBuilder.build(requests);

  Traveller<SagaRequest> traveller = new ByLevelTraveller<>(tasks, new FromRootTraversalDirection<>());
  Collection<Node<SagaRequest>> nodes = traveller.nodes();

  traveller.next();
  assertThat(requestsOf(nodes), IsIterableContainingInOrder.contains(NoOpSagaRequest.SAGA_START_REQUEST));
  nodes.clear();

  traveller.next();
  assertThat(requestsOf(nodes), contains(request1, request2));
  nodes.clear();

  traveller.next();
  assertThat(requestsOf(nodes), contains(request3));
  nodes.clear();

  traveller.next();
  assertThat(requestsOf(nodes), IsIterableContainingInOrder.contains(NoOpSagaRequest.SAGA_END_REQUEST));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-saga,代码行数:23,代码来源:GraphBuilderTest.java

示例6: testMultipleTimeSeriesResponse

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
@Test
public void testMultipleTimeSeriesResponse() {
  setUp();
  final String testMetricName1 = "testMetric1";
  final List<String> testTags1 = Arrays.asList("host=h1", "dc=dc1");
  final List<String> testTags2 = Arrays.asList("host=h2", "dc=dc1");
  assertTrue(chunk.query(new Query("test", Collections.emptyList())).isEmpty());

  parseAndAddOpenTSDBMetric(
      makeMetricString(testMetricName1, "host=h1 dc=dc1", testTs, testValue), chunk);
  parseAndAddOpenTSDBMetric(
      makeMetricString(testMetricName1, "host=h2 dc=dc1", testTs, testValue), chunk);

  Point p1 = new Point(testTs, testValue);

  Assert.assertThat(chunk.query(Query.parse(testMetricName1 + " dc=dc1")),
      IsIterableContainingInOrder.contains(
          new TimeSeries(testMetricName1 + " dc=dc1 host=h1", Collections.singletonList(p1)),
          new TimeSeries(testMetricName1 + " dc=dc1 host=h2", Collections.singletonList(p1))));
}
 
开发者ID:pinterest,项目名称:yuvi,代码行数:21,代码来源:ChunkImplTest.java

示例7: testMultipleTimeSeriesResponse

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
public void testMultipleTimeSeriesResponse() {
  final String testMetricName1 = "testMetric1";
  final List<String> testTags1 = Arrays.asList("host=h1", "dc=dc1");
  final List<String> testTags2 = Arrays.asList("host=h2", "dc=dc1");
  assertTrue(ms.getSeries(new Query("test", Collections.emptyList())).isEmpty());

  final Metric testMetric1 = new Metric(testMetricName1, testTags1);
  final Metric testMetric2 = new Metric(testMetricName1, testTags2);

  ms.addPoint(testMetric1, ts, value);
  ms.addPoint(testMetric2, ts, value);
  Point p1 = new Point(ts, value);

  assertThat(ms.getSeries(Query.parse(testMetricName1 + " dc=dc1")),
      IsIterableContainingInOrder.contains(
          new TimeSeries(testMetricName1 + " dc=dc1 host=h1", Collections.singletonList(p1)),
          new TimeSeries(testMetricName1 + " dc=dc1 host=h2", Collections.singletonList(p1))));
}
 
开发者ID:pinterest,项目名称:yuvi,代码行数:19,代码来源:MetricsAndTagStoreImplTest.java

示例8: testEnums

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
@Test
public void testEnums() {
    Codec<Pojo> pojoCodec = codecRegistry.get(Pojo.class);

    LovelyDisplayable lovelyDisplayable = LovelyDisplayable.builder().identityProperty("foo").build();

    Pojo pojo = Pojo.builder()
            .simpleEnumProperty(EnumA.TYPE1)
            .displayable(Arrays.asList(EnumB.TYPE1, EnumA.TYPE1, EnumA.TYPE3, lovelyDisplayable))
            .build();

    StringWriter stringWriter = new StringWriter();
    JsonWriter writer = new JsonWriter(stringWriter, new JsonWriterSettings(true));
    pojoCodec.encode(writer, pojo, EncoderContext.builder().build());
    System.out.println(stringWriter.toString());

    Pojo decodedPojo = pojoCodec.decode(new JsonReader(stringWriter.toString()), DecoderContext.builder().build());

    MatcherAssert.assertThat(decodedPojo.getDisplayable(),
            IsIterableContainingInOrder.contains(EnumB.TYPE1, EnumA.TYPE1, EnumA.TYPE3, lovelyDisplayable));

}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:23,代码来源:TestEnums.java

示例9: testWrite

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
@Test
public void testWrite()
{
    String xml = "<FaceInterpolator parts=\"morph1 morph2 morph3\">" + "0.1 0.5 0.4 0.4\n" + "0.9 0.7 0.6 0.2" + "</FaceInterpolator>";
    FaceInterpolator ipIn = new FaceInterpolator();
    ipIn.readXML(xml);

    StringBuilder buf = new StringBuilder();
    ipIn.appendXML(buf);
    FaceInterpolator ipOut = new FaceInterpolator();
    ipOut.readXML(buf.toString());
    
    assertThat(ipOut.getParts(), IsIterableContainingInOrder.contains("morph1", "morph2", "morph3"));
    assertEquals(0.1, ipOut.getStartTime(), PRECISION);
    assertEquals(0.9, ipOut.getEndTime(), PRECISION);
}
 
开发者ID:ArticulatedSocialAgentsPlatform,项目名称:HmiCore,代码行数:17,代码来源:FaceInterpolatorTest.java

示例10: getFields_shouldGetFields

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
@Test
public void getFields_shouldGetFields() {
    final Field height = new Field("height", "", null, null, "");
    final Field width = new Field("width", "", null, null, "");
    final Field title = new Field("title", "", null, null, "");

    final List<Field> fields = Arrays.asList(height, width, title);

    final RegisterReadOnly register = mock(RegisterReadOnly.class);
    when(register.getRegisterName()).thenReturn(new RegisterName("widget"));
    final HomePageView homePageView = new HomePageView(null, null, mockRequestContext, 1, 2, null, Optional.empty(), homepageContent, registerResolver, fields, registerLinkService, register);

    final List<Field> actualFields = Lists.newArrayList(homePageView.getFields());

    assertThat(actualFields, IsIterableContainingInOrder.contains(height, width, title));
}
 
开发者ID:openregister,项目名称:openregister-java,代码行数:17,代码来源:HomePageViewTest.java

示例11: shouldUseServiceToGetEntryProof

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
@Test
public void shouldUseServiceToGetEntryProof() {
    int entryNumber = 2;
    int totalEntries = 5;
    HashValue expectedHash1 = new HashValue(HashingAlgorithm.SHA256, sampleHash1);
    HashValue expectedHash2 = new HashValue(HashingAlgorithm.SHA256, sampleHash2);
    List<HashValue> expectedAuditPath = Arrays.asList(expectedHash1, expectedHash2);

    EntryProof expectedProof = new EntryProof("3", expectedAuditPath);
    RegisterReadOnly registerMock = mock(RegisterReadOnly.class);
    when(registerMock.getTotalEntries()).thenReturn(8);
    when(registerMock.getEntryProof(entryNumber, totalEntries)).thenReturn(expectedProof);

    VerifiableLogResource vlResource = new VerifiableLogResource(registerMock);
    EntryProof actualProof = vlResource.entryProof(entryNumber, totalEntries);

    verify(registerMock, times(1)).getEntryProof(entryNumber, totalEntries);
    assertThat(actualProof.getProofIdentifier(), equalTo(expectedProof.getProofIdentifier()));
    assertThat(actualProof.getEntryNumber(), equalTo(expectedProof.getEntryNumber()));
    assertThat(actualProof.getAuditPath(), IsIterableContainingInOrder.contains(expectedHash1, expectedHash2));
}
 
开发者ID:openregister,项目名称:openregister-java,代码行数:22,代码来源:VerifiableLogResourceTest.java

示例12: shouldUseServiceToGetConsistencyProof

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
@Test
public void shouldUseServiceToGetConsistencyProof() {
    int totalEntries1 = 3;
    int totalEntries2 = 6;
    HashValue expectedHash1 = new HashValue(HashingAlgorithm.SHA256, sampleHash1);
    HashValue expectedHash2 = new HashValue(HashingAlgorithm.SHA256, sampleHash2);
    List<HashValue> expectedConsistencyNodes = Arrays.asList(expectedHash1, expectedHash2);

    ConsistencyProof expectedProof = new ConsistencyProof(expectedConsistencyNodes);
    RegisterReadOnly registerMock = mock(RegisterReadOnly.class);
    when(registerMock.getTotalEntries()).thenReturn(8);
    when(registerMock.getConsistencyProof(totalEntries1, totalEntries2)).thenReturn(expectedProof);

    VerifiableLogResource vlResource = new VerifiableLogResource(registerMock);
    ConsistencyProof actualProof = vlResource.consistencyProof(totalEntries1, totalEntries2);

    verify(registerMock, times(1)).getConsistencyProof(totalEntries1, totalEntries2);
    assertThat(actualProof.getProofIdentifier(), equalTo(expectedProof.getProofIdentifier()));

    assertThat(actualProof.getConsistencyNodes(), IsIterableContainingInOrder.contains(expectedHash1, expectedHash2));
}
 
开发者ID:openregister,项目名称:openregister-java,代码行数:22,代码来源:VerifiableLogResourceTest.java

示例13: read

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
@Test
public void read() throws Exception {
    final List<TimeSeriesCollection> tsdata = create_tsdata_(3).collect(Collectors.toList());
    file_support.create_file(tmpfile, tsdata);

    final TSData fd = TSData.readonly(tmpfile);

    assertEquals(tsdata, fd.stream().collect(Collectors.toList()));

    assertEquals(Files.size(tmpfile), fd.getFileSize());
    assertEquals(tsdata.get(0).getTimestamp(), fd.getBegin());
    assertEquals(tsdata.get(tsdata.size() - 1).getTimestamp(), fd.getEnd());
    assertNotNull(fd.getFileChannel());
    assertEquals(tsdata.size(), fd.size());
    assertEquals(file_support.getMajor(), fd.getMajor());
    assertEquals(file_support.getMinor(), fd.getMinor());
    assertThat(fd, IsIterableContainingInOrder.contains(tsdata.stream().map(Matchers::equalTo).collect(Collectors.toList())));
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:19,代码来源:TSDataTest.java

示例14: read

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
@Test
public void read() throws Exception {
    file_support.create_file(tmpfile, tsdata);

    final UnmappedReadonlyTSDataFile fd = UnmappedReadonlyTSDataFile.open(tmpfile);

    assertEquals(Files.size(tmpfile), fd.getFileSize());
    assertEquals(tsdata.get(0).getTimestamp(), fd.getBegin());
    assertEquals(tsdata.get(tsdata.size() - 1).getTimestamp(), fd.getEnd());
    assertTrue(fd.getFileChannel().isPresent());
    assertEquals(tsdata.size(), fd.size());
    assertEquals(file_support.getMajor(), fd.getMajor());
    assertEquals(file_support.getMinor(), fd.getMinor());
    assertThat(fd, IsIterableContainingInOrder.contains(tsdata.stream().map(Matchers::equalTo).collect(Collectors.toList())));
    assertThat(fd.streamReversed().collect(Collectors.toList()),
            IsIterableContainingInOrder.contains(expect_reversed.stream().map(Matchers::equalTo).collect(Collectors.toList())));
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:18,代码来源:UnmappedReadonlyTSDataFileTest.java

示例15: verifyValues

import org.hamcrest.collection.IsIterableContainingInOrder; //导入依赖的package包/类
private void verifyValues(List<byte[]> expectedValues, InputStream is) throws Exception {
  List<byte[]> values = new ArrayList<>();
  long count;
  do {
    count = VarInt.decodeLong(is);
    for (int i = 0; i < count; ++i) {
      values.add(ByteArrayCoder.of().decode(is));
    }
  } while(count > 0);

  if (expectedValues.isEmpty()) {
    assertTrue(values.isEmpty());
  } else {
    assertThat(values, IsIterableContainingInOrder.contains(expectedValues.toArray()));
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:17,代码来源:BufferedElementCountingOutputStreamTest.java


注:本文中的org.hamcrest.collection.IsIterableContainingInOrder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。