• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ReflectionEquals类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: foundHeroesShouldContainFrodoAndGandalf

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void foundHeroesShouldContainFrodoAndGandalf() {

	// given
	when(characterRepository.getFellowshipOfTheRing()).thenReturn(fellowshipOfTheRing);

	// when
	List<Character> heroes = tolkienService.getFellowshipOfTheRing();

	// then
	assertThat(heroes,
                  hasItems(new ReflectionEquals(new Character("Frodo",
                                                              HOBBIT,
                                                              LocalDate.of(2968, Month.SEPTEMBER, 22))),
                           new ReflectionEquals(new Character("Gandalf", MAIAR, LocalDate.MIN))));
}
 
开发者ID:lpandzic,项目名称:assertj-workshop,代码行数:17,代码来源:CollectionAssertionsTest.java


示例2: pollFirstMultiple

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void pollFirstMultiple() {
    map.put(IDENTIFIER, blockDefinitionsWithBothNodes);

    assertThat(map.get(IDENTIFIER).size(), is(2));

    Optional<BlockDefinition> definition1 = underTest.pollFirst(IDENTIFIER);
    assertThat(definition1.isPresent(), is(true));
    assertThat(definition1.get(), new ReflectionEquals(blockDefinition1));

    assertThat(map.get(IDENTIFIER).size(), is(1));

    Optional<BlockDefinition> definition2 = underTest.pollFirst(IDENTIFIER);
    assertThat(definition2.isPresent(), is(true));
    assertThat(definition2.get(), new ReflectionEquals(blockDefinition2));

    assertThat(map.get(IDENTIFIER).size(), is(0));
}
 
开发者ID:jtwig,项目名称:jtwig-core,代码行数:19,代码来源:BlockContextTest.java


示例3: assertGetJobExecutionShardingContextWhenNotAssignShardingItem

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void assertGetJobExecutionShardingContextWhenNotAssignShardingItem() {
    when(configService.getShardingTotalCount()).thenReturn(3);
    when(configService.isFailover()).thenReturn(false);
    when(configService.isMonitorExecution()).thenReturn(false);
    when(configService.getFetchDataCount()).thenReturn(10);
    JobExecutionMultipleShardingContext expected = new JobExecutionMultipleShardingContext();
    expected.setJobName("testJob");
    expected.setShardingTotalCount(3);
    expected.setFetchDataCount(10);
    assertThat(executionContextService.getJobExecutionShardingContext(Collections.<Integer>emptyList()), new ReflectionEquals(expected));
    verify(configService).getShardingTotalCount();
    verify(configService).isMonitorExecution();
    verify(configService).getFetchDataCount();
}
 
开发者ID:artoderk,项目名称:elastic-jobx,代码行数:16,代码来源:ExecutionContextServiceTest.java


示例4: assertGetJobExecutionShardingContextWhenAssignShardingItems

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void assertGetJobExecutionShardingContextWhenAssignShardingItems() {
    when(configService.getShardingTotalCount()).thenReturn(3);
    when(configService.isFailover()).thenReturn(false);
    when(configService.isMonitorExecution()).thenReturn(false);
    when(configService.getFetchDataCount()).thenReturn(10);
    Map<Integer, String> shardingItemParameters = new HashMap<Integer, String>(3);
    shardingItemParameters.put(0, "A");
    shardingItemParameters.put(1, "B");
    shardingItemParameters.put(2, "C");
    when(configService.getShardingItemParameters()).thenReturn(shardingItemParameters);
    Map<Integer, String> offsets = new HashMap<Integer, String>(2);
    offsets.put(0, "offset0");
    offsets.put(1, "offset1");
    when(offsetService.getOffsets(Arrays.asList(0, 1))).thenReturn(offsets);
    JobExecutionMultipleShardingContext expected = new JobExecutionMultipleShardingContext();
    expected.setJobName("testJob");
    expected.setShardingTotalCount(3);
    expected.setFetchDataCount(10);
    expected.setShardingItems(Arrays.asList(0, 1));
    expected.getShardingItemParameters().put(0, "A");
    expected.getShardingItemParameters().put(1, "B");
    expected.setOffsets(offsets);
    assertThat(executionContextService.getJobExecutionShardingContext(Arrays.asList(0, 1)), new ReflectionEquals(expected));
    verify(configService).getShardingTotalCount();
    verify(configService).isMonitorExecution();
    verify(configService).getFetchDataCount();
    verify(configService).getShardingItemParameters();
    verify(offsetService).getOffsets(Arrays.asList(0, 1));
}
 
