java类org.hamcrest.core.Is的实例源码

RedditListViewModelTest.java 文件源码 项目:droidcon2016 阅读 32 收藏 0 点赞 0 评论 0
@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));
}
MainViewModelTest.java 文件源码 项目:droidcon2016 阅读 30 收藏 0 点赞 0 评论 0
@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));
}
AlphaIntegrationTest.java 文件源码 项目:incubator-servicecomb-saga 阅读 22 收藏 0 点赞 0 评论 0
@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()));
}
FragmentStatePagerAdapterTest.java 文件源码 项目:android_pager_adapters 阅读 40 收藏 0 点赞 0 评论 0
@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));
}
RedditListViewModelTest.java 文件源码 项目:droidcon2016 阅读 35 收藏 0 点赞 0 评论 0
@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"));
}
HomeActivityTest.java 文件源码 项目:Cook-E 阅读 31 收藏 0 点赞 0 评论 0
/**
 * 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()));
}
RegistryTest.java 文件源码 项目:SwaggerCloud 阅读 44 收藏 0 点赞 0 评论 0
@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));

}
PropertyValidatorTest.java 文件源码 项目:aries-rsa 阅读 39 收藏 0 点赞 0 评论 0
@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"}));
}
DecisionTaskJsonConverterTest.java 文件源码 项目:flowable-engine 阅读 22 收藏 0 点赞 0 评论 0
@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)));
}
SessionActiveHandlerTest.java 文件源码 项目:vespa 阅读 33 收藏 0 点赞 0 评论 0
@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)"));
}
JujacoreProgressServiceIntegrationTest.java 文件源码 项目:microservices 阅读 27 收藏 0 点赞 0 评论 0
@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"));
}
HealthCheckResourceTest.java 文件源码 项目:pay-publicauth 阅读 33 收藏 0 点赞 0 评论 0
@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));
}
AuthoritiesServiceImplTest.java 文件源码 项目:motech 阅读 27 收藏 0 点赞 0 评论 0
@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"));

}
JCheckBoxBuilderTest.java 文件源码 项目:triplea 阅读 22 收藏 0 点赞 0 评论 0
@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));
}
JComboBoxBuilderTest.java 文件源码 项目:triplea 阅读 31 收藏 0 点赞 0 评论 0
@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));
}
JComboBoxBuilderTest.java 文件源码 项目:triplea 阅读 26 收藏 0 点赞 0 评论 0
@Test
public void useLastSelectionAsFutureDefaultWithStringKey() {
  final String settingKey = "settingKey";
  ClientSetting.save(settingKey, "");
  MatcherAssert.assertThat("establish a preconditions state to avoid pollution between runs",
      ClientSetting.load(settingKey), Is.is(""));

  final JComboBox<String> box = JComboBoxBuilder.builder()
      .menuOptions("option 1", "option 2")
      .useLastSelectionAsFutureDefault(settingKey)
      .build();
  Mockito.when(mockItemEvent.getStateChange()).thenReturn(ItemEvent.SELECTED);
  Mockito.when(mockItemEvent.getSource()).thenReturn(box);
  final String valueFromEvent = "test value";
  Mockito.when(mockItemEvent.getItem()).thenReturn(valueFromEvent);
  Arrays.stream(box.getItemListeners())
      .forEach(listener -> listener.itemStateChanged(mockItemEvent));

  MatcherAssert.assertThat(
      "selecting the 1st index should be 'option 2', we expect that to "
          + "have been flushed to client settings",
      ClientSetting.load(settingKey), Is.is(valueFromEvent));
}
JComboBoxBuilderTest.java 文件源码 项目:triplea 阅读 37 收藏 0 点赞 0 评论 0
@Test
public void useLastSelectionAsFutureDefaultWithClientKey() {
  ClientSetting.TEST_SETTING.saveAndFlush("");

  final JComboBox<String> box = JComboBoxBuilder.builder()
      .menuOptions("option 1", "option 2")
      .useLastSelectionAsFutureDefault(ClientSetting.TEST_SETTING)
      .build();

  Mockito.when(mockItemEvent.getStateChange()).thenReturn(ItemEvent.SELECTED);
  Mockito.when(mockItemEvent.getSource()).thenReturn(box);
  final String valueFromEvent = "test value";
  Mockito.when(mockItemEvent.getItem()).thenReturn(valueFromEvent);
  Arrays.stream(box.getItemListeners())
      .forEach(listener -> listener.itemStateChanged(mockItemEvent));

  MatcherAssert.assertThat("We expect any selected value to have been bound to our test setting",
      ClientSetting.TEST_SETTING.value(), Is.is(valueFromEvent));
}
HealthCheckResourceTest.java 文件源码 项目:pay-publicapi 阅读 31 收藏 0 点赞 0 评论 0
@Test
public void checkHealthCheck_isUnHealthy() throws JsonProcessingException {
    SortedMap<String,HealthCheck.Result> map = new TreeMap<>();
    map.put("ping", HealthCheck.Result.unhealthy("application is unavailable"));
    map.put("deadlocks", HealthCheck.Result.unhealthy("no new threads available"));
    when(healthCheckRegistry.runHealthChecks()).thenReturn(map);
    Response response = resource.healthCheck();
    assertThat(response.getStatus(), is(503));
    ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
    String body = ow.writeValueAsString(response.getEntity());

    JsonAssert.with(body)
            .assertThat("$.*", hasSize(2))
            .assertThat("$.ping.healthy", Is.is(false))
            .assertThat("$.deadlocks.healthy", Is.is(false));
}
HealthCheckResourceTest.java 文件源码 项目:pay-publicapi 阅读 30 收藏 0 点赞 0 评论 0
@Test
public void checkHealthCheck_pingIsHealthy_deadlocksIsUnhealthy() throws JsonProcessingException {
    SortedMap<String,HealthCheck.Result> map = new TreeMap<>();
    map.put("ping", HealthCheck.Result.healthy());
    map.put("deadlocks", HealthCheck.Result.unhealthy("no new threads available"));
    when(healthCheckRegistry.runHealthChecks()).thenReturn(map);
    Response response = resource.healthCheck();
    assertThat(response.getStatus(), is(503));
    ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
    String body = ow.writeValueAsString(response.getEntity());

    JsonAssert.with(body)
            .assertThat("$.*", hasSize(2))
            .assertThat("$.ping.healthy", Is.is(true))
            .assertThat("$.deadlocks.healthy", Is.is(false));
}
AddedFieldTest.java 文件源码 项目:offheap-store 阅读 33 收藏 0 点赞 0 评论 0
@Test
public void addingSerializableField() throws Exception {
  Portability<Serializable> p = new SerializablePortability();

  ClassLoader loaderA = createClassNameRewritingLoader(A_write.class, IncompatibleSerializable_write.class, Serializable_write.class);
  Serializable a = (Serializable) loaderA.loadClass(newClassName(A_write.class)).newInstance();
  ByteBuffer encodedA = p.encode(a);

  pushTccl(createClassNameRewritingLoader(A_read.class, IncompatibleSerializable_read.class));
  try {
    Serializable out = p.decode(encodedA);
    Assert.assertThat(out.getClass().getField("bar").getInt(out), Is.is(4));
  } finally {
    popTccl();
  }
}
AddedFieldTest.java 文件源码 项目:offheap-store 阅读 29 收藏 0 点赞 0 评论 0
@Test
public void addingExternalizableField() throws Exception {
  Portability<Serializable> p = new SerializablePortability();

  ClassLoader loaderA = createClassNameRewritingLoader(B_write.class, Externalizable_write.class);
  Serializable a = (Serializable) loaderA.loadClass(newClassName(B_write.class)).newInstance();
  ByteBuffer encodedA = p.encode(a);

  pushTccl(createClassNameRewritingLoader(B_read.class));
  try {
    Serializable out = p.decode(encodedA);
    Assert.assertThat(out.getClass().getField("bar").getInt(out), Is.is(4));
  } finally {
    popTccl();
  }
}
SerializeAfterEvolutionTest.java 文件源码 项目:offheap-store 阅读 28 收藏 0 点赞 0 评论 0
@Test
public void test() throws Exception {
  Portability<Serializable> p = new SerializablePortability();

  ClassLoader loaderA = createClassNameRewritingLoader(A_old.class);
  Serializable a = (Serializable) loaderA.loadClass(newClassName(A_old.class)).newInstance();
  ByteBuffer encodedA = p.encode(a);

  ClassLoader loaderB = createClassNameRewritingLoader(A_new.class);
  pushTccl(loaderB);
  try {
    Serializable outA = p.decode(encodedA);
    Assert.assertThat(outA.getClass().getField("integer").get(outA), Is.is(42));

    Serializable b = (Serializable) loaderB.loadClass(newClassName(A_new.class)).newInstance();
    Serializable outB = p.decode(p.encode(b));
    Assert.assertThat(outB.getClass().getField("integer").get(outB), Is.is(42));
  } finally {
    popTccl();
  }
}
OriginInfoMapperTest.java 文件源码 项目:proarc 阅读 28 收藏 0 点赞 0 评论 0
@Test
public void testRead() {
    ModsDefinition mods = new ModsDefinition();
    mods.getOriginInfo().add(originInfo(Role.PRINTER, "printer[0]", "date0", "place0"));
    mods.getOriginInfo().add(originInfo(Role.PRINTER, "printer[1]", "date1", "place1"));
    mods.getOriginInfo().add(originInfo(Role.OTHER, "unknown[2]", "date2", "place2"));
    mods.getOriginInfo().add(originInfo(Role.PUBLISHER, "publisher[3]", "date3", "place3"));
    mods.getOriginInfo().add(originInfo(Role.OTHER, "unknown[4]", null, null));
    mods.getOriginInfo().add(originInfo(Role.PUBLISHER, "publisher[5]", "date5", "place5"));
    List<OriginInfoItem> expected = Arrays.<OriginInfoItem>asList(
            new PublisherItem(0, Role.PRINTER, "printer[0]", "date0", "place0"),
            new PublisherItem(1, Role.PRINTER, "printer[1]", "date1", "place1"),
            new PublisherItem(2, Role.OTHER, null, null, null),
            new PublisherItem(3, Role.PUBLISHER, "publisher[3]", "date3", "place3"),
            new PublisherItem(4, Role.OTHER, null, null, null),
            new PublisherItem(5, Role.PUBLISHER, "publisher[5]", "date5", "place5")
            );

    OriginInfoMapper instance = new OriginInfoMapper();
    List<OriginInfoItem> result = instance.map(mods);
    assertThat(result, Is.is(expected));
}
RestAPIAuthenticationIT.java 文件源码 项目:motech 阅读 25 收藏 0 点赞 0 评论 0
@Test
public void testThatItShouldAllowRestApiAccessAfterFormAuthentication() throws IOException, JSONException,
        InterruptedException {

    HttpGet statusRequest =
            new HttpGet(String.format("http://%s:%d/motech-platform-server/module/server/web-api/status", HOST, PORT));

    HttpResponse response = HTTP_CLIENT.execute(statusRequest, HttpStatus.SC_UNAUTHORIZED);
    assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());

    Header authenticateHeader = response.getFirstHeader(HttpHeaders.WWW_AUTHENTICATE);
    assertNotNull(authenticateHeader);

    String authenticateHeaderValue = authenticateHeader.getValue();
    assertThat(authenticateHeaderValue, Is.is("Basic realm=\"MOTECH\""));

    EntityUtils.consume(response.getEntity());

    login();

    HttpResponse statusResponse = HTTP_CLIENT.execute(statusRequest);
    assertEquals(HttpStatus.SC_OK, statusResponse.getStatusLine().getStatusCode());
}
LanguageMapperTest.java 文件源码 项目:proarc 阅读 23 收藏 0 点赞 0 评论 0
@Test
    public void testWrite() {
        ModsDefinition mods = new ModsDefinition();
        mods.getLanguage().add(language("cze"));
        mods.getLanguage().add(otherLanguage("other1"));
        mods.getLanguage().add(language("ger"));
        List<LanguageItem> updates = Arrays.asList(
                new LanguageItem(0, "cze-update"), // update
//                new LanguageItem(2, "ger") // delete
                new LanguageItem(null, "eng") // add
                );
        LanguageMapper instance = new LanguageMapper();
        instance.map(mods, updates);
        List<LanguageItem> result = instance.map(mods);
        List<LanguageItem> expect = Arrays.asList(
                new LanguageItem(0, "cze-update"),
                new LanguageItem(1, "eng")
                );
        assertThat(result, Is.is(expect));
    }
InteractionListResponseTest.java 文件源码 项目:rxnorm-client 阅读 25 收藏 0 点赞 0 评论 0
@Test
public void testDeserializeInteractionListResponse() throws IOException {
    ClassLoader cl = InteractionListResponseTest.class.getClassLoader();
    File testJsonResponseFile = new File(cl.getResource("json/interaction-list-response.json").getFile());
    FileReader jsonStreamReader = new FileReader(testJsonResponseFile);
    InteractionListResponse response = gson.fromJson(jsonStreamReader, InteractionListResponse.class);
    jsonStreamReader.close();

    assertThat("InteractionDrugResponse is populated", response, Matchers.notNullValue());

    FullInteractionTypeGroup interactionGroup = response.getFullInteractionTypeGroup().get(0);
    assertThat("FullInteractionTypeGroup list is populated", interactionGroup.getFullInteractionType().size(), Matchers.greaterThanOrEqualTo(1));

    FullInteractionType interaction = interactionGroup.getFullInteractionType().get(0);

    assertThat("First drug is Simvastatin 40 MG Oral Tablet [Zocor]", interaction.getMinConcept().get(0).getName(), Is.is("Simvastatin 40 MG Oral Tablet [Zocor]"));
    assertThat("Second drug is bosentan 125 MG Oral Tablet", interaction.getMinConcept().get(1).getName(), Is.is("bosentan 125 MG Oral Tablet"));

}
PeriodicalMapperTest.java 文件源码 项目:proarc 阅读 28 收藏 0 点赞 0 评论 0
public static void assertPeriodicalEquals(Periodical expected, Periodical actual) {
    if (expected == null && actual == null) {
        return ;
    }
    assertNotNull(expected);
    assertNotNull(actual);
    assertThat(actual.getIdentifiers(), Is.is(expected.getIdentifiers()));
    assertEquals(expected.getSigla(), actual.getSigla());
    assertThat(actual.getShelfLocators(), Is.is(expected.getShelfLocators()));
    assertThat(actual.getPeriodicities(), Is.is(expected.getPeriodicities()));
    assertThat(actual.getTitles(), Is.is(expected.getTitles()));
    assertThat(actual.getSubtitles(), Is.is(expected.getSubtitles()));
    assertThat(actual.getKeyTitles(), Is.is(expected.getKeyTitles()));
    assertThat(actual.getAlternativeTitles(), Is.is(expected.getAlternativeTitles()));
    assertThat(actual.getIdentifiers(), Is.is(expected.getIdentifiers()));
    assertThat(actual.getAuthors(), Is.is(expected.getAuthors()));
    assertThat(actual.getContributors(), Is.is(expected.getContributors()));
    assertThat(actual.getPrinters(), Is.is(expected.getPrinters()));
    assertThat(actual.getPublishers(), Is.is(expected.getPublishers()));
    assertThat(actual.getLanguages(), Is.is(expected.getLanguages()));
    assertThat(actual.getClassifications(), Is.is(expected.getClassifications()));
    assertThat(actual.getKeywords(), Is.is(expected.getKeywords()));
    assertThat(actual.getPhysicalDescriptions(), Is.is(expected.getPhysicalDescriptions()));
    assertEquals(expected.getRecordOrigin(), actual.getRecordOrigin());
    assertEquals(expected.getNote(), actual.getNote());
}
TitleInfoMapperTest.java 文件源码 项目:proarc 阅读 27 收藏 0 点赞 0 评论 0
@Test
public void testGetTitles() {
    ModsDefinition mods = ModsUtils.unmarshal(XML, ModsDefinition.class);
    TitleInfoMapper instance = new TitleInfoMapper(mods);

    List<String> titleResult = instance.getTitles();
    List<String> subtitleResult = instance.getSubtitles();
    List<String> alternativeResult = instance.getAlternativeTitles();
    List<String> keyResult = instance.getKeyTitles();

    List<String> titleExpected = Arrays.asList("MTITLE[1][0]");
    List<String> subtitleExpected = Arrays.asList("STITLE[1][0]");
    List<String> alternativeExpected = Arrays.asList("ATITLE[0][0]", "ATITLE[0][1]");
    List<String> keyExpected = Arrays.asList("KTITLE[2][0]");

    assertThat(titleResult, Is.is(titleExpected));
    assertThat(subtitleResult, Is.is(subtitleExpected));
    assertThat(alternativeResult, Is.is(alternativeExpected));
    assertThat(keyResult, Is.is(keyExpected));
}
TitleInfoMapperTest.java 文件源码 项目:proarc 阅读 24 收藏 0 点赞 0 评论 0
@Test
public void testGetEmptyTitles() {
    TitleInfoMapper instance = new TitleInfoMapper(new ModsDefinition());

    List<String> titleResult = instance.getTitles();
    List<String> subtitleResult = instance.getSubtitles();
    List<String> alternativeResult = instance.getAlternativeTitles();
    List<String> keyResult = instance.getKeyTitles();

    List<String> titleExpected = Collections.emptyList();
    List<String> subtitleExpected = Collections.emptyList();
    List<String> alternativeExpected = Collections.emptyList();
    List<String> keyExpected = Collections.emptyList();

    assertThat(titleResult, Is.is(titleExpected));
    assertThat(subtitleResult, Is.is(subtitleExpected));
    assertThat(alternativeResult, Is.is(alternativeExpected));
    assertThat(keyResult, Is.is(keyExpected));
}
PhysicalDescriptionMapperTest.java 文件源码 项目:proarc 阅读 21 收藏 0 点赞 0 评论 0
@Test
public void testToPairs() {
    List<ArrayItem> items = Arrays.asList(
            new ExtentItem(0, "extent1[0]"),
            new ExtentItem(1, "size1[1]"),
            new UnkownItem(2),
            new ExtentItem(3, "extent2[3]"),
            new ExtentItem(4, "size2[4]"),
            new ExtentItem(5, "extent3[5]")
            );
    List<ExtentPair> expected = Arrays.asList(
            new ExtentPair("extent1[0]", 0, "size1[1]", 1),
            new ExtentPair("extent2[3]", 3, "size2[4]", 4),
            new ExtentPair("extent3[5]", 5, null, null)
            );
    List<ExtentPair> result = PhysicalDescriptionMapper.toPairs(items);
    assertThat(result, Is.is(expected));
}


问题


面经


文章

微信
公众号

扫码关注公众号