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

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

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

IterableAssert.isSameAs介绍

暂无

代码示例

代码示例来源:origin: apache/geode

@Test
public void getPartitionedRegionsWithApplicationWorks() {
 when(delegate.getPartitionedRegions()).thenReturn(applicationRegions);
 Set result = cache.getPartitionedRegions();
 assertThat(result).isSameAs(applicationRegions);
}

代码示例来源:origin: apache/geode

@Test
public void rootRegionsWithParameterWithApplicationWorks() {
 when(delegate.rootRegions(true)).thenReturn(applicationRegions);
 Set result = cache.rootRegions(true);
 assertThat(result).isSameAs(applicationRegions);
}

代码示例来源:origin: apache/geode

@Test
public void getAllRegionsWithApplicationWorks() {
 when(delegate.getAllRegions()).thenReturn(applicationRegions);
 Set result = cache.getAllRegions();
 assertThat(result).isSameAs(applicationRegions);
}

代码示例来源:origin: apache/geode

@Test
public void rootRegionsWithApplicationWorks() {
 when(delegate.rootRegions()).thenReturn(applicationRegions);
 Set result = cache.rootRegions();
 assertThat(result).isSameAs(applicationRegions);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
 public void underTest_returns_inputFactory_which_caches_loaded_issues() {
  String componentUuid = randomAlphanumeric(12);
  ReportComponent component = ReportComponent.builder(Component.Type.FILE, 1).setUuid(componentUuid).build();
  when(movedFilesRepository.getOriginalFile(component)).thenReturn(Optional.absent());

  Input<DefaultIssue> input = underTest.create(component);

  verifyZeroInteractions(dbClient, issuesLoader);

  List<DefaultIssue> issues = ImmutableList.of(new DefaultIssue());
  when(issuesLoader.loadClosedIssues(componentUuid)).thenReturn(issues);

  assertThat(input.getIssues()).isSameAs(issues);

  reset(issuesLoader);

  assertThat(input.getIssues()).isSameAs(issues);
  verifyZeroInteractions(issuesLoader);
 }
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void returnsDelegateAttributes() throws Exception {
  List sources = new ArrayList();
  MethodSecurityMetadataSource delegate = mock(MethodSecurityMetadataSource.class);
  ConfigAttribute ca = mock(ConfigAttribute.class);
  List attributes = Arrays.asList(ca);
  Method toString = String.class.getMethod("toString");
  when(delegate.getAttributes(toString, String.class)).thenReturn(attributes);
  sources.add(delegate);
  mds = new DelegatingMethodSecurityMetadataSource(sources);
  assertThat(mds.getMethodSecurityMetadataSources()).isSameAs(sources);
  assertThat(mds.getAllConfigAttributes().isEmpty()).isTrue();
  MethodInvocation mi = new SimpleMethodInvocation("", toString);
  assertThat(mds.getAttributes(mi)).isSameAs(attributes);
  // Exercise the cached case
  assertThat(mds.getAttributes(mi)).isSameAs(attributes);
  assertThat(mds.getAttributes(
      new SimpleMethodInvocation(null, String.class.getMethod("length")))).isEmpty();
}

代码示例来源:origin: spring-projects/spring-security

@Test
  public void gettersReturnCtorSuppliedData() throws Exception {
    AuthorizationFailureEvent event = new AuthorizationFailureEvent(new Object(),
        attributes, foo, exception);
    assertThat(event.getConfigAttributes()).isSameAs(attributes);
    assertThat(event.getAccessDeniedException()).isSameAs(exception);
    assertThat(event.getAuthentication()).isSameAs(foo);
  }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void underTest_returns_inputFactory_loading_closed_issues_only_when_getIssues_is_called() {
 String componentUuid = randomAlphanumeric(12);
 ReportComponent component = ReportComponent.builder(Component.Type.FILE, 1).setUuid(componentUuid).build();
 when(movedFilesRepository.getOriginalFile(component)).thenReturn(Optional.absent());
 Input<DefaultIssue> input = underTest.create(component);
 verifyZeroInteractions(dbClient, issuesLoader);
 List<DefaultIssue> issues = ImmutableList.of(new DefaultIssue(), new DefaultIssue());
 when(issuesLoader.loadClosedIssues(componentUuid)).thenReturn(issues);
 assertThat(input.getIssues()).isSameAs(issues);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void creates_returns_always_the_same_instance_of_maxScore_is_less_than_min_required_score() {
 ScoreFile[] doesNotMatterRemovedFiles = new ScoreFile[0];
 ScoreFile[] doesNotMatterNewFiles = new ScoreFile[0];
 int[][] doesNotMatterScores = new int[0][0];
 ScoreMatrix scoreMatrix1 = new ScoreMatrix(doesNotMatterRemovedFiles, doesNotMatterNewFiles, doesNotMatterScores, MIN_REQUIRED_SCORE - 1);
 MatchesByScore matchesByScore = MatchesByScore.create(scoreMatrix1);
 assertThat(matchesByScore.getSize()).isEqualTo(0);
 assertThat(matchesByScore).isEmpty();
 ScoreMatrix scoreMatrix2 = new ScoreMatrix(doesNotMatterRemovedFiles, doesNotMatterNewFiles, doesNotMatterScores, MIN_REQUIRED_SCORE - 5);
 assertThat(MatchesByScore.create(scoreMatrix2)).isSameAs(matchesByScore);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void underTest_returns_inputFactory_loading_closed_issues_from_moved_component_when_present() {
 String componentUuid = randomAlphanumeric(12);
 String originalComponentUuid = randomAlphanumeric(12);
 ReportComponent component = ReportComponent.builder(Component.Type.FILE, 1).setUuid(componentUuid).build();
 when(movedFilesRepository.getOriginalFile(component))
  .thenReturn(Optional.of(new MovedFilesRepository.OriginalFile(1, originalComponentUuid, randomAlphanumeric(2))));
 Input<DefaultIssue> input = underTest.create(component);
 verifyZeroInteractions(dbClient, issuesLoader);
 List<DefaultIssue> issues = ImmutableList.of();
 when(issuesLoader.loadClosedIssues(originalComponentUuid)).thenReturn(issues);
 assertThat(input.getIssues()).isSameAs(issues);
}

代码示例来源:origin: apache/geode

@Test
public void getNotReachedReturnsIdenticalResults() {
 MemoryThresholdInfo info1 = MemoryThresholdInfo.getNotReached();
 MemoryThresholdInfo info2 = MemoryThresholdInfo.getNotReached();
 assertThat(info1).isSameAs(info2);
 assertThat(info1.getMembersThatReachedThreshold())
   .isSameAs(info2.getMembersThatReachedThreshold());
}

代码示例来源:origin: springside/springside4

assertThat(set3).isSameAs(set1);

代码示例来源:origin: hcoles/pitest

@Test
public void shouldNotMarkAnyMutationsInClassWithoutStaticInitializer() {
 final Class<?> clazz = NoStaticInializer.class;
 final List<MutationDetails> mutations = findMutationsFor(clazz);
 this.testee.begin(treeFor(clazz));
 final Collection<MutationDetails> actual = this.testee.intercept(mutations, this.mutator);
 this.testee.end();
 assertThat(actual).isSameAs(mutations);
}

代码示例来源:origin: hcoles/pitest

@Test
public void shouldReturnMutantListUnmodified() {
 final Collection<MutationDetails> mutations = this.mutator.findMutations(ClassName.fromClass(VeryMutable.class));
 this.testee.begin(tree(VeryMutable.class));
 final Collection<MutationDetails> actual = this.testee.intercept(mutations, this.mutator);
 this.testee.end();
 assertThat(actual).isSameAs(mutations);
}

代码示例来源:origin: com.datastax.oss/native-protocol

@Test
 public void should_return_singleton_empty_instance() {
  NullAllowingImmutableSet<Integer> s1 = NullAllowingImmutableSet.of();
  NullAllowingImmutableSet<Integer> s2 = NullAllowingImmutableSet.of();
  assertThat(s1).isSameAs(s2);
 }
}

代码示例来源:origin: zanata/zanata-platform

private void assertChildClass(ChildClass original, ChildClass clone,
    boolean expectNewRef) {
  if (expectNewRef) {
    assertThat(clone).isNotSameAs(original);
    assertThat(clone.getId()).isNotEqualTo(original.getId());
    assertThat(clone.getTestList()).isNotSameAs(original.getTestList());
    assertThat(clone.getTestSet()).isNotSameAs(original.getTestSet());
    assertThat(clone.getTestMap()).isNotSameAs(original.getTestMap());
  } else {
    assertThat(clone.getId()).isEqualTo(original.getId());
    assertThat(clone.getTestList()).isSameAs(original.getTestList());
    assertThat(clone.getTestSet()).isSameAs(original.getTestSet());
    assertThat(clone.getTestMap()).isSameAs(original.getTestMap());
  }
  assertThat(clone.getTestString()).isEqualTo(original.getTestString());
  assertThat(clone.getTestList()).isEqualTo(original.getTestList());
  assertThat(clone.getTestSet()).isEqualTo(original.getTestSet());
  assertThat(clone.getTestMap()).isEqualTo(original.getTestMap());
}

代码示例来源:origin: line/centraldogma

@Test
public void ofJson() throws Exception {
  final Entry<JsonNode> e = Entry.ofJson(new Revision(1), "/a.json", "{ \"foo\": \"bar\" }");
  assertThat(e.revision()).isEqualTo(new Revision(1));
  assertThat(e.hasContent()).isTrue();
  e.ifHasContent(content -> assertThatJson(content).isEqualTo("{ \"foo\": \"bar\" }"));
  assertThatJson(e.content()).isEqualTo("{ \"foo\": \"bar\" }");
  assertThat(e.contentAsText()).isEqualTo("{\"foo\":\"bar\"}");
  assertThat(e.contentAsPrettyText()).isEqualTo("{\n  \"foo\": \"bar\"\n}");
  assertThat(e.content()).isSameAs(e.contentAsJson());
  assertThat(e.content()).isEqualTo(e.contentAsJson(JsonNode.class));
  // JSON file vs. JSON file
  final Entry<JsonNode> e2 = Entry.ofJson(new Revision(1), "/a.json", "{ \"foo\": \"bar\" }");
  assertThat(e).isEqualTo(e2);
  assertThat(e.hashCode()).isEqualTo(e2.hashCode());
  assertThat(e).isNotEqualTo(Entry.ofJson(new Revision(2), "/a.json", "{ \"foo\": \"bar\" }"));
  assertThat(e).isNotEqualTo(Entry.ofJson(new Revision(1), "/b.json", "{ \"foo\": \"bar\" }"));
  assertThat(e).isNotEqualTo(Entry.ofJson(new Revision(1), "/a.json", "null"));
  // JSON file vs. text file
  final Entry<String> e3 = Entry.ofText(new Revision(1), "/a.json", "{\"foo\":\"bar\"}");
  assertThat(e).isNotEqualTo(e3);
  assertThat(e.hashCode()).isNotEqualTo(e3.hashCode());
  // JSON file vs. directory
  final Entry<Void> e4 = Entry.ofDirectory(new Revision(1), "/foo");
  assertThat(e).isNotEqualTo(e4);
  assertThat(e.hashCode()).isNotEqualTo(e4.hashCode());
}

相关文章

微信公众号

最新文章

更多