當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。