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


Java Is类代码示例

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


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

示例1: refresh

import org.hamcrest.core.Is; //导入依赖的package包/类
@Test
public void refresh() throws Exception {
    final Reddit reddit = new Reddit();
    PublishSubject<Reddit> subject = PublishSubject.create();
    Mockito.doReturn(subject.asObservable().toList())
            .when(mRepository)
            .getReddits(Mockito.anyString());
    mViewModel.refresh();
    Mockito.verify(mRepository).getReddits("test");
    Assert.assertThat(mViewModel.errorText.get(), IsNull.nullValue());
    Assert.assertThat(mViewModel.isLoading.get(), Is.is(true));
    subject.onNext(reddit);
    subject.onCompleted();
    Assert.assertThat(mViewModel.isLoading.get(), Is.is(false));
    Assert.assertThat(mViewModel.reddits, IsCollectionContaining.hasItems(reddit));
}
 
开发者ID:DanielSerdyukov,项目名称:droidcon2016,代码行数:17,代码来源:RedditListViewModelTest.java

示例2: searchQueryChange

import org.hamcrest.core.Is; //导入依赖的package包/类
@Test
public void searchQueryChange() throws Exception {
    final Subreddit subreddit = new Subreddit();
    PublishSubject<Subreddit> subject = PublishSubject.create();
    Mockito.doReturn(subject.asObservable().toList())
            .when(mRepository)
            .searchSubreddits(Mockito.anyString());
    mViewModel.subscribeOnSearchQueryChange();
    mViewModel.mSearchQuery.onNext("test");
    Mockito.verify(mRepository).searchSubreddits("test");
    Assert.assertThat(mViewModel.isLoading.get(), Is.is(true));
    subject.onNext(subreddit);
    subject.onCompleted();
    Assert.assertThat(mViewModel.isLoading.get(), Is.is(false));
    Assert.assertThat(mViewModel.subreddits, IsCollectionContaining.hasItems(subreddit));
}
 
开发者ID:DanielSerdyukov,项目名称:droidcon2016,代码行数:17,代码来源:MainViewModelTest.java

示例3: persistsEvent

import org.hamcrest.core.Is; //导入依赖的package包/类
@Test
public void persistsEvent() {
  asyncStub.onConnected(serviceConfig, compensateResponseObserver);
  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()));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-saga,代码行数:21,代码来源:AlphaIntegrationTest.java

示例4: testSaveStateWithoutInstantiatedFragments

import org.hamcrest.core.Is; //导入依赖的package包/类
@Test
@SuppressWarnings("ConstantConditions")
public void testSaveStateWithoutInstantiatedFragments() {
	final FragmentManager mockFragmentManager = mock(FragmentManager.class);
	final FragmentStatePagerAdapter adapter = new Adapter(mockFragmentManager);
	final Bundle restoreState = new Bundle();
	final Fragment.SavedState mockFragmentState = mock(Fragment.SavedState.class);
	final long itemId = adapter.getItemId(0);
	restoreState.putParcelable("android:pager:fragment_state:" + itemId, mockFragmentState);
	restoreState.putLongArray(FragmentStatePagerAdapter.STATE_FRAGMENT_STATES, new long[]{itemId});
	adapter.restoreState(restoreState, Adapter.class.getClassLoader());
	final Parcelable state = adapter.saveState();
	assertThat(state, is(not(nullValue())));
	assertThat(state, instanceOf(Bundle.class));
	final Bundle savedState = (Bundle) state;
	final long[] savedStateIds = savedState.getLongArray(FragmentStatePagerAdapter.STATE_FRAGMENT_STATES);
	assertThat(savedStateIds, is(not(nullValue())));
	assertThat(savedStateIds.length, is(1));
	assertThat(savedStateIds[0], is(itemId));
	assertThat(savedState.getParcelable("android:pager:fragment_state:" + itemId), Is.<Parcelable>is(mockFragmentState));
}
 
开发者ID:universum-studios,项目名称:android_pager_adapters,代码行数:22,代码来源:FragmentStatePagerAdapterTest.java

示例5: refreshError

import org.hamcrest.core.Is; //导入依赖的package包/类
@Test
public void refreshError() throws Exception {
    PublishSubject<Reddit> subject = PublishSubject.create();
    Mockito.doReturn(subject.asObservable().toList())
            .when(mRepository)
            .getReddits(Mockito.anyString());
    mViewModel.refresh();
    Mockito.verify(mRepository).getReddits("test");
    Assert.assertThat(mViewModel.errorText.get(), IsNull.nullValue());
    Assert.assertThat(mViewModel.isLoading.get(), Is.is(true));
    subject.onError(new Exception("error text"));
    Assert.assertThat(mViewModel.isLoading.get(), Is.is(false));
    Assert.assertThat(mViewModel.errorText.get(), IsEqual.equalTo("error text"));
}
 
开发者ID:DanielSerdyukov,项目名称:droidcon2016,代码行数:15,代码来源:RedditListViewModelTest.java

示例6: testTabSwiping

import org.hamcrest.core.Is; //导入依赖的package包/类
/**
 * Tests swiping to change tabs
 */
public void testTabSwiping() {
    final Matcher<View> mealsTab = withText(R.string.meals);
    final Matcher<View> recipesTab = withText(R.string.recipes);
    final Matcher<View> mealList = withTagKey(R.id.test_tag_meal_list,
            Is.<Object>is("Meal List"));
    final Matcher<View> recipeList = withTagKey(R.id.test_tag_recipe_list,
            Is.<Object>is("Recipe List"));
    final Matcher<View> pager = withClassName(IsEqual.equalTo(ViewPager.class.getName()));

    onView(pager).perform(swipeLeft());
    SystemClock.sleep(SWITCH_DELAY_MS);
    onView(recipesTab).check(matches(isSelected()));
    onView(pager).perform(swipeRight());
    SystemClock.sleep(SWITCH_DELAY_MS);
    onView(mealsTab).check(matches(isSelected()));
}
 
开发者ID:Cook-E-team,项目名称:Cook-E,代码行数:20,代码来源:HomeActivityTest.java

示例7: testAddToExistingGroup

import org.hamcrest.core.Is; //导入依赖的package包/类
@Test
public void testAddToExistingGroup() {
    initiliase();
    ApplicationRegistrationMetadata metadata4 = new ApplicationRegistrationMetadata();
    metadata4.setId(4);
    metadata4.setName("API4");
    metadata4.setGroupId("za.co.moronicgeek.api4");
    metadata4.setSwaggerUrl("Another");
    registry.addApi(metadata4);
    Assert.assertThat(registry.sizeOf("za.co.moronicgeek.api4"), Is.is(1));
    ApiDefinition meta = registry.getMetadataByGroupId("za.co.moronicgeek.api4");

    ApplicationRegistrationMetadata metadata2 = new ApplicationRegistrationMetadata();
    metadata2.setId(4);
    metadata2.setName("API4");
    metadata2.setGroupId("za.co.moronicgeek.api4");
    metadata2.setSwaggerUrl("Dont care");
    registry.unRegisterApplication(metadata2);
    Assert.assertThat(registry.sizeOf("za.co.moronicgeek.api4"), Is.is(0));

}
 
开发者ID:moronicgeek,项目名称:SwaggerCloud,代码行数:22,代码来源:RegistryTest.java

示例8: testValidatePropertyTypes_objectClass

