org.hamcrest.collection.IsEmptyCollection Java Examples

The following examples show how to use org.hamcrest.collection.IsEmptyCollection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: datacollector   Author: streamsets   File: AbstractMysqlSource.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldIncludeAndIgnoreTables() throws Exception {
  MysqlSourceConfig config = createConfig("root");
  MysqlSource source = createMysqlSource(config);
  config.includeTables = "test.foo,t%.foo2";
  config.ignoreTables = "test.foo";
  runner = new SourceRunner.Builder(MysqlDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, MAX_BATCH_SIZE);
  assertThat(output.getRecords().get(LANE), is(IsEmptyCollection.<Record>empty()));

  execute(ds, "INSERT INTO foo (bar) VALUES (1)");
  execute(ds, "INSERT INTO foo2 VALUES (1, 2, 3)");

  output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  List<Record> records = output.getRecords().get(LANE);
  assertThat(records, hasSize(1));
  assertThat(records.get(0).get("/Table").getValueAsString(), is("foo2"));
  execute(ds, "TRUNCATE foo");
  execute(ds, "TRUNCATE foo2");
}
 
Example #2
Source Project: datacollector   Author: streamsets   File: AbstractMysqlSource.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldIgnoreEmptyFilters() throws Exception {
  MysqlSourceConfig config = createConfig("root");
  MysqlSource source = createMysqlSource(config);
  config.includeTables = "";
  config.ignoreTables = "";
  runner = new SourceRunner.Builder(MysqlDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, MAX_BATCH_SIZE);
  assertThat(output.getRecords().get(LANE), is(IsEmptyCollection.<Record>empty()));

  execute(ds, "INSERT INTO foo (bar) VALUES (1)");
  execute(ds, "INSERT INTO foo2 VALUES (1, 2, 3)");

  output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  List<Record> records = output.getRecords().get(LANE);
  assertThat(records, hasSize(2));
}
 
Example #3
Source Project: datacollector   Author: streamsets   File: AbstractMysqlSource.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldReturnCorrectOffsetForFilteredOutEvents() throws Exception {
  MysqlSourceConfig config = createConfig("root");
  MysqlSource source = createMysqlSource(config);
  config.ignoreTables = "test.foo";
  runner = new SourceRunner.Builder(MysqlDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, MAX_BATCH_SIZE);
  assertThat(output.getRecords().get(LANE), is(IsEmptyCollection.<Record>empty()));

  execute(ds, "INSERT INTO foo (bar) VALUES (1)");

  output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  List<Record> records = output.getRecords().get(LANE);
  assertThat(records, is(empty()));
  assertThat(output.getNewOffset(), not(isEmptyString()));
}
 
Example #4
Source Project: datacollector   Author: streamsets   File: TestAbstractMysqlSource.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldIncludeAndIgnoreTables() throws Exception {
  MysqlBinLogSourceConfig config = createConfig("root");
  MysqlBinLogSource source = createMysqlSource(config);
  config.includeTables = "test.foo,t%.foo2";
  config.ignoreTables = "test.foo";
  runner = new SourceRunner.Builder(MySQLBinLogDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, MAX_BATCH_SIZE);
  assertThat(output.getRecords().get(LANE), is(IsEmptyCollection.<Record>empty()));

  execute(ds, "INSERT INTO foo (bar) VALUES (1)");
  execute(ds, "INSERT INTO foo2 VALUES (1, 2, 3)");

  output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  List<Record> records = output.getRecords().get(LANE);
  assertThat(records, hasSize(1));
  assertThat(records.get(0).get("/Table").getValueAsString(), is("foo2"));
  execute(ds, "TRUNCATE foo");
  execute(ds, "TRUNCATE foo2");
}
 