开发者ID:artoderk,项目名称:elastic-jobx,代码行数:31,代码来源:ExecutionContextServiceTest.java


示例5: assertGetJobExecutionShardingContextWhenHasRunningItems

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void assertGetJobExecutionShardingContextWhenHasRunningItems() {
    when(configService.getShardingTotalCount()).thenReturn(3);
    when(configService.isFailover()).thenReturn(true);
    when(configService.isMonitorExecution()).thenReturn(true);
    when(jobNodeStorage.isJobNodeExisted("execution/0/running")).thenReturn(false);
    when(jobNodeStorage.isJobNodeExisted("execution/1/running")).thenReturn(true);
    when(configService.getFetchDataCount()).thenReturn(10);
    Map<Integer, String> shardingItemParameters = new HashMap<Integer, String>(3);
    shardingItemParameters.put(0, "A");
    shardingItemParameters.put(1, "B");
    shardingItemParameters.put(2, "C");
    when(configService.getShardingItemParameters()).thenReturn(shardingItemParameters);
    Map<Integer, String> offsets = new HashMap<Integer, String>(1);
    offsets.put(0, "offset0");
    when(offsetService.getOffsets(Collections.singletonList(0))).thenReturn(offsets);
    JobExecutionMultipleShardingContext expected = new JobExecutionMultipleShardingContext();
    expected.setJobName("testJob");
    expected.setShardingTotalCount(3);
    expected.setFetchDataCount(10);
    expected.setShardingItems(Collections.singletonList(0));
    expected.getShardingItemParameters().put(0, "A");
    expected.setMonitorExecution(true);
    expected.setOffsets(offsets);
    assertThat(executionContextService.getJobExecutionShardingContext(Lists.newArrayList(0, 1)), new ReflectionEquals(expected));
    verify(configService).getShardingTotalCount();
    verify(configService).isMonitorExecution();
    verify(jobNodeStorage).isJobNodeExisted("execution/0/running");
    verify(jobNodeStorage).isJobNodeExisted("execution/1/running");
    verify(configService).getFetchDataCount();
    verify(configService).getShardingItemParameters();
    verify(offsetService).getOffsets(Collections.singletonList(0));
}
 
开发者ID:artoderk,项目名称:elastic-jobx,代码行数:34,代码来源:ExecutionContextServiceTest.java


示例6: assertGetJobExecutionShardingContextWhenAssignShardingItems

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void assertGetJobExecutionShardingContextWhenAssignShardingItems() {
    when(configService.getShardingTotalCount()).thenReturn(3);
    when(configService.isFailover()).thenReturn(false);
    when(configService.isMonitorExecution()).thenReturn(false);
    when(configService.getFetchDataCount()).thenReturn(10);
    Map<Integer, String> shardingItemParameters = new HashMap<>(3);
    shardingItemParameters.put(0, "A");
    shardingItemParameters.put(1, "B");
    shardingItemParameters.put(2, "C");
    when(configService.getShardingItemParameters()).thenReturn(shardingItemParameters);
    Map<Integer, String> offsets = new HashMap<>(2);
    offsets.put(0, "offset0");
    offsets.put(1, "offset1");
    when(offsetService.getOffsets(Arrays.asList(0, 1))).thenReturn(offsets);
    JobExecutionMultipleShardingContext expected = new JobExecutionMultipleShardingContext();
    expected.setJobName("testJob");
    expected.setShardingTotalCount(3);
    expected.setFetchDataCount(10);
    expected.setShardingItems(Arrays.asList(0, 1));
    expected.getShardingItemParameters().put(0, "A");
    expected.getShardingItemParameters().put(1, "B");
    expected.setOffsets(offsets);
    assertThat(executionContextService.getJobExecutionShardingContext(Arrays.asList(0, 1)), new ReflectionEquals(expected));
    verify(configService).getShardingTotalCount();
    verify(configService).isMonitorExecution();
    verify(configService).getFetchDataCount();
    verify(configService).getShardingItemParameters();
    verify(offsetService).getOffsets(Arrays.asList(0, 1));
}
 
开发者ID:zhoujia123,项目名称:ElasticJob,代码行数:31,代码来源:ExecutionContextServiceTest.java


