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


Java IsCollectionWithSize类代码示例

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


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

示例1: testMultipleBeanIndex

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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));
}
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:27,代码来源:TestServerPojoTest.java

示例2: shouldGetStringArrayWhenParsingArrayNode

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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")));
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:17,代码来源:PayloadDeserializerTest.java

示例3: shouldGetScopeAsAuthorities

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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"));
}
 
开发者ID:auth0,项目名称:auth0-spring-security-api,代码行数:18,代码来源:AuthenticationJsonWebTokenTest.java

示例4: shouldFetchAllProgressCodes

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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"
        )
    );
}
 
开发者ID:JujaLabs,项目名称:microservices,代码行数:23,代码来源:JujacoreProgressServiceTest.java

示例5: shouldExcludeBlackListedCodes

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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"
        )
    );
}
 
开发者ID:JujaLabs,项目名称:microservices,代码行数:24,代码来源:JujacoreProgressServiceTest.java

示例6: testHalfPassMatcher

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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));
}
 
开发者ID:Terracotta-OSS,项目名称:statistics,代码行数:17,代码来源:FilterTest.java

示例7: testPojoRoundtrip

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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());
}
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:37,代码来源:TestServerPojoTest.java

示例8: testTaxonomyPojo

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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());*/
}
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:41,代码来源:TestServerPojoTest.java

示例9: shouldGetStringArrayWhenParsingTextNode

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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")));
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:12,代码来源:PayloadDeserializerTest.java

示例10: shouldGetAudience

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@Test
public void shouldGetAudience() throws Exception {
    assertThat(payload, is(notNullValue()));

    assertThat(payload.getAudience(), is(IsCollectionWithSize.hasSize(1)));
    assertThat(payload.getAudience(), is(IsCollectionContaining.hasItems("audience")));
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:8,代码来源:PayloadImplTest.java

示例11: shouldGetArrayAudience

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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")));
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:10,代码来源:JWTDecoderTest.java

示例12: shouldGetStringAudience

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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")));
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:10,代码来源:JWTDecoderTest.java

示例13: parsedSize

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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)
    );
}
 
开发者ID:jedcua,项目名称:Parseux,代码行数:14,代码来源:CsvAsDTOTest.java

示例14: successDeleteBundle

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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);
}
 
开发者ID:resourcepool,项目名称:dashboard,代码行数:39,代码来源:BundleControllerDeleteTest.java

示例15: successWithBasic

import org.hamcrest.collection.IsCollectionWithSize; //导入依赖的package包/类
@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);
}
 
开发者ID:resourcepool,项目名称:dashboard,代码行数:39,代码来源:BundleControllerCreateTest.java


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