org.assertj.core.api.IterableAssert.hasSameElementsAs()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(15.7k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中org.assertj.core.api.IterableAssert.hasSameElementsAs()方法的一些代码示例,展示了IterableAssert.hasSameElementsAs()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IterableAssert.hasSameElementsAs()方法的具体详情如下:
包路径:org.assertj.core.api.IterableAssert
类名称:IterableAssert
方法名:hasSameElementsAs

IterableAssert.hasSameElementsAs介绍

暂无

代码示例

代码示例来源:origin: palantir/atlasdb

@Test
public void canGetRows() {
  Map<Cell, Value> row = getTestKvs()
      .getRows(TEST_TABLE, ImmutableList.of(FIRST_ROW), ColumnSelection.all(), Long.MAX_VALUE);
  assertThat(row.entrySet()).hasSameElementsAs(expectedRowEntries);
}

代码示例来源:origin: palantir/atlasdb

@Test
public void extraSweepersGiveUpAfterFailingToAcquireEnoughTimes() throws InterruptedException {
  int shards = 16;
  int sweepers = 4;
  int threads = shards / (sweepers / 2);
  TimelockService stickyLockService = createStickyLockService();
  createAndInitializeSweepersAndWaitForOneBackgroundIteration(sweepers, shards, threads, stickyLockService);
  ArgumentCaptor<LockRequest> captor = ArgumentCaptor.forClass(LockRequest.class);
  // minimum: as in the example above, but we have extra threads
  // threads + ... + threads * (shards / threads) + shards * (threads * sweepers - shards)
  verify(stickyLockService, atLeast(shards * (shards / threads + 1) / 2 + shards * (threads * sweepers - shards)))
      .lock(captor.capture());
  // maximum: one would think that it is
  // shards + shards - 1 + ... + shards - (sweepers - 1) + shards * (threads * sweepers - shards)
  // but actually the logic is much more complicated since threads from the same sweeper can loop back and hit a
  // race condition with each other, so we go with the more conservative upper bound
  verify(stickyLockService, atMost(threads * sweepers * shards)).lock(any());
  Set<String> requestedLockIds = captor.getAllValues().stream()
      .map(LockRequest::getLockDescriptors)
      .map(Iterables::getOnlyElement)
      .map(LockDescriptor::getLockIdAsString)
      .collect(Collectors.toSet());
  Set<String> expectedLockIds = IntStream.range(0, shards).boxed()
      .map(ShardAndStrategy::conservative)
      .map(ShardAndStrategy::toText)
      .collect(Collectors.toSet());
  assertThat(requestedLockIds).hasSameElementsAs(expectedLockIds);
}

代码示例来源:origin: eclipse/ditto

/**
 * Asserts that the specified collection of Bson objects is equal to this value.
 *
 * @param expected the expected collection of Bson objects.
 * @return this assertion object to allow method chaining.
 */
public <T extends Bson> BsonCollectionAssert isEqualToInAnyOrder(final Iterable<T> expected) {
  assertBothOrNonNull(expected);
  Assertions.assertThat(actual)
      .hasSameElementsAs(expected)
      .usingElementComparator(areBsonObjectsEqualComparator);
  return myself;
}

代码示例来源:origin: SonarSource/sonar-go

@Test
void should_use_all_uast_kinds() throws Exception {
 // ensure that we test all kinds that can be produced
 List<UastNode.Kind> usedKinds = files().map(UastKindsTest::fileContent)
  .map(source -> new Generator(source).uast())
  .flatMap(node -> collectKinds(node).stream())
  .collect(Collectors.toList());
 EnumSet<UastNode.Kind> usedKindsSet = EnumSet.copyOf(usedKinds);
 assertThat(usedKindsSet).hasSameElementsAs(EnumSet.allOf(UastNode.Kind.class));
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testRequestParameterTypeChangedWorksCorrectly() {
    // given
    String oldApiPath = "request/parametertypechanged/petstore.yaml";
    String newApiPath = "request/parametertypechanged/petstore_v2.yaml";
    RequestParameterTypeChangedBreakingChange bc = new RequestParameterTypeChangedBreakingChange("/pet/findByTags", HttpMethod.GET, "tags", "", "array", "string");
    Collection<BreakingChange> expected = Collections.singleton(bc);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(1);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testPathDeletionWorksCorrectly() {
    // given
    String oldApiPath = "path/deleted/petstore.yaml";
    String newApiPath = "path/deleted/petstore_v2.yaml";
    PathDeletedBreakingChange bc = new PathDeletedBreakingChange("/pet/findByStatus", HttpMethod.GET);
    Collection<BreakingChange> expected = Collections.singleton(bc);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(1);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testRequestParameterInTypeChangedWorksCorrectly() {
    // given
    String oldApiPath = "request/parameterintypechanged/petstore.yaml";
    String newApiPath = "request/parameterintypechanged/petstore_v2.yaml";
    RequestParameterInTypeChangedBreakingChange bc = new RequestParameterInTypeChangedBreakingChange("/pet/findByStatus", HttpMethod.GET, "status", "query", "header");
    Collection<BreakingChange> expected = Collections.singleton(bc);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(1);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testRequestParameterDeletedWorksCorrectly() {
    // given
    String oldApiPath = "request/parameterdeleted/petstore.yaml";
    String newApiPath = "request/parameterdeleted/petstore_v2.yaml";
    RequestParameterDeletedBreakingChange bc = new RequestParameterDeletedBreakingChange("/pet/findByStatus", HttpMethod.GET, "status");
    Collection<BreakingChange> expected = Collections.singleton(bc);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(1);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testResponseTypeChangeIsBreakingChangeWhenExistingAttributeRemoved() {
    // given
    String oldApiPath = "response/deleted/petstore.yaml";
    String newApiPath = "response/deleted/petstore_v2.yaml";
    ResponseDeletedBreakingChange bc = new ResponseDeletedBreakingChange("/pet", HttpMethod.PUT, "404");
    Collection<BreakingChange> expected = Collections.singleton(bc);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(1);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testRequestParameterEnumValueDeletedWorksCorrectly() {
    // given
    String oldApiPath = "request/parameterenumvaluedeleted/petstore.yaml";
    String newApiPath = "request/parameterenumvaluedeleted/petstore_v2.yaml";
    RequestParameterEnumValueDeletedBreakingChange bc = new RequestParameterEnumValueDeletedBreakingChange("/pet/findByStatus", HttpMethod.GET, "status", "pending");
    Collection<BreakingChange> expected = Collections.singleton(bc);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(1);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testResponseTypeChangeIsBreakingChangeWhenExistingAttributeRemoved() {
    // given
    String oldApiPath = "response/recursiveresponseattributeremoved/schema.json";
    String newApiPath = "response/recursiveresponseattributeremoved/schema_v2.json";
    ResponseTypeAttributeRemovedBreakingChange bc1 =
      new ResponseTypeAttributeRemovedBreakingChange("/api/v1/audits/summary/{businessId}", HttpMethod.GET, "200", "unverifiedPayoffBreakdown.amountApplied");
    Collection<BreakingChange> expected = Collections.singletonList(bc1);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(1);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testResponseTypeChangeIsBreakingChangeWhenExistingAttributeRemoved() {
    // given
    String oldApiPath = "response/typechanged/petstore.yaml";
    String newApiPath = "response/typechanged/petstore_v2.yaml";
    ResponseTypeChangedBreakingChange bc1 = new ResponseTypeChangedBreakingChange("/pet/findByStatus", HttpMethod.GET, "200", "","array", "object");
    ResponseTypeChangedBreakingChange bc2 = new ResponseTypeChangedBreakingChange("/pet/findByTags", HttpMethod.GET, "200", "", "array", "string");
    Collection<BreakingChange> expected = Arrays.asList(bc1, bc2);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(2);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testRequestParameterRequiredWorksCorrectly() {
    // given
    String oldApiPath = "request/parameterrequired/petstore.yaml";
    String newApiPath = "request/parameterrequired/petstore_v2.yaml";
    RequestParameterRequiredBreakingChange bc1 = new RequestParameterRequiredBreakingChange("/pet", HttpMethod.POST, "test");
    RequestParameterRequiredBreakingChange bc2 = new RequestParameterRequiredBreakingChange("/pet/findByStatus", HttpMethod.GET, "test");
    Collection<BreakingChange> expected = Arrays.asList(bc1, bc2);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(2);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testResponseMediaTypeDeletedWorksCorrectly() {
    // given
    String oldApiPath = "response/mediatypedeleted/petstore.yaml";
    String newApiPath = "response/mediatypedeleted/petstore_v2.yaml";
    ResponseMediaTypeDeletedBreakingChange bc = new ResponseMediaTypeDeletedBreakingChange("/pet/findByStatus", HttpMethod.GET, new MediaType("application/json"));
    Collection<BreakingChange> expected = Collections.singleton(bc);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(1);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testRequestTypeChangeIsBreakingChangeWhenDifferentTypeIsUsedWithDifferentAttributes() {
    // given
    String oldApiPath = "request/differenttypesdifferentattributes/petstore.yaml";
    String newApiPath = "request/differenttypesdifferentattributes/petstore_v2.yaml";
    RequestTypeAttributeRemovedBreakingChange bc1 = new RequestTypeAttributeRemovedBreakingChange("/pet", HttpMethod.POST, "category");
    RequestTypeAttributeRemovedBreakingChange bc2 = new RequestTypeAttributeRemovedBreakingChange("/pet", HttpMethod.POST, "category.id");
    RequestTypeAttributeRemovedBreakingChange bc3 = new RequestTypeAttributeRemovedBreakingChange("/pet", HttpMethod.POST, "category.name");
    Collection<BreakingChange> expected = Arrays.asList(bc1, bc2, bc3);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(3);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testRequestMediaTypeDeletedWorksCorrectly() {
    // given
    String oldApiPath = "request/mediatypedeleted/petstore.yaml";
    String newApiPath = "request/mediatypedeleted/petstore_v2.yaml";
    RequestMediaTypeDeletedBreakingChange bc = new RequestMediaTypeDeletedBreakingChange("/pet", HttpMethod.POST, new MediaType("application/xml"));
    Collection<BreakingChange> expected = Collections.singleton(bc);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(1);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testRequestTypeEnumValueDeletedWorksCorrectly() {
    // given
    String oldApiPath = "request/typeenumvaluedeleted/petstore.yaml";
    String newApiPath = "request/typeenumvaluedeleted/petstore_v2.yaml";
    RequestTypeEnumValueDeletedBreakingChange bc1 = new RequestTypeEnumValueDeletedBreakingChange("/store/order", HttpMethod.POST, "status.approved");
    ResponseTypeEnumValueDeletedBreakingChange bc2 = new ResponseTypeEnumValueDeletedBreakingChange("/store/order", HttpMethod.POST, "status.approved");
    ResponseTypeEnumValueDeletedBreakingChange bc3 = new ResponseTypeEnumValueDeletedBreakingChange("/store/order/{orderId}", HttpMethod.GET, "status.approved");
    Collection<BreakingChange> expected = Arrays.asList(bc1, bc2, bc3);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(3);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testResponseTypeEnumValueDeletedWorksCorrectly() {
    // given
    String oldApiPath = "response/typeenumvaluedeleted/petstore.yaml";
    String newApiPath = "response/typeenumvaluedeleted/petstore_v2.yaml";
    RequestTypeEnumValueDeletedBreakingChange bc1 = new RequestTypeEnumValueDeletedBreakingChange("/store/order", HttpMethod.POST, "status.approved");
    ResponseTypeEnumValueDeletedBreakingChange bc2 = new ResponseTypeEnumValueDeletedBreakingChange("/store/order", HttpMethod.POST, "status.approved");
    ResponseTypeEnumValueDeletedBreakingChange bc3 = new ResponseTypeEnumValueDeletedBreakingChange("/store/order/{orderId}", HttpMethod.GET, "status.approved");
    Collection<BreakingChange> expected = Arrays.asList(bc1, bc2, bc3);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(3);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
  public void testResponseTypeChangeIsBreakingChangeWhenDifferentTypeIsUsedWithDifferentAttributes() {
    // given
    String oldApiPath = "response/differenttypesdifferentattributes/petstore.yaml";
    String newApiPath = "response/differenttypesdifferentattributes/petstore_v2.yaml";
    ResponseTypeAttributeRemovedBreakingChange bc1 = new ResponseTypeAttributeRemovedBreakingChange("/pet/findByStatus", HttpMethod.GET, "200", "category");
    ResponseTypeAttributeRemovedBreakingChange bc2 = new ResponseTypeAttributeRemovedBreakingChange("/pet/findByStatus", HttpMethod.GET, "200", "category.id");
    ResponseTypeAttributeRemovedBreakingChange bc3 = new ResponseTypeAttributeRemovedBreakingChange("/pet/findByStatus", HttpMethod.GET, "200", "category.name");
    Collection<BreakingChange> expected = Arrays.asList(bc1, bc2, bc3);
    // when
    Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
    // then
    assertThat(result).hasSize(3);
    assertThat(result).hasSameElementsAs(expected);
  }
}

代码示例来源:origin: redskap/swagger-brake

@Test
public void testResponseTypeChangeIsBreakingChangeWhenExistingDeepAttributeRemoved() {
  // given
  String oldApiPath = "response/deepattributeremoved/petstore.yaml";
  String newApiPath = "response/deepattributeremoved/petstore_v2.yaml";
  ResponseTypeAttributeRemovedBreakingChange bc1 = new ResponseTypeAttributeRemovedBreakingChange("/pet/findByStatus", HttpMethod.GET, "200", "category.name");
  ResponseTypeAttributeRemovedBreakingChange bc2 = new ResponseTypeAttributeRemovedBreakingChange("/pet/{petId}", HttpMethod.GET, "200", "category.name");
  ResponseTypeAttributeRemovedBreakingChange bc3 = new ResponseTypeAttributeRemovedBreakingChange("/pet/findByTags", HttpMethod.GET, "200", "category.name");
  RequestTypeAttributeRemovedBreakingChange bc4 = new RequestTypeAttributeRemovedBreakingChange("/pet", HttpMethod.PUT, "category.name");
  RequestTypeAttributeRemovedBreakingChange bc5 = new RequestTypeAttributeRemovedBreakingChange("/pet", HttpMethod.POST, "category.name");
  Collection<BreakingChange> expected = Arrays.asList(bc1, bc2, bc3, bc4, bc5);
  // when
  Collection<BreakingChange> result = execute(oldApiPath, newApiPath);
  // then
  assertThat(result).hasSize(5);
  assertThat(result).hasSameElementsAs(expected);
}

相关文章

微信公众号

最新文章

更多