Example #5
Source Project: datacollector   Author: streamsets   File: TestAbstractMysqlSource.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldIgnoreEmptyFilters() throws Exception {
  MysqlBinLogSourceConfig config = createConfig("root");
  MysqlBinLogSource source = createMysqlSource(config);
  config.includeTables = "";
  config.ignoreTables = "";
  runner = new SourceRunner.Builder(MySQLBinLogDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, MAX_BATCH_SIZE);
  assertThat(output.getRecords().get(LANE), is(IsEmptyCollection.<Record>empty()));

  execute(ds, "INSERT INTO foo (bar) VALUES (1)");
  execute(ds, "INSERT INTO foo2 VALUES (1, 2, 3)");

  output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  List<Record> records = output.getRecords().get(LANE);
  assertThat(records, hasSize(2));
}
 
Example #6
Source Project: datacollector   Author: streamsets   File: TestAbstractMysqlSource.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldReturnCorrectOffsetForFilteredOutEvents() throws Exception {
  MysqlBinLogSourceConfig config = createConfig("root");
  MysqlBinLogSource source = createMysqlSource(config);
  config.ignoreTables = "test.foo";
  runner = new SourceRunner.Builder(MySQLBinLogDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, MAX_BATCH_SIZE);
  assertThat(output.getRecords().get(LANE), is(IsEmptyCollection.<Record>empty()));

  execute(ds, "INSERT INTO foo (bar) VALUES (1)");

  output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  List<Record> records = output.getRecords().get(LANE);
  assertThat(records, is(empty()));
  assertThat(output.getNewOffset(), not(isEmptyString()));
}
 
Example #7
Source Project: datakernel   Author: softindex   File: CubeOTTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void test() throws OTTransformException {
	LogFile logFile = new LogFile("file", 1);
	List<String> fields = asList("field1", "field2");
	LogDiff<CubeDiff> changesLeft = LogDiff.of(
			singletonMap("clicks", positionDiff(logFile, 0, 10)),
			cubeDiff("key", chunk(1, fields, ofArray("str", 10), ofArray("str", 20), 15)));

	LogDiff<CubeDiff> changesRight = LogDiff.of(
			singletonMap("clicks", positionDiff(logFile, 0, 20)),
			cubeDiff("key", chunk(1, fields, ofArray("str", 10), ofArray("str", 25), 30)));
	TransformResult<LogDiff<CubeDiff>> transform = logSystem.transform(changesLeft, changesRight);

	assertTrue(transform.hasConflict());
	assertEquals(ConflictResolution.RIGHT, transform.resolution);
	assertThat(transform.right, IsEmptyCollection.empty());

	LogDiff<CubeDiff> result = LogDiff.of(
			singletonMap("clicks", positionDiff(logFile, 10, 20)),
			cubeDiff("key", addedChunks(changesRight.getDiffs()), addedChunks(changesLeft.getDiffs())));

	assertEquals(1, transform.left.size());
	assertEquals(result, transform.left.get(0));
}
 
Example #8
Source Project: emissary   Author: NationalSecurityAgency   File: PeersIT.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void peers() {
    // test
    Response response = target("peers").request().get();

    // verify
    assertThat(response.getStatus(), equalTo(200));
    PeersResponseEntity entity = response.readEntity(PeersResponseEntity.class);
    assertThat(entity.getErrors(), IsEmptyCollection.empty());
    assertThat(entity.getCluster(), equalTo(null));
    assertThat(entity.getLocal().getHost(), equalTo(TestEmissaryNode.TEST_NODE_PORT));
    assertThat(entity.getLocal().getPeers(), equalTo(PEERS));

}
 
Example #9
Source Project: emissary   Author: NationalSecurityAgency   File: AgentsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Ignore
// TODO: stop mocking and run a server since we made it so easy
@Test
public void agents() throws Exception {
    // test
    Response response = target("agents").request().get();

    // verify
    assertThat(response.getStatus(), equalTo(200));
    AgentsResponseEntity entity = response.readEntity(AgentsResponseEntity.class);
    assertThat(entity.getErrors(), IsEmptyCollection.empty());
    assertThat(entity.getCluster(), IsEmptyCollection.empty());
    assertThat(entity.getLocal().getHost(), equalTo("localhost:8001"));
    assertThat(entity.getLocal().getAgents(), IsIterableContainingInOrder.contains(EXPECTED_AGENTS));
}
 
