Example usage for org.apache.commons.collections4 ListUtils isEqualList

List of usage examples for org.apache.commons.collections4 ListUtils isEqualList

Introduction

In this page you can find the example usage for org.apache.commons.collections4 ListUtils isEqualList.

Prototype

public static boolean isEqualList(final Collection<?> list1, final Collection<?> list2) 

Source Link

Document

Tests two lists for value-equality as per the equality contract in java.util.List#equals(java.lang.Object) .

Usage

From source file:libepg.util.db.AboutDBTest.java

/**
 * Test of convertToTable method, of class Reader2.
 *
 * @throws java.io.IOException//from w  w w. ja  v a  2s .c  o m
 */
@Test
public void testConvert() throws IOException {
    LOG.info("convert");

    List<TsPacket> _expResult = be.getExpResult_Normal_And_Wrong_Sync();
    TestPacket_BitError.dumpPacketList(_expResult);

    try (JDBCAccessor ac = JDBCAccessor.getInstance()) {
        ac.connect(AboutDB.URL);
        Connection conn = ac.getConnection();
        AboutDB.convertToTable(_expResult, conn);
        debug_dump_table(conn);

        List<TsPacket> result = AboutDB.convertToList(conn);
        TestPacket_BitError.dumpPacketList(result);

        assertEquals(ListUtils.isEqualList(_expResult, result), true);
    } catch (SQLException ex) {
        LOG.fatal(ex);
        fail();
    }
}

From source file:com.garethahealy.karaf.commands.ensemble.healthy.EnsembleHealthyAction.java

protected Boolean waitForEnsembleHealthy() throws InterruptedException {
    Boolean hasTimedOut = false;/*from  w w w  . j a v  a2s . co  m*/

    Long currentTime = System.nanoTime();
    Long waitTimeout = currentTime + TimeUnit.MILLISECONDS.toNanos(wait);

    while (!hasTimedOut) {
        List<String> containersInEnsemble = clusterService.getEnsembleContainers();

        //Sort them to be alphabetical
        Collections.sort(containersInEnsemble);

        Boolean isEqualList = ListUtils.isEqualList(containers, containersInEnsemble);
        if (isEqualList) {
            log.trace("MATCH: Expected: {}, Result: {}", StringUtils.join(containers, ','),
                    StringUtils.join(containersInEnsemble, ','));

            System.out.println(
                    String.format(FORMAT, "Ensemble List: ", StringUtils.join(containersInEnsemble, ',')));
            System.out.println("Ensemble Healthy: success");
            break;

        } else {
            log.trace("NON-MATCH: Expected: {}, Result: {}. Waiting...", StringUtils.join(containers, ','),
                    StringUtils.join(containersInEnsemble, ','));
        }

        currentTime = System.nanoTime();
        if (currentTime > waitTimeout) {
            log.trace("Ensemble of {} took too long. Current time {}ns is greater than wait {}ns",
                    StringUtils.join(containers, ','), currentTime, waitTimeout);

            hasTimedOut = true;
            break;
        }

        //Probably not the best way, but does its job
        TimeUnit.MILLISECONDS.sleep(tick);
    }

    return hasTimedOut;
}

From source file:com.romeikat.datamessie.core.base.query.entity.EntityQueryTest.java

@Test
public void listObjects() {
    final EntityQuery<BarEntity> query = new EntityQuery<>(BarEntity.class);
    query.addOrder(Order.asc("name"));

    final List<BarEntity> objects = query.listObjects(sessionProvider.getStatelessSession());
    final List<String> names = getNames(objects);
    final List<String> expected = Arrays.asList("BarEntity1", "BarEntity2", "BarEntity3", "BarEntity4");
    assertTrue(ListUtils.isEqualList(expected, names));

    dbSetupTracker.skipNextLaunch();/*w w w  .  j a  va 2s  .  c om*/
}

From source file:com.romeikat.datamessie.core.base.query.entity.EntityQueryTest.java

@Test
public void listIdsForProperty() {
    final EntityQuery<BarEntity> query = new EntityQuery<>(BarEntity.class);
    query.addOrder(Order.asc("name"));

    final List<Long> ids = query.listIdsForProperty(sessionProvider.getStatelessSession(), "fooId");
    final List<Long> expected = Arrays.asList(1l, 2l, 3l, 4l);
    assertTrue(ListUtils.isEqualList(expected, ids));

    dbSetupTracker.skipNextLaunch();//from   w  ww  .  jav  a  2  s.  c o  m
}

From source file:com.romeikat.datamessie.core.base.query.entity.EntityWithIdQueryTest.java

@Test
public void listObjects() {
    final EntityWithIdQuery<BarEntityWithId> query = new EntityWithIdQuery<>(BarEntityWithId.class);
    query.addOrder(Order.asc("name"));

    final List<BarEntityWithId> objects = query.listObjects(sessionProvider.getStatelessSession());
    final List<String> names = getNames(objects);
    final List<String> expected = Arrays.asList("BarEntityWithId1", "BarEntityWithId2", "BarEntityWithId3",
            "BarEntityWithId4");
    assertTrue(ListUtils.isEqualList(expected, names));

    dbSetupTracker.skipNextLaunch();/*from ww w.  j av  a2s.  c om*/
}

From source file:com.romeikat.datamessie.core.base.query.entity.EntityWithIdQueryTest.java

@Test
public void listIds() {
    final EntityWithIdQuery<BarEntityWithId> query = new EntityWithIdQuery<>(BarEntityWithId.class);
    query.addOrder(Order.asc("name"));

    final List<Long> ids = query.listIds(sessionProvider.getStatelessSession());
    final List<Long> expected = Arrays.asList(1l, 2l, 3l, 4l);
    assertTrue(ListUtils.isEqualList(expected, ids));

    dbSetupTracker.skipNextLaunch();//from w  w  w  . j a  v a2s . c  o  m
}

From source file:com.romeikat.datamessie.core.base.query.entity.EntityQueryTest.java

@Test
public void listForProjection() {
    final EntityQuery<BarEntity> query = new EntityQuery<>(BarEntity.class);
    query.addOrder(Order.asc("name"));

    @SuppressWarnings("unchecked")
    final List<String> names = (List<String>) query.listForProjection(sessionProvider.getStatelessSession(),
            Projections.property("name"));
    final List<String> expected = Arrays.asList("BarEntity1", "BarEntity2", "BarEntity3", "BarEntity4");
    assertTrue(ListUtils.isEqualList(expected, names));

    dbSetupTracker.skipNextLaunch();//from ww  w.  j  a  v  a  2 s.com
}

From source file:libepg.ts.reader.Reader2Test.java

/**
 * Test of getPackets method, of class Reader2.
 *
 * @throws java.io.IOException/*from  w ww . j  av a 2s .  co m*/
 */
@Test
public void testGetPackets_Normal() throws IOException {
    LOG.info("getPackets_Normal");
    File temp_NotContainError = TestPacket_BitError.writeBytesToFile(this.list_NotContainError);
    Reader2 instance = new Reader2(temp_NotContainError);
    List<TsPacket> _expResult = this.expResult_Normal_And_Wrong_Sync;
    List<TsPacket> result = instance.getPackets();
    LOG.info("expResult");
    dumpPacketList(_expResult);
    LOG.info("result");
    dumpPacketList(result);
    assertEquals(ListUtils.isEqualList(_expResult, result), true);
}

From source file:com.romeikat.datamessie.core.base.query.entity.EntityWithIdQueryTest.java

@Test
public void listIdsForProperty() {
    final EntityWithIdQuery<BarEntityWithId> query = new EntityWithIdQuery<>(BarEntityWithId.class);
    query.addOrder(Order.asc("name"));

    final List<Long> ids = query.listIdsForProperty(sessionProvider.getStatelessSession(), "fooId");
    final List<Long> expected = Arrays.asList(1l, 2l, 3l, 4l);
    assertTrue(ListUtils.isEqualList(expected, ids));

    dbSetupTracker.skipNextLaunch();/*from   w w w .  j  av  a  2s  . co m*/
}

From source file:libepg.ts.reader.Reader2Test.java

/**
 * Test of getPackets method, of class Reader2.
 *
 * @throws java.io.IOException//from www.  j a va2 s  .c o  m
 */
@Test
public void testGetPackets_WrongSync() throws IOException {
    LOG.info("getPackets_WrongSync");
    File temp_ContainError_WrongSync = TestPacket_BitError.writeBytesToFile(this.list_ContainError_WrongSync);
    Reader2 instance = new Reader2(temp_ContainError_WrongSync);
    List<TsPacket> _expResult = this.expResult_Normal_And_Wrong_Sync;
    List<TsPacket> result = instance.getPackets();
    LOG.info("expResult");
    dumpPacketList(_expResult);
    LOG.info("result");
    dumpPacketList(result);
    assertEquals(ListUtils.isEqualList(_expResult, result), true);
}