import org.hamcrest.core.Is; //导入依赖的package包/类
@Test
public void testValidatePropertyTypes_objectClass() throws Exception {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(Constants.OBJECTCLASS, "test");
    Map<String, Object> config = validatePropertyTypes(map);
    assertThat(config.containsKey(Constants.OBJECTCLASS), is(true));
    assertThat(config.get(Constants.OBJECTCLASS), Is.<Object>is(new String[]{"test"}));

    map = new HashMap<String, Object>();
    map.put(Constants.OBJECTCLASS, new String[]{"test"});
    config = validatePropertyTypes(map);
    assertThat(config.get(Constants.OBJECTCLASS), Is.<Object>is(new String[]{"test"}));

    map = new HashMap<String, Object>();
    map.put(Constants.OBJECTCLASS, singletonList("test"));
    config = validatePropertyTypes(map);
    assertThat(config.get(Constants.OBJECTCLASS), Is.<Object>is(new String[]{"test"}));
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:19,代码来源:PropertyValidatorTest.java

示例9: validateModel

import org.hamcrest.core.Is; //导入依赖的package包/类
@Override
protected void validateModel(CmmnModel model) {
    Case caseModel = model.getPrimaryCase();
    assertEquals("dmnExportCase", caseModel.getId());
    assertEquals("dmnExportCase", caseModel.getName());

    Stage planModelStage = caseModel.getPlanModel();
    assertNotNull(planModelStage);
    assertEquals("casePlanModel", planModelStage.getId());

    PlanItem planItem = planModelStage.findPlanItemInPlanFragmentOrUpwards("planItem1");
    assertNotNull(planItem);
    assertEquals("planItem1", planItem.getId());
    assertEquals("dmnTask", planItem.getName());
    PlanItemDefinition planItemDefinition = planItem.getPlanItemDefinition();
    assertNotNull(planItemDefinition);
    assertTrue(planItemDefinition instanceof DecisionTask);
    DecisionTask decisionTask = (DecisionTask) planItemDefinition;
    assertEquals("sid-F4BCA0C7-8737-4279-B50F-59272C7C65A2", decisionTask.getId());
    assertEquals("dmnTask", decisionTask.getName());

    FieldExtension fieldExtension = new FieldExtension();
    fieldExtension.setFieldName("decisionTaskThrowErrorOnNoHits");
    fieldExtension.setStringValue("false");
    assertThat(((DecisionTask) planItemDefinition).getFieldExtensions(), Is.is(Collections.singletonList(fieldExtension)));
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:27,代码来源:DecisionTaskJsonConverterTest.java

示例10: require_that_session_created_from_active_that_is_no_longer_active_cannot_be_activated

import org.hamcrest.core.Is; //导入依赖的package包/类
@Test
public void require_that_session_created_from_active_that_is_no_longer_active_cannot_be_activated() throws Exception {
    Clock clock = Clock.systemUTC();

    long sessionId = 1;
    activateAndAssertOK(1, 0, clock);
    sessionId++;
    activateAndAssertOK(sessionId, 1, clock);

    sessionId++;
    ActivateRequest activateRequest = new ActivateRequest(sessionId, 1, "", Clock.systemUTC()).invoke();
    HttpResponse actResponse = activateRequest.getActResponse();
    String message = getRenderedString(actResponse);
    assertThat(message, actResponse.getStatus(), Is.is(CONFLICT));
    assertThat(message,
               containsString("Cannot activate session 3 because the currently active session (2) has changed since session 3 was created (was 1 at creation time)"));
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:18,代码来源:SessionActiveHandlerTest.java

示例11: markProgressForUser

import org.hamcrest.core.Is; //导入依赖的package包/类
@Ignore
@Test
public void markProgressForUser() throws Exception {
    final ProgressService service = JujacoreProgressServiceIntegrationTest
        .injector.getInstance(ProgressService.class);
    final SpreadSheetReader spreadsheet =
        JujacoreProgressServiceIntegrationTest.injector.getInstance(
            Key.get(SpreadSheetReader.class, Names.named("progress"))
        );
    Cell cell = new GdataCell(
        spreadsheet, "viktorkuchyn", "log-код", "+lms"
    );
    cell.update("");
    service.markProgressDone(
        User.create().withSlackNick("viktorkuchyn").build(), "+lms"
    );
    cell = new GdataCell(spreadsheet, "viktorkuchyn", "log-код", "+lms");
    MatcherAssert.assertThat(cell.value(), Is.is("DONE"));
}
 
开发者ID:JujaLabs,项目名称:microservices,代码行数:20,代码来源:JujacoreProgressServiceIntegrationTest.java

示例12: checkHealthCheck_isHealthy

import org.hamcrest.core.Is; //导入依赖的package包/类
@Test
public void checkHealthCheck_isHealthy() throws JsonProcessingException {
    SortedMap<String,HealthCheck.Result> map = new TreeMap<>();
    map.put("postgresql", HealthCheck.Result.healthy());
    map.put("deadlocks", HealthCheck.Result.healthy());
    when(healthCheckRegistry.runHealthChecks()).thenReturn(map);
    Response response = resource.healthCheck();
    assertThat(response.getStatus(), is(200));
    ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
    String body = ow.writeValueAsString(response.getEntity());

    JsonAssert.with(body)
        .assertThat("$.*", hasSize(2))
        .assertThat("$.postgresql.healthy", Is.is(true))
        .assertThat("$.deadlocks.healthy", Is.is(true));
}
 
开发者ID:alphagov,项目名称:pay-publicauth,代码行数:17,代码来源:HealthCheckResourceTest.java

示例13: shouldRetrieveAuthorities

import org.hamcrest.core.Is; //导入依赖的package包/类
@Test
public void shouldRetrieveAuthorities() {
    MotechUser user = mock(MotechUser.class);
    RoleDto role = mock(RoleDto.class);
    List<String> roles = Arrays.asList("role1");
    when(user.getRoles()).thenReturn(roles);

    when(motechRoleService.getRole("role1")).thenReturn(role);

    List<String> permissions = Arrays.asList("permission1");
    when(role.getPermissionNames()).thenReturn(permissions);

    List<GrantedAuthority> authorities = authoritiesService.authoritiesFor(user);

    assertThat(authorities.size(), Is.is(1));
    assertThat(authorities.get(0).getAuthority(), Is.is("permission1"));

}
 
开发者ID:motech,项目名称:motech,代码行数:19,代码来源:AuthoritiesServiceImplTest.java

示例14: selected

import org.hamcrest.core.Is; //导入依赖的package包/类
@Test
public void selected() {
  MatcherAssert.assertThat(
      JCheckBoxBuilder.builder()
          .selected(false)
          .build()
          .isSelected(),
      Is.is(false));

  MatcherAssert.assertThat(
      JCheckBoxBuilder.builder()
          .selected(true)
          .build()
          .isSelected(),
      Is.is(true));
}
 
开发者ID:triplea-game,项目名称:triplea,代码行数:17,代码来源:JCheckBoxBuilderTest.java

示例15: itemListener

import org.hamcrest.core.Is; //导入依赖的package包/类
@Test
public void itemListener() {

  final AtomicInteger triggerCount = new AtomicInteger(0);

  final String secondOption = "option 2";
  final JComboBox<String> box = JComboBoxBuilder.builder()
      .menuOptions("option 1", secondOption, "option 3")
      .itemListener(value -> {
        if (value.equals(secondOption)) {
          triggerCount.incrementAndGet();
        }
      }).build();
  box.setSelectedIndex(1);
  MatcherAssert.assertThat(triggerCount.get(), Is.is(1));
}
 
开发者ID:triplea-game,项目名称:triplea,代码行数:17,代码来源:JComboBoxBuilderTest.java


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