示例7: assertGetJobExecutionShardingContextWhenHasRunningItems

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void assertGetJobExecutionShardingContextWhenHasRunningItems() {
    when(configService.getShardingTotalCount()).thenReturn(3);
    when(configService.isFailover()).thenReturn(true);
    when(configService.isMonitorExecution()).thenReturn(true);
    when(jobNodeStorage.isJobNodeExisted("execution/0/running")).thenReturn(false);
    when(jobNodeStorage.isJobNodeExisted("execution/1/running")).thenReturn(true);
    when(configService.getFetchDataCount()).thenReturn(10);
    Map<Integer, String> shardingItemParameters = new HashMap<>(3);
    shardingItemParameters.put(0, "A");
    shardingItemParameters.put(1, "B");
    shardingItemParameters.put(2, "C");
    when(configService.getShardingItemParameters()).thenReturn(shardingItemParameters);
    Map<Integer, String> offsets = new HashMap<>(1);
    offsets.put(0, "offset0");
    when(offsetService.getOffsets(Collections.singletonList(0))).thenReturn(offsets);
    JobExecutionMultipleShardingContext expected = new JobExecutionMultipleShardingContext();
    expected.setJobName("testJob");
    expected.setShardingTotalCount(3);
    expected.setFetchDataCount(10);
    expected.setShardingItems(Collections.singletonList(0));
    expected.getShardingItemParameters().put(0, "A");
    expected.setMonitorExecution(true);
    expected.setOffsets(offsets);
    assertThat(executionContextService.getJobExecutionShardingContext(Lists.newArrayList(0, 1)), new ReflectionEquals(expected));
    verify(configService).getShardingTotalCount();
    verify(configService).isMonitorExecution();
    verify(jobNodeStorage).isJobNodeExisted("execution/0/running");
    verify(jobNodeStorage).isJobNodeExisted("execution/1/running");
    verify(configService).getFetchDataCount();
    verify(configService).getShardingItemParameters();
    verify(offsetService).getOffsets(Collections.singletonList(0));
}
 
开发者ID:zhoujia123,项目名称:ElasticJob,代码行数:34,代码来源:ExecutionContextServiceTest.java


示例8: addLastMultiple

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void addLastMultiple() throws Exception {
    underTest.addLast(blockNode1, resourceReference1);
    underTest.addLast(blockNode2, resourceReference2);

    assertThat(map.get(IDENTIFIER).get(0), new ReflectionEquals(blockDefinition1));
    assertThat(map.get(IDENTIFIER).get(1), new ReflectionEquals(blockDefinition2));
}
 
开发者ID:jtwig,项目名称:jtwig-core,代码行数:9,代码来源:BlockContextTest.java


示例9: addFirstMultiple

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void addFirstMultiple() throws Exception {
    underTest.addFirst(blockNode1, resourceReference1);
    underTest.addFirst(blockNode2, resourceReference2);

    assertThat(map.get(IDENTIFIER).get(1), new ReflectionEquals(blockDefinition1));
    assertThat(map.get(IDENTIFIER).get(0), new ReflectionEquals(blockDefinition2));
}
 
开发者ID:jtwig,项目名称:jtwig-core,代码行数:9,代码来源:BlockContextTest.java


示例10: get

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void get() {
    map.put(IDENTIFIER, blockDefinitionsWithNode);

    Optional<BlockDefinition> definitionA = underTest.get(IDENTIFIER);
    assertThat(definitionA.isPresent(), is(true));
    assertThat(definitionA.get(), new ReflectionEquals(blockDefinition1));

    Optional<BlockDefinition> definitionB = underTest.get(IDENTIFIER, 0);
    assertThat(definitionB.isPresent(), is(true));
    assertThat(definitionB.get(), new ReflectionEquals(blockDefinition1));
}
 
开发者ID:jtwig,项目名称:jtwig-core,代码行数:13,代码来源:BlockContextTest.java


示例11: getMultiple

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void getMultiple() {
    map.put(IDENTIFIER, blockDefinitionsWithBothNodes);

    Optional<BlockDefinition> definition1 = underTest.get(IDENTIFIER, 0);
    assertThat(definition1.isPresent(), is(true));
    assertThat(definition1.get(), new ReflectionEquals(blockDefinition1));

    Optional<BlockDefinition> definition2 = underTest.get(IDENTIFIER, 1);
    assertThat(definition2.isPresent(), is(true));
    assertThat(definition2.get(), new ReflectionEquals(blockDefinition2));
}
 
开发者ID:jtwig,项目名称:jtwig-core,代码行数:13,代码来源:BlockContextTest.java