Example #10
Source Project: auth0-spring-security-api   Author: auth0   File: AuthenticationJsonWebTokenTest.java    License: MIT License 5 votes vote down vote up
@Test
public void shouldGetEmptyAuthoritiesOnMissingScopeClaim() throws Exception {
    String token = JWT.create()
            .sign(hmacAlgorithm);

    AuthenticationJsonWebToken auth = new AuthenticationJsonWebToken(token, verifier);
    assertThat(auth, is(notNullValue()));
    assertThat(auth.getAuthorities(), is(notNullValue()));
    assertThat(auth.getAuthorities(), is(IsEmptyCollection.empty()));
}
 
Example #11
Source Project: auth0-spring-security-api   Author: auth0   File: AuthenticationJsonWebTokenTest.java    License: MIT License 5 votes vote down vote up
@Test
public void shouldGetEmptyAuthoritiesOnEmptyScopeClaim() throws Exception {
    String token = JWT.create()
            .withClaim("scope", "   ")
            .sign(hmacAlgorithm);

    AuthenticationJsonWebToken auth = new AuthenticationJsonWebToken(token, verifier);
    assertThat(auth, is(notNullValue()));
    assertThat(auth.getAuthorities(), is(notNullValue()));
    assertThat(auth.getAuthorities(), is(IsEmptyCollection.empty()));
}
 
Example #12
Source Project: auth0-spring-security-api   Author: auth0   File: AuthenticationJsonWebTokenTest.java    License: MIT License 5 votes vote down vote up
@Test
public void shouldGetEmptyAuthoritiesOnEmptyPermissionsClaim() throws Exception {
    String token = JWT.create()
            .withArrayClaim("permissions", new String[]{})
            .sign(hmacAlgorithm);

    AuthenticationJsonWebToken auth = new AuthenticationJsonWebToken(token, verifier);
    assertThat(auth, is(notNullValue()));
    assertThat(auth.getAuthorities(), is(notNullValue()));
    assertThat(auth.getAuthorities(), is(IsEmptyCollection.empty()));
}
 
Example #13
@Test
public void shouldGetEmptyAuthoritiesOnMissingScopeClaim() throws Exception {
    String token = JWT.create()
            .sign(hmacAlgorithm);

    PreAuthenticatedAuthenticationJsonWebToken auth = usingToken(token);
    assertThat(auth, is(notNullValue()));
    assertThat(auth.getAuthorities(), is(notNullValue()));
    assertThat(auth.getAuthorities(), is(IsEmptyCollection.empty()));
}
 
Example #14
@Test
public void shouldAlwaysGetEmptyAuthorities() throws Exception {
    String token = JWT.create()
            .withClaim("scope", "read:users add:users")
            .sign(hmacAlgorithm);

    PreAuthenticatedAuthenticationJsonWebToken auth = usingToken(token);
    assertThat(auth, is(notNullValue()));
    assertThat(auth.getAuthorities(), is(notNullValue()));
    assertThat(auth.getAuthorities(), is(IsEmptyCollection.empty()));
}
 
Example #15
Source Project: cactoos   Author: yegor256   File: ReversedTest.java    License: MIT License 5 votes vote down vote up
@Test
public void reversesEmptyList() {
    new Assertion<>(
        "Must reverse empty list",
        new ListOf<>(
            new Reversed<>(
                new IteratorOf<>()
            )
        ),
        new IsEmptyCollection<>()
    ).affirm();
}
 
Example #16
Source Project: jpeek   Author: yegor256   File: XmlGraphTest.java    License: MIT License 5 votes vote down vote up
@Test
void buildsConnections() {
    final Map<String, Node> byname = new MapOf<>(
        Node::name,
        node -> node,
        new XmlGraph(
            new Skeleton(new FakeBase(XmlGraphTest.CLASS_NAME))
        ).nodes()
    );
    final Node one = byname.get(XmlGraphTest.METHOD_ONE);
    final Node two = byname.get(XmlGraphTest.METHOD_TWO);
    final Node three = byname.get(XmlGraphTest.METHOD_THREE);
    final Node four = byname.get(XmlGraphTest.METHOD_FOUR);
    final Node five = byname.get(XmlGraphTest.METHOD_FIVE);
    new Assertion<>(
        "Must build nodes connections when called",
        one.connections(),
        new HasValues<>(two)
    ).affirm();
    new Assertion<>(
        "Must build nodes connections when called or calling",
        two.connections(),
        new HasValues<>(one, four)
    ).affirm();
    new Assertion<>(
        "Must build nodes connections when neither called nor calling",
        three.connections(),
        new IsEmptyCollection<>()
    ).affirm();
    new Assertion<>(
        "Must build nodes connections when calling",
        four.connections(),
        new HasValues<>(two)
    ).affirm();
    new Assertion<>(
        "Must build nodes connections when throwing",
        five.connections(),
        new IsEmptyCollection<>()
    ).affirm();
}
 
Example #17
Source Project: JWTDecode.Android   Author: auth0   File: ClaimImplTest.java    License: MIT License 5 votes vote down vote up
@Test
public void shouldGetEmptyListIfNullValue() {
    JsonElement value = gson.toJsonTree(null);
    ClaimImpl claim = new ClaimImpl(value);

    assertThat(claim.asList(String.class), is(notNullValue()));
    assertThat(claim.asList(String.class), is(IsEmptyCollection.emptyCollectionOf(String.class)));
}
 
Example #18
Source Project: JWTDecode.Android   Author: auth0   File: ClaimImplTest.java    License: MIT License 5 votes vote down vote up
@Test
public void shouldGetEmptyListIfNonArrayValue() {
    JsonElement value = gson.toJsonTree(1);
    ClaimImpl claim = new ClaimImpl(value);

    assertThat(claim.asList(String.class), is(notNullValue()));
    assertThat(claim.asList(String.class), is(IsEmptyCollection.emptyCollectionOf(String.class)));
}
 
Example #19
Source Project: JWTDecode.Android   Author: auth0   File: JWTTest.java    License: MIT License 5 votes vote down vote up
@Test
public void shouldGetEmptyListAudienceIfMissing() {
    JWT jwt = new JWT("eyJhbGciOiJIUzI1NiJ9.e30.something");
    assertThat(jwt, is(notNullValue()));

    assertThat(jwt.getAudience(), IsEmptyCollection.<String>empty());
}
 
Example #20
Source Project: strimzi-kafka-operator   Author: strimzi   File: SimpleAclOperatorIT.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testNoAclRules(VertxTestContext context) {
    Set<SimpleAclRule> acls = simpleAclOperator.getAcls("no-acls-user");
    context.verify(() -> {
        assertThat(acls, IsEmptyCollection.empty());
    });
    context.completeNow();
}
 
Example #21
Source Project: openhab-core   Author: openhab   File: I18nConfigOptionsProviderTest.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testRegion() throws Exception {
    assertThat(provider.getParameterOptions(uriI18N, "region", Locale.US), hasItem(expectedCntryEN));
    assertThat(provider.getParameterOptions(uriI18N, "region", Locale.FRENCH),
            anyOf(hasItem(expectedCntryFRJava8), hasItem(expectedCntryFRJava9)));
    assertThat(provider.getParameterOptions(uriI18N, "region", null), not(IsEmptyCollection.empty()));
}
 
Example #22
Source Project: logbook   Author: zalando   File: HttpResponseTest.java    License: MIT License 5 votes vote down vote up
@Test
public void testEmptyCodes() {
    HttpResponse response = mock(HttpResponse.class);
    when(response.getReasonPhrase()).thenCallRealMethod();
    
    Set<Integer> list = new HashSet<>(RESPONSE_CODES);
    for(int i = 0; i < 1000; i++) {
        when(response.getStatus()).thenReturn(i);
        if(response.getReasonPhrase() != null && !list.remove(Integer.valueOf(i))) {
            fail("Unexpected reason phrase for code " + i);
        }
    }
    assertThat(list, IsEmptyCollection.empty());
}
 
Example #23
Source Project: datacollector   Author: streamsets   File: AbstractMysqlSource.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldStartFromCurrent() throws Exception {
  execute(ds, "INSERT INTO foo (bar) VALUES (1)");

  MysqlSourceConfig config = createConfig("root");
  config.startFromBeginning = false;
  MysqlSource source = createMysqlSource(config);
  runner = new SourceRunner.Builder(MysqlDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, MAX_BATCH_SIZE);
  List<Record> records = new ArrayList<>();

  while (!output.getRecords().get(LANE).isEmpty()) {
    records.addAll(output.getRecords().get(LANE));
    output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  }
  assertThat(records, is(IsEmptyCollection.<Record>empty()));

  // add one more
  execute(ds, "INSERT INTO foo (bar) VALUES (2)");
  output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  records.addAll(output.getRecords().get(LANE));

  Record found = null;
  for (Record record : records) {
    if (record.get("/Table").getValueAsString().equals("foo")) {
      found = record;
      break;
    }
  }
  assertThat(found, notNullValue());
  assertThat(found.get("/Data/bar"), is(create(2)));
}
 
Example #24
Source Project: datacollector   Author: streamsets   File: AbstractMysqlSource.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSendAllEventRecordsDiscardingbatchSize() throws Exception {
  int count = 100;
  for (int i = 0; i < count; i++) {
    execute(ds, String.format("INSERT INTO foo (bar) VALUES (%d)", i));
  }

  MysqlSourceConfig config = createConfig("root");
  MysqlSource source = createMysqlSource(config);
  runner = new SourceRunner.Builder(MysqlDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, count);
  assertThat(output.getRecords().get(LANE), is(IsEmptyCollection.<Record>empty()));

  execute(ds, "DELETE FROM foo");

  output = runner.runProduce(output.getNewOffset(), count / 2);

  List<Record> records = new ArrayList<>();
  records.addAll(output.getRecords().get(LANE));

  assertThat(records, hasSize(count));
}
 
Example #25
Source Project: datacollector   Author: streamsets   File: TestAbstractMysqlSource.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldStartFromCurrent() throws Exception {
  execute(ds, "INSERT INTO foo (bar) VALUES (1)");

  MysqlBinLogSourceConfig config = createConfig("root");
  config.startFromBeginning = false;
  MysqlBinLogSource source = createMysqlSource(config);
  runner = new SourceRunner.Builder(MySQLBinLogDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, MAX_BATCH_SIZE);
  List<Record> records = new ArrayList<>();

  while (!output.getRecords().get(LANE).isEmpty()) {
    records.addAll(output.getRecords().get(LANE));
    output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  }
  assertThat(records, is(IsEmptyCollection.<Record>empty()));

  // add one more
  execute(ds, "INSERT INTO foo (bar) VALUES (2)");
  output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  records.addAll(output.getRecords().get(LANE));

  Record found = null;
  for (Record record : records) {
    if (record.get("/Table").getValueAsString().equals("foo")) {
      found = record;
      break;
    }
  }
  assertThat(found, notNullValue());
  assertThat(found.get("/Data/bar"), is(create(2)));
}
 
Example #26
Source Project: datacollector   Author: streamsets   File: TestAbstractMysqlSource.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSendAllEventRecordsDiscardingbatchSize() throws Exception {
  int count = 100;
  for (int i = 0; i < count; i++) {
    execute(ds, String.format("INSERT INTO foo (bar) VALUES (%d)", i));
  }

  MysqlBinLogSourceConfig config = createConfig("root");
  MysqlBinLogSource source = createMysqlSource(config);
  runner = new SourceRunner.Builder(MySQLBinLogDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, count);
  assertThat(output.getRecords().get(LANE), is(IsEmptyCollection.<Record>empty()));

  execute(ds, "DELETE FROM foo");

  output = runner.runProduce(output.getNewOffset(), count / 2);

  List<Record> records = new ArrayList<>();
  records.addAll(output.getRecords().get(LANE));

  assertThat(records, hasSize(count));
}
 
Example #27
Source Project: java-jwt   Author: auth0   File: PayloadDeserializerTest.java    License: MIT License 5 votes vote down vote up
@Test
public void shouldGetEmptyStringArrayWhenParsingEmptyTextNode() throws Exception {
    Map<String, JsonNode> tree = new HashMap<>();
    TextNode textNode = new TextNode("");
    tree.put("key", textNode);

    List<String> values = deserializer.getStringOrArray(tree, "key");
    assertThat(values, is(notNullValue()));
    assertThat(values, is(IsEmptyCollection.empty()));
}
 
Example #28
Source Project: cache2k   Author: cache2k   File: CacheManagerManagementTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * https://github.com/jsr107/jsr107tck/issues/87
 * changed in 1.1, CacheManager.getCacheNames()
 * @throws MalformedObjectNameException
 */
@After
public void tearDown() throws MalformedObjectNameException {
  //assertEquals(0, mBeanServer.queryNames(new ObjectName("java.cache:*"), null).size());
  if (!cacheManager.isClosed()) {
    for (String cacheName : cacheManager.getCacheNames()) {
      cacheManager.destroyCache(cacheName);
    }
  }
  cacheManager.close();
  //All registered object names should be removed during shutdown
  assertThat(mBeanServer.queryNames(new ObjectName("javax.cache:*"), null), IsEmptyCollection.<ObjectName>empty());
}
 
Example #29
Source Project: cactoos   Author: yegor256   File: BehavesAsCollection.java    License: MIT License 4 votes vote down vote up
@Override
@SuppressWarnings({ "unchecked", "PMD.ClassCastExceptionWithToArray" })
public boolean matchesSafely(final Collection<E> col) {
    new Assertion<>(
        "Must contain item",
        col,
        new IsCollectionContaining<>(
            new IsEqual<>(
                this.sample
            )
        )
    ).affirm();
    new Assertion<>(
        "Must not be empty",
        col,
        new IsNot<>(
            new IsEmptyCollection<>()
        )
    ).affirm();
    new Assertion<>(
        "Size must be more than 0",
        col,
        new IsCollectionWithSize<>(
            new MatcherOf<>(s -> s > 0)
        )
    ).affirm();
    new Assertion<>(
        "Array must contain item",
        new ListOf<>(
            (E[]) col.toArray()
        ),
        new IsCollectionContaining<>(
            new IsEqual<>(this.sample)
        )
    ).affirm();
    final E[] array = (E[]) new Object[col.size()];
    col.toArray(array);
    new Assertion<>(
        "Array from collection must contain item",
        new ListOf<>(array),
        new IsCollectionContaining<>(
            new IsEqual<>(this.sample)
        )
    ).affirm();
    new Assertion<>(
        "Must contain list with the item",
        col.containsAll(
            new ListOf<>(this.sample)
        ),
        new IsEqual<>(true)
    ).affirm();
    return true;
}
 
Example #30
Source Project: raml-module-builder   Author: folio-org   File: CompoundIndexIT.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void multiFieldNamesDotStarGIN() throws Exception {
  assertThat( cqla("ginfielddotstar == \"Boston\""),  IsEmptyCollection.empty());
}