java类org.hamcrest.collection.IsCollectionWithSize的实例源码

TestServerPojoTest.java 文件源码 项目:vind 阅读 26 收藏 0 点赞 0 评论 0
@Test
public void testMultipleBeanIndex() {
    final SearchServer server = searchServer.getSearchServer();

    final Pojo doc1 = Pojo.create("doc1", "Eins", "Erstes Dokument", "simple");
    final Pojo doc2 = Pojo.create("doc2", "Zwei", "Zweites Dokument", "simple");
    final Pojo doc3 = Pojo.create("doc3", "Drei", "Dieses ist das dritte Dokument", "complex");
    final Pojo doc4 = Pojo.create("doc4", "Vier", "Das vierte Dokument", "complex");

    server.indexBean(doc1,doc2);

    List<Object> beanList = new ArrayList<>();
    beanList.add(doc3);
    beanList.add(doc4);

    server.indexBean(beanList);
    server.commit();

    final BeanSearchResult<Pojo> all = server.execute(Search.fulltext(), Pojo.class);
    assertThat("#numOfResults", all.getNumOfResults(), CoreMatchers.equalTo(4l));
    assertThat("results.size()", all.getResults(), IsCollectionWithSize.hasSize(4));
    checkPojo(doc3, all.getResults().get(2));
    checkPojo(doc2, all.getResults().get(1));
    checkPojo(doc1, all.getResults().get(0));
    checkPojo(doc4, all.getResults().get(3));
}
PayloadDeserializerTest.java 文件源码 项目:javaOIDCMsg 阅读 23 收藏 0 点赞 0 评论 0
@Test
public void shouldGetStringArrayWhenParsingArrayNode() throws Exception {
    Map<String, JsonNode> tree = new HashMap<>();
    List<JsonNode> subNodes = new ArrayList<>();
    TextNode textNode1 = new TextNode("one");
    TextNode textNode2 = new TextNode("two");
    subNodes.add(textNode1);
    subNodes.add(textNode2);
    ArrayNode arrNode = new ArrayNode(JsonNodeFactory.instance, subNodes);
    tree.put("key", arrNode);

    List<String> values = deserializer.getStringOrArray(tree, "key");
    assertThat(values, is(notNullValue()));
    assertThat(values, is(IsCollectionWithSize.hasSize(2)));
    assertThat(values, is(IsCollectionContaining.hasItems("one", "two")));
}
AuthenticationJsonWebTokenTest.java 文件源码 项目:auth0-spring-security-api 阅读 31 收藏 0 点赞 0 评论 0
@Test
public void shouldGetScopeAsAuthorities() throws Exception {
    String token = JWT.create()
            .withClaim("scope", "auth0 auth10")
            .sign(hmacAlgorithm);

    AuthenticationJsonWebToken auth = new AuthenticationJsonWebToken(token, verifier);
    assertThat(auth, is(notNullValue()));
    assertThat(auth.getAuthorities(), is(notNullValue()));
    assertThat(auth.getAuthorities(), is(IsCollectionWithSize.hasSize(2)));

    ArrayList<GrantedAuthority> authorities = new ArrayList<>(auth.getAuthorities());
    assertThat(authorities.get(0), is(notNullValue()));
    assertThat(authorities.get(0).getAuthority(), is("auth0"));
    assertThat(authorities.get(1), is(notNullValue()));
    assertThat(authorities.get(1).getAuthority(), is("auth10"));
}
JujacoreProgressServiceTest.java 文件源码 项目:microservices 阅读 32 收藏 0 点赞 0 评论 0
@Test
public void shouldFetchAllProgressCodes() throws Exception {
    //Given
    final ProgressDao dao = Mockito.mock(ProgressDao.class);
    final ProgressService service = new JujacoreProgressService(
        "", dao, Mockito.mock(SlackSession.class)
    );
    Mockito.when(dao.fetchProgressCodes()).thenReturn(Arrays.asList(
        "+code1", "+code2", "+code1"
    ));
    //When
    final Set<String> codes = service.codes();
    //Then
    MatcherAssert.assertThat(
        codes, IsCollectionWithSize.hasSize(2)
    );
    MatcherAssert.assertThat(
        codes, IsCollectionContaining.hasItems(
            "+code1", "+code2"
        )
    );
}
JujacoreProgressServiceTest.java 文件源码 项目:microservices 阅读 31 收藏 0 点赞 0 评论 0
@Test
public void shouldExcludeBlackListedCodes() throws Exception {
    //Given
    final ProgressDao dao = Mockito.mock(ProgressDao.class);
    final ProgressService service = new JujacoreProgressService(
        "+blackListCode1;+blackListCode2", dao,
        Mockito.mock(SlackSession.class)
    );
    Mockito.when(dao.fetchProgressCodes()).thenReturn(Arrays.asList(
        "+code1", "+blackListCode1", "+blackListCode2", "+code2"
    ));
    //When
    final Set<String> actualProgressCodes = service.codes();
    //Then
    MatcherAssert.assertThat(
        actualProgressCodes, IsCollectionWithSize.hasSize(2)
    );
    MatcherAssert.assertThat(
        actualProgressCodes, IsCollectionContaining.hasItems(
            "+code1", "+code2"
        )
    );
}
FilterTest.java 文件源码 项目:statistics 阅读 34 收藏 0 点赞 0 评论 0
@Test
public void testHalfPassMatcher() {
  Set<TreeNode> input = new HashSet<>();
  input.add(createTreeNode(A.class));
  input.add(createTreeNode(B.class));

  assertThat(buildQuery(new Matcher<TreeNode>() {

    private boolean match;

    @Override
    protected boolean matchesSafely(TreeNode object) {
      return match ^= true;
    }
  }).execute(input), IsCollectionWithSize.hasSize(input.size() / 2));
}
PayloadDeserializerTest.java 文件源码 项目:java-jwt 阅读 35 收藏 0 点赞 0 评论 0
@Test
public void shouldGetStringArrayWhenParsingArrayNode() throws Exception {
    Map<String, JsonNode> tree = new HashMap<>();
    List<JsonNode> subNodes = new ArrayList<>();
    TextNode textNode1 = new TextNode("one");
    TextNode textNode2 = new TextNode("two");
    subNodes.add(textNode1);
    subNodes.add(textNode2);
    ArrayNode arrNode = new ArrayNode(JsonNodeFactory.instance, subNodes);
    tree.put("key", arrNode);

    List<String> values = deserializer.getStringOrArray(tree, "key");
    assertThat(values, is(notNullValue()));
    assertThat(values, is(IsCollectionWithSize.hasSize(2)));
    assertThat(values, is(IsCollectionContaining.hasItems("one", "two")));
}
TestServerPojoTest.java 文件源码 项目:vind 阅读 30 收藏 0 点赞 0 评论 0
@Test
public void testPojoRoundtrip() {
    final SearchServer server = searchServer.getSearchServer();

    final Pojo doc1 = Pojo.create("doc1", "Eins", "Erstes Dokument", "simple");
    final Pojo doc2 = Pojo.create("doc2", "Zwei", "Zweites Dokument", "simple");
    final Pojo doc3 = Pojo.create("doc3", "Drei", "Dieses ist das dritte Dokument", "complex");
    final Pojo doc4 = Pojo.create("doc3", "Drei", "Dieses ist das dritte Dokument", "complex");

    server.indexBean(doc1);
    server.indexBean(doc2);
    server.indexBean(doc3);
    server.commit();

    final BeanSearchResult<Pojo> dritte = server.execute(Search.fulltext("dritte"), Pojo.class);
    assertThat("#numOfResults", dritte.getNumOfResults(), CoreMatchers.equalTo(1l));
    assertThat("results.size()", dritte.getResults(), IsCollectionWithSize.hasSize(1));
    checkPojo(doc3, dritte.getResults().get(0));

    final BeanSearchResult<Pojo> all = server.execute(Search.fulltext()
            .facet("category")
            .filter(or(eq("title", "Eins"), or(eq("title", "Zwei"),eq("title","Drei"))))
            .sort("_id_", Sort.Direction.Desc), Pojo.class); //TODO create special sort for reserved fields (like score, type, id)
    assertThat("#numOfResults", all.getNumOfResults(), CoreMatchers.equalTo(3l));
    assertThat("results.size()", all.getResults(), IsCollectionWithSize.hasSize(3));
    checkPojo(doc3, all.getResults().get(0));
    checkPojo(doc2, all.getResults().get(1));
    checkPojo(doc1, all.getResults().get(2));

    TermFacetResult<String> facets = all.getFacetResults().getTermFacet("category", String.class);
    assertEquals(2,facets.getValues().size());
    assertEquals("simple", facets.getValues().get(0).getValue());
    assertEquals("complex",facets.getValues().get(1).getValue());
    assertEquals(2,facets.getValues().get(0).getCount());
    assertEquals(1,facets.getValues().get(1).getCount());
}
TestServerPojoTest.java 文件源码 项目:vind 阅读 38 收藏 0 点赞 0 评论 0
@Test
public void testTaxonomyPojo() {
    final SearchServer server = searchServer.getSearchServer();

    final Pojo1 doc1 = new Pojo1();
    doc1.id = "pojo-Id-1";
    doc1.title = "title 1";
    doc1.tax = new Taxonomy("term 1",1,"", ZonedDateTime.now(),Arrays.asList("term 1","term one"));

    final Pojo1 doc2 = new Pojo1();
    doc2.id = "pojo-Id-2";
    doc2.title = "title 2";
    doc2.tax = new Taxonomy("term 2",2,"", ZonedDateTime.now(),Arrays.asList("term 2","term two"));

    server.indexBean(doc1);
    server.indexBean(doc2);
    server.commit();

    final BeanSearchResult<Pojo1> second = server.execute(Search.fulltext("two"), Pojo1.class);
    assertThat("#numOfResults", second.getNumOfResults(), CoreMatchers.equalTo(1l));
    assertThat("results.size()", second.getResults(), IsCollectionWithSize.hasSize(1));
   // checkPojo(doc3, dritte.getResults().get(0));

   /* final BeanSearchResult<Pojo> all = server.execute(Search.fulltext()
            .facet("category")
            .filter(or(eq("title", "Eins"), or(eq("title", "Zwei"),eq("title","Drei"))))
            .sort("_id_", Sort.Direction.Desc), Pojo.class); //TODO create special sort for reserved fields (like score, type, id)
    assertThat("#numOfResults", all.getNumOfResults(), CoreMatchers.equalTo(3l));
    assertThat("results.size()", all.getResults(), IsCollectionWithSize.hasSize(3));
    checkPojo(doc3, all.getResults().get(0));
    checkPojo(doc2, all.getResults().get(1));
    checkPojo(doc1, all.getResults().get(2));

    TermFacetResult<String> facets = all.getFacetResults().getTermFacet("category", String.class);
    assertEquals(2,facets.getValues().size());
    assertEquals("simple", facets.getValues().get(0).getValue());
    assertEquals("complex",facets.getValues().get(1).getValue());
    assertEquals(2,facets.getValues().get(0).getCount());
    assertEquals(1,facets.getValues().get(1).getCount());*/
}
PayloadDeserializerTest.java 文件源码 项目:javaOIDCMsg 阅读 30 收藏 0 点赞 0 评论 0
@Test
public void shouldGetStringArrayWhenParsingTextNode() throws Exception {
    Map<String, JsonNode> tree = new HashMap<>();
    TextNode textNode = new TextNode("something");
    tree.put("key", textNode);

    List<String> values = deserializer.getStringOrArray(tree, "key");
    assertThat(values, is(notNullValue()));
    assertThat(values, is(IsCollectionWithSize.hasSize(1)));
    assertThat(values, is(IsCollectionContaining.hasItems("something")));
}
PayloadImplTest.java 文件源码 项目:javaOIDCMsg 阅读 33 收藏 0 点赞 0 评论 0
@Test
public void shouldGetAudience() throws Exception {
    assertThat(payload, is(notNullValue()));

    assertThat(payload.getAudience(), is(IsCollectionWithSize.hasSize(1)));
    assertThat(payload.getAudience(), is(IsCollectionContaining.hasItems("audience")));
}
JWTDecoderTest.java 文件源码 项目:javaOIDCMsg 阅读 24 收藏 0 点赞 0 评论 0
@Test
public void shouldGetArrayAudience() throws Exception {
    String token = "eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsiSG9wZSIsIlRyYXZpcyIsIlNvbG9tb24iXX0.Tm4W8WnfPjlmHSmKFakdij0on2rWPETpoM7Sh0u6-S4";
    JWT jwt = JWT.require(Algorithm.HMAC256("secret")).build();
    DecodedJWT decodedJWT = jwt.decode(token);
    assertThat(decodedJWT, is(notNullValue()));
    assertThat(decodedJWT.getAudience(), is(IsCollectionWithSize.hasSize(3)));
    assertThat(decodedJWT.getAudience(), is(IsCollectionContaining.hasItems("Hope", "Travis", "Solomon")));
}
JWTDecoderTest.java 文件源码 项目:javaOIDCMsg 阅读 22 收藏 0 点赞 0 评论 0
@Test
public void shouldGetStringAudience() throws Exception {
    String token = "eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJKYWNrIFJleWVzIn0.a4I9BBhPt1OB1GW67g2P1bEHgi6zgOjGUL4LvhE9Dgc";
    JWT jwt = JWT.require(Algorithm.HMAC256("secret")).build();
    DecodedJWT decodedJWT = jwt.decode(token);
    assertThat(decodedJWT, is(notNullValue()));
    assertThat(decodedJWT.getAudience(), is(IsCollectionWithSize.hasSize(1)));
    assertThat(decodedJWT.getAudience(), is(IsCollectionContaining.hasItems("Jack Reyes")));
}
CsvAsDTOTest.java 文件源码 项目:Parseux 阅读 28 收藏 0 点赞 0 评论 0
@Test
public void parsedSize() {
    MatcherAssert.assertThat(
        "DTOs has correct size",
        new CsvAsDTO<>(
            new InputStreamReader(
                new ResourceAsStream("csv/test.csv").stream()
            ),
            CsvTestDTO.class
        ).asDTOs(),
        IsCollectionWithSize.hasSize(4)
    );
}
BundleControllerDeleteTest.java 文件源码 项目:dashboard 阅读 34 收藏 0 点赞 0 评论 0
@Test
public void successDeleteBundle() throws Exception {

    BundleMetadata bundleMetadata = new BundleMetadata.Builder().name("ToDelete").build();
    bundleService.save(bundleMetadata);

    final long previousSize = bundleService.getAll().size();
    final long previousRevision = revisionService.getLatest();

    assertThat(bundleService.getAll().size(), Matchers.equalTo(1));
    assertThat(bundleMetadata.getUuid(), not(Matchers.isEmptyOrNullString()));
    assertThat(bundleMetadata.getTag(), not(Matchers.isEmptyOrNullString()));
    assertTrue(Files.exists(fileSystem.getPath(props.getBasePath(), BundleDaoImpl.ENTITY_NAME, bundleMetadata.getUuid() + ".yaml")));

    assertNotNull(bundleService.getByTag(bundleMetadata.getTag()));

    mockMvc.perform(deleteAuthenticated("/bundle/" + bundleMetadata.getTag()))
            .andExpect(status().isOk());

    mockMvc.perform(deleteAuthenticated("/bundle/" + bundleMetadata.getTag()))
            .andExpect(status().isNotFound());

    assertFalse(Files.exists(fileSystem.getPath(props.getBasePath(), BundleDaoImpl.ENTITY_NAME, bundleMetadata.getUuid() + ".yaml")));
    assertNull(bundleService.getByTag(bundleMetadata.getTag()));

    assertEquals(previousSize - 1, bundleService.getAll().size());
    assertEquals(previousRevision + 1, revisionService.getLatest());

    List<Revision> revisions = revisionService.getDiffs(previousRevision);
    assertThat(revisions, IsCollectionWithSize.hasSize(1));

    Revision revision = revisions.get(0);
    assertEquals(revision.getAction(), Revision.Action.DELETE);
    assertEquals(((long) revision.getRevision()), previousRevision + 1);
    assertEquals(revision.getType(), Revision.Type.BUNDLE);
    assertEquals(revision.getTarget(), bundleMetadata.getUuid());
    assertEquals(revision.getResult(), null);
}
BundleControllerCreateTest.java 文件源码 项目:dashboard 阅读 21 收藏 0 点赞 0 评论 0
@Test
public void successWithBasic() throws Exception {
    long n = bundleService.getAll().size();
    final long previousRevision = revisionService.getLatest();
    final String name = "UnNom";

    MvcResult result = mockMvc.perform(postAuthenticated(("/bundle"))
            .content(toJson(new BundleMetadataDto.Builder().name(name).build()))
            .contentType(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(status().isOk())
            .andReturn();

    BundleMetadataDto bundleMetadataDto = fromJson(result.getResponse().getContentAsString(), BundleMetadataDto.class);

    assertEquals(name, bundleMetadataDto.getName());
    assertNull(bundleMetadataDto.getValidity());
    assertNotNull(bundleMetadataDto.getUuid());
    assertEquals(StringUtils.normalize(name), bundleMetadataDto.getTag());

    // Vérification de la persistence
    assertNotNull(bundleService.getByTag(bundleMetadataDto.getTag()));
    Path path = fileSystem.getPath(props.getBasePath(), BundleDao.ENTITY_NAME, bundleMetadataDto.getUuid() + ".yaml");
    assertTrue(Files.isRegularFile(path));
    assertEquals(n + 1, bundleService.getAll().size());

    // Vérification de la récision
    assertEquals(previousRevision + 1, revisionService.getLatest());

    List<Revision> revisions = revisionService.getDiffs(previousRevision);
    assertThat(revisions, IsCollectionWithSize.hasSize(1));

    Revision revision = revisions.get(0);
    assertEquals(revision.getAction(), Revision.Action.ADD);
    assertEquals(((long) revision.getRevision()), previousRevision + 1);
    assertEquals(revision.getType(), Revision.Type.BUNDLE);
    assertEquals(revision.getTarget(), bundleMetadataDto.getUuid());
    assertEquals(revision.getResult(), null);
}
JujacoreProgressServiceIntegrationTest.java 文件源码 项目:microservices 阅读 28 收藏 0 点赞 0 评论 0
@Ignore
@Test
public void fetchCodesFromRealSpreadsheet() throws Exception {
    final ProgressService service = JujacoreProgressServiceIntegrationTest
        .injector.getInstance(ProgressService.class);
    final Set<String> codes = service.codes();
    MatcherAssert.assertThat(
        codes, IsCollectionWithSize.hasSize(251)
    );
    MatcherAssert.assertThat(codes, IsNot.not(
        IsCollectionContaining.hasItem(""))
    );
}
InMemJobRepositoryTest.java 文件源码 项目:edison-microservice 阅读 30 收藏 0 点赞 0 评论 0
@Test
public void shouldFindRunningJobsWithoutUpdatedSinceSpecificDate() throws Exception {
    // given
    repository.createOrUpdate(newJobInfo("deadJob", "FOO", fixed(Instant.now().minusSeconds(10), systemDefault()), "localhost"));
    repository.createOrUpdate(newJobInfo("running", "FOO", fixed(Instant.now(), systemDefault()), "localhost"));

    // when
    final List<JobInfo> jobInfos = repository.findRunningWithoutUpdateSince(now().minus(5, ChronoUnit.SECONDS));

    // then
    assertThat(jobInfos, IsCollectionWithSize.hasSize(1));
    assertThat(jobInfos.get(0).getJobId(), is("deadJob"));
}
PayloadDeserializerTest.java 文件源码 项目:java-jwt 阅读 22 收藏 0 点赞 0 评论 0
@Test
public void shouldGetStringArrayWhenParsingTextNode() throws Exception {
    Map<String, JsonNode> tree = new HashMap<>();
    TextNode textNode = new TextNode("something");
    tree.put("key", textNode);

    List<String> values = deserializer.getStringOrArray(tree, "key");
    assertThat(values, is(notNullValue()));
    assertThat(values, is(IsCollectionWithSize.hasSize(1)));
    assertThat(values, is(IsCollectionContaining.hasItems("something")));
}
PayloadImplTest.java 文件源码 项目:java-jwt 阅读 23 收藏 0 点赞 0 评论 0
@Test
public void shouldGetAudience() throws Exception {
    assertThat(payload, is(notNullValue()));

    assertThat(payload.getAudience(), is(IsCollectionWithSize.hasSize(1)));
    assertThat(payload.getAudience(), is(IsCollectionContaining.hasItems("audience")));
}
JWTDecoderTest.java 文件源码 项目:java-jwt 阅读 42 收藏 0 点赞 0 评论 0
@Test
public void shouldGetArrayAudience() throws Exception {
    DecodedJWT jwt = JWT.decode("eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsiSG9wZSIsIlRyYXZpcyIsIlNvbG9tb24iXX0.Tm4W8WnfPjlmHSmKFakdij0on2rWPETpoM7Sh0u6-S4");
    assertThat(jwt, is(notNullValue()));
    assertThat(jwt.getAudience(), is(IsCollectionWithSize.hasSize(3)));
    assertThat(jwt.getAudience(), is(IsCollectionContaining.hasItems("Hope", "Travis", "Solomon")));
}
JWTDecoderTest.java 文件源码 项目:java-jwt 阅读 23 收藏 0 点赞 0 评论 0
@Test
public void shouldGetStringAudience() throws Exception {
    DecodedJWT jwt = JWT.decode("eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJKYWNrIFJleWVzIn0.a4I9BBhPt1OB1GW67g2P1bEHgi6zgOjGUL4LvhE9Dgc");
    assertThat(jwt, is(notNullValue()));
    assertThat(jwt.getAudience(), is(IsCollectionWithSize.hasSize(1)));
    assertThat(jwt.getAudience(), is(IsCollectionContaining.hasItems("Jack Reyes")));
}
JWTTest.java 文件源码 项目:java-jwt 阅读 30 收藏 0 点赞 0 评论 0
@Test
public void shouldGetArrayAudience() throws Exception {
    String token = "eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsiSG9wZSIsIlRyYXZpcyIsIlNvbG9tb24iXX0.Tm4W8WnfPjlmHSmKFakdij0on2rWPETpoM7Sh0u6-S4";
    DecodedJWT jwt = JWT.require(Algorithm.HMAC256("secret"))
            .build()
            .verify(token);

    assertThat(jwt, is(notNullValue()));
    assertThat(jwt.getAudience(), is(IsCollectionWithSize.hasSize(3)));
    assertThat(jwt.getAudience(), is(IsCollectionContaining.hasItems("Hope", "Travis", "Solomon")));
}
JWTTest.java 文件源码 项目:java-jwt 阅读 28 收藏 0 点赞 0 评论 0
@Test
public void shouldGetStringAudience() throws Exception {
    String token = "eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJKYWNrIFJleWVzIn0.a4I9BBhPt1OB1GW67g2P1bEHgi6zgOjGUL4LvhE9Dgc";
    DecodedJWT jwt = JWT.require(Algorithm.HMAC256("secret"))
            .build()
            .verify(token);

    assertThat(jwt, is(notNullValue()));
    assertThat(jwt.getAudience(), is(IsCollectionWithSize.hasSize(1)));
    assertThat(jwt.getAudience(), is(IsCollectionContaining.hasItems("Jack Reyes")));
}
SimpleMatcherExamplesTest.java 文件源码 项目:smog 阅读 29 收藏 0 点赞 0 评论 0
@Test
public void testListSizeMatching() {
    Matcher<Person> matcher =
            is(aPersonThat()
                    .hasPhoneList(IsCollectionWithSize.<Phone>hasSize(1)));

    String descriptionOfMismatch = "phoneList collection size was <2> (expected a collection with size <1>)";

    assertMismatch(bob, matcher, descriptionOfMismatch);
}
ApplicationGsonTest.java 文件源码 项目:Lock.Android 阅读 21 收藏 0 点赞 0 评论 0
@Test
public void shouldReturnApplication() throws Exception {
    final List<Connection> connections = buildApplicationFrom(json(APPLICATION));
    assertThat(connections, is(notNullValue()));
    assertThat(connections, is(notNullValue()));
    assertThat(connections, IsCollectionWithSize.hasSize(1));
    assertThat(connections.get(0), instanceOf(Connection.class));
}
ITestSolrRepositoryOperations.java 文件源码 项目:spring-data-solr 阅读 26 收藏 0 点赞 0 评论 0
/**
 * @see DATASOLR-144
 */
@Test
public void testDerivedDeleteByQueryRemovesDocumentAndReturnsListOfDeletedDocumentsCorrectly() {

    List<ProductBean> result = repo.removeByName(NAMED_PRODUCT.getName());
    Assert.assertThat(repo.exists(NAMED_PRODUCT.getId()), Is.is(false));
    Assert.assertThat(result, IsCollectionWithSize.hasSize(1));
    Assert.assertThat(result.get(0).getId(), IsEqual.equalTo(NAMED_PRODUCT.getId()));
}
ITestSolrRepositoryOperations.java 文件源码 项目:spring-data-solr 阅读 28 收藏 0 点赞 0 评论 0
/**
 * @see DATASOLR-170
 */
@Test
public void findTopNResultAppliesLimitationCorrectly() {

    List<ProductBean> result = repo.findTop2ByNameStartingWith("na");
    Assert.assertThat(result, IsCollectionWithSize.hasSize(2));
}
MappingSolrConverterTests.java 文件源码 项目:spring-data-solr 阅读 26 收藏 0 点赞 0 评论 0
@Test
public void testWriteCollectionToSolrInputDocumentColletion() {
    BeanWithDefaultTypes bean1 = new BeanWithDefaultTypes();
    bean1.stringProperty = "solr";

    BeanWithDefaultTypes bean2 = new BeanWithDefaultTypes();
    bean2.intProperty = 10;

    Collection<SolrInputDocument> result = converter.write(Arrays.asList(bean1, bean2));
    Assert.assertNotNull(result);
    Assert.assertThat(result, IsCollectionWithSize.hasSize(2));
}
AbstractRepositoryUnitTests.java 文件源码 项目:spring-data-keyvalue 阅读 26 收藏 0 点赞 0 评论 0
@Test // DATACMNS-525
public void findPage() {

    repository.saveAll(LENNISTERS);

    Page<Person> page = repository.findByAge(19, PageRequest.of(0, 1));
    assertThat(page.hasNext(), is(true));
    assertThat(page.getTotalElements(), is(2L));
    assertThat(page.getContent(), IsCollectionWithSize.hasSize(1));

    Page<Person> next = repository.findByAge(19, page.nextPageable());
    assertThat(next.hasNext(), is(false));
    assertThat(next.getTotalElements(), is(2L));
    assertThat(next.getContent(), IsCollectionWithSize.hasSize(1));
}


问题


面经


文章

微信
公众号

扫码关注公众号