示例12: testSaveResourceCredentials

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void testSaveResourceCredentials() throws Exception {
    final APIResourceCredentials credentials1 = new APIResourceCredentials(TestUtils.LOCAL_USER_ID, "tempToken1", "tempTokenSecret1");
    final APIResourceCredentials credentials2 = new APIResourceCredentials(TestUtils.LOCAL_USER_ID, "tempToken2", "tempTokenSecret2");
    this.fitbitApiCredentialsCacheOdb.saveResourceCredentials(TestUtils.LOCAL_USER_DETAIL, credentials1);
    assertTrue(new ReflectionEquals(credentials1).matches(this.fitbitApiCredentialsCacheOdb.getResourceCredentials(TestUtils.LOCAL_USER_DETAIL)));
    this.fitbitApiCredentialsCacheOdb.saveResourceCredentials(TestUtils.LOCAL_USER_DETAIL, credentials2);
    assertTrue(new ReflectionEquals(credentials2).matches(this.fitbitApiCredentialsCacheOdb.getResourceCredentials(TestUtils.LOCAL_USER_DETAIL)));
}
 
开发者ID:Regisc,项目名称:fitbit-bat,代码行数:10,代码来源:FitbitApiCredentialsCacheOdbTest.java


示例13: assertObjectEquals

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
/**
 * Without this method we would need to override equals() and .hashcode() for each object, which explodes code and makes it less maintainable
 */
public <T> void assertObjectEquals(final T expected, final T actual) {
    assertTrue("Expected:\n" + expected + "\nactual:\n" + actual, new ReflectionEquals(actual, (String[])null).matches(expected));
}
 
开发者ID:EXASOL,项目名称:virtual-schemas,代码行数:7,代码来源:RequestJsonParserTest.java


示例14: addLast

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void addLast() throws Exception {
    underTest.addLast(blockNode1, resourceReference1);

    assertThat(map.get(IDENTIFIER).peek(), new ReflectionEquals(blockDefinition1));
}
 
开发者ID:jtwig,项目名称:jtwig-core,代码行数:7,代码来源:BlockContextTest.java


示例15: addLastFirst

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void addLastFirst() throws Exception {
    underTest.addFirst(blockNode1, resourceReference1);

    assertThat(map.get(IDENTIFIER).peek(), new ReflectionEquals(blockDefinition1));
}
 
开发者ID:jtwig,项目名称:jtwig-core,代码行数:7,代码来源:BlockContextTest.java


示例16: testGetResourceCredentials

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void testGetResourceCredentials() throws Exception {
    assertNull(this.fitbitApiCredentialsCacheOdb.getResourceCredentials(TestUtils.LOCAL_USER_DETAIL));
    this.fitbitApiCredentialsCacheOdb.saveResourceCredentials(TestUtils.LOCAL_USER_DETAIL, this.apiResourceCredentials);
    assertTrue(new ReflectionEquals(this.apiResourceCredentials).matches(this.fitbitApiCredentialsCacheOdb.getResourceCredentials(TestUtils.LOCAL_USER_DETAIL)));
}
 
开发者ID:Regisc,项目名称:fitbit-bat,代码行数:7,代码来源:FitbitApiCredentialsCacheOdbTest.java


示例17: testGetResourceCredentialsByTempToken

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
@Test
public void testGetResourceCredentialsByTempToken() throws Exception {
    this.fitbitApiCredentialsCacheOdb.saveResourceCredentials(TestUtils.LOCAL_USER_DETAIL, this.apiResourceCredentials);
    assertTrue(new ReflectionEquals(this.apiResourceCredentials).matches(this.fitbitApiCredentialsCacheOdb.getResourceCredentialsByTempToken("tempToken")));
}
 
开发者ID:Regisc,项目名称:fitbit-bat,代码行数:6,代码来源:FitbitApiCredentialsCacheOdbTest.java


示例18: refEq

import org.mockito.internal.matchers.apachecommons.ReflectionEquals; //导入依赖的package包/类
/**
 * Object argument that is reflection-equal to the given value with support for excluding
 * selected fields from a class.
 * <p>
 * This matcher can be used when equals() is not implemented on compared objects.
 * Matcher uses java reflection API to compare fields of wanted and actual object.
 * <p>
 * Works similarly to EqualsBuilder.reflectionEquals(this, other, exlucdeFields) from
 * apache commons library.
 * <p>
 * <b>Warning</b> The equality check is shallow!
 * <p>
 * See examples in javadoc for {@link Matchers} class
 * 
 * @param value
 *            the given value.
 * @param excludeFields
 *            fields to exclude, if field does not exist it is ignored.
 * @return <code>null</code>.
 */
public static <T> T refEq(T value, String... excludeFields) {
    return reportMatcher(new ReflectionEquals(value, excludeFields)).<T>returnNull();
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:24,代码来源:Matchers.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Pack类代码示例发布时间:2022-05-23
下一篇:
Java Term类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap