Example usage for java.util List equals

List of usage examples for java.util List equals

Introduction

In this page you can find the example usage for java.util List equals.

Prototype

boolean equals(Object o);

Source Link

Document

Compares the specified object with this list for equality.

Usage

From source file:org.archive.settings.file.PrefixFinderTest.java

private void doTest() {
    // Generate test data.
    SortedSet<String> testData = new TreeSet<String>();
    long seed = System.currentTimeMillis();
    System.out.println("Used seed: " + seed);
    Random random = new Random(seed);
    String prefix = "0";
    testData.add(prefix);/*from w  w  w . j a  v a2s . c  om*/
    for (int i = 1; i < 10000; i++) {
        if (random.nextInt(1024) == 0) {
            prefix += " " + i;
            testData.add(prefix);
        } else {
            testData.add(prefix + " " + i);
        }
    }

    // Brute-force to get the expected results.
    List<String> expected = new ArrayList<String>();
    for (String value : testData) {
        if (prefix.startsWith(value)) {
            expected.add(value);
        }
    }

    // Results go from longest to shortest.
    Collections.reverse(expected);

    final List<String> result = PrefixFinder.find(testData, prefix);

    if (!result.equals(expected)) {
        System.out.println("Expected: " + expected);
        System.out.println("Result:   " + result);
    }
    assertEquals(result, expected);

    // Double-check.
    for (String value : result) {
        if (!prefix.startsWith(value)) {
            System.out.println("Result: " + result);
            fail("Prefix string \"" + prefix + "\" does not start with result key \"" + value + "\"");
        }
    }
}

From source file:org.zhangmz.cymbidium.modules.convert.JaxbMapperTest.java

@Test
public void xmlToObject() {
    String xml = generateXmlByDom4j();
    User user = JaxbMapper.fromXml(xml, User.class);

    System.out.println("Jaxb Xml to Object result:\n" + user);

    Assert.assertEquals(1L, user.getId().longValue());

    // ?//ww w .  j a  va 2 s. c  o  m
    List expecteds = Lists.newArrayList("movie", "sports");
    Assert.assertTrue(expecteds.equals(user.getInterests()));
}

From source file:org.apache.hise.dao.JpaBase.java

@Override
public boolean equals(Object obj) {
    if (obj == null)
        return false;
    List<Object> l1 = new ArrayList<Object>();
    Collections.addAll(l1, getKeys());
    List<Object> l2 = new ArrayList<Object>();
    Collections.addAll(l2, ((JpaBase) obj).getKeys());
    return l1.equals(l2);
}

From source file:fr.umlv.lastproject.smart.browser.FileLoader.java

@Override
public void deliverResult(List<File> data) {
    if (isReset()) {
        onReleaseResources(data);//from  w  ww.  j a va  2s  .  c  o  m
        return;
    }

    List<File> oldData = mData;
    mData = data;

    if (isStarted()) {
        super.deliverResult(data);
    }

    if (oldData != null && !oldData.equals(data)) {
        onReleaseResources(oldData);
    }

}

From source file:org.openvpms.web.component.im.list.LookupListModel.java

/**
 * Refreshes the model, if needed./*from  ww  w.j a  va  2s.com*/
 *
 * @return <tt>true</tt> if the model was refreshed
 */
public boolean refresh() {
    boolean refreshed = false;
    if (source != null) {
        List<Lookup> current = getCurrentLookups();
        List<Lookup> lookups = getLookups();
        if (!current.equals(lookups)) {
            boolean all = getAllIndex() != -1;
            boolean none = getNoneIndex() != -1;
            setObjects(lookups, all, none);
            refreshed = true;
        }
    }
    return refreshed;
}

From source file:petascope.wcs2.wcst.MetadataRollbackTest.java

@Test
public void testMetadataRollback() throws IOException, PetascopeException, SecoreException {
    //update the coverage with a wrong data type
    String gmlCov = IOUtils.toString(TEST_DATASET_UPDATE);
    //create the time point where to add the data
    DimensionSlice dimensionSlice = new DimensionSlice("ansi", "\"2002-11-01T00:00:00+00:00\"");
    List<DimensionSubset> subsets = new ArrayList<DimensionSubset>();
    subsets.add(dimensionSlice);//from w ww.  j  a v a2  s.  c  o  m
    UpdateCoverageRequest updateCoverageRequest = new UpdateCoverageRequest(this.coverageName, gmlCov, null,
            null, null, subsets, null, null, "Float64");
    UpdateCoverageHandler updateCoverageHandler = new UpdateCoverageHandler(this.metadataSource);

    //try to make the failing update
    try {
        updateCoverageHandler.handle(updateCoverageRequest);
    } catch (PetascopeException e) {
        //ok, we expected this, check if the coefficients stayed the same
        List<BigDecimal> newCoefficients = this.metadataSource.getAllCoefficients(this.coverageName,
                IRREG_AXIS_ORDER);
        Assert.assertTrue(newCoefficients.equals(this.initialCoefficientList));
        return;
    } catch (SecoreException e) {
        //problem
        throw e;
    }

    //request didn't fail and it should have, so smth went wrong
    Assert.assertTrue(false);
}

From source file:org.onosproject.yang.compiler.utils.io.impl.YangFileScannerTest.java

/**
 * This testcase checks for a java file inside an empty directory.
 *
 * @throws IOException when fails to do IO operations
 *//*from   w  w  w .j  av a 2 s .c o  m*/
@Test
public void emptyDirJavaScannerTest() throws IOException {

    String emptyDir = baseDir + separator + "scanner1";
    File path = createDirectory(emptyDir);
    List<String> emptyDirContents = getJavaFiles(path.toString());
    List<String> expectedContents = new LinkedList<>();
    assertThat(true, is(emptyDirContents.equals(expectedContents)));
    deleteDirectory(path);
}

From source file:org.onosproject.yang.compiler.utils.io.impl.YangFileScannerTest.java

/**
 * This testcase checks for a yang file inside an empty directory.
 *
 * @throws IOException when fails to do IO operations
 *//*from   www  .jav a  2 s.  co  m*/
@Test
public void emptyDirYangScannerTest() throws IOException {

    String emptyYangDir = baseDir + separator + "scanner1";
    File path = createDirectory(emptyYangDir);
    List<String> emptyDirContents = getYangFiles(path.toString());
    List<String> expectedContents = new LinkedList<>();
    assertThat(true, is(emptyDirContents.equals(expectedContents)));
    deleteDirectory(path);
}

From source file:org.cleverbus.admin.services.log.LogEventParsingIterator.java

/**
 * Ensures that either {@link #parsedEvent} is not null, or the end is reached.
 *
 * @throws IOException if there's a problem opening a new file, while advancing to the next event
 *//*w  ww.java2 s . c om*/
private void nextEvent() throws IOException {
    if (totalCount >= config.getLimit()) {
        Log.debug("Reached {} events limit - stopping", config.getLimit());
        close();
        return;
    }

    if (parsedEvent != null) {
        return;
    }

    boolean haveMore = !reachedEnd();
    while (parsedEvent == null && haveMore) {
        haveMore = seekToNextEvent();
        if (preParsedEvent != null && config.getGroupBy() != null && config.getGroupLimit() != null) {
            // grouping enabled - check group:
            List<String> nextGroupKey = getGroupKey(preParsedEvent, config);
            if (!nextGroupKey.equals(groupKey)) {
                groupKey = nextGroupKey; // this event starts a new group
                groupCount = 1; // reset group counter
            } else if (groupCount >= config.getGroupLimit()) {
                preParsedEvent = null; // discard the pre-parsed event, as its group is full
            } else {
                groupCount++;
            }
        }
    }

    if (parsedEvent != null) {
        fileEventsFound++;
        totalCount++;
    }
}