Example usage for java.util.concurrent ConcurrentMap size

List of usage examples for java.util.concurrent ConcurrentMap size

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentMap size.

Prototype

int size();

Source Link

Document

Returns the number of key-value mappings in this map.

Usage

From source file:com.googlecode.concurrentlinkedhashmap.ConcurrentMapTest.java

@Test(dataProvider = "guardedMap")
public void putIfAbsent(ConcurrentMap<Integer, Integer> map) {
    for (Integer i = 0; i < capacity(); i++) {
        assertThat(map.putIfAbsent(i, i), is(nullValue()));
        assertThat(map.putIfAbsent(i, 1), is(i));
        assertThat(map.get(i), is(i));/*  ww  w  .j a  va2  s  .  co m*/
    }
    assertThat(map.size(), is(equalTo((int) capacity())));
}

From source file:org.opendaylight.ovsdb.plugin.impl.ConfigurationServiceImpl.java

public String getSpecialCaseParentUUID(Node node, String databaseName, String childTableName) {
    if (!databaseName.equals(OvsVswitchdSchemaConstants.DATABASE_NAME))
        return null;
    String[] parentColumn = OvsVswitchdSchemaConstants.getParentColumnToMutate(childTableName);
    if (parentColumn != null && parentColumn[0].equals(OvsVswitchdSchemaConstants.DATABASE_NAME)) {
        Connection connection = connectionService.getConnection(node);
        OpenVSwitch openVSwitch = connection.getClient().getTypedRowWrapper(OpenVSwitch.class, null);
        ConcurrentMap<String, Row> row = this.getRows(node, openVSwitch.getSchema().getName());
        if (row == null || row.size() == 0)
            return null;
        return (String) row.keySet().toArray()[0];
    }/*from   w w  w.  ja  v  a  2 s.  co m*/
    return null;
}

From source file:com.cubeia.firebase.server.lobby.systemstate.StateLobby.java

public String printPacketCounts() {
    ConcurrentMap<LobbyPath, Integer> fullPacketCount = new ConcurrentHashMap<LobbyPath, Integer>();
    ConcurrentMap<LobbyPath, Integer> deltaPacketCount = new ConcurrentHashMap<LobbyPath, Integer>();

    for (SnapshotGenerator generator : generators.values()) {
        ConcurrentMap<LobbyPath, FullSnapshot> fullSnapshots = generator.getFullSnapshots();
        ConcurrentMap<LobbyPath, DeltaSnapshot> deltaSnapshots = generator.getDeltaSnapshots();

        for (LobbyPath path : fullSnapshots.keySet()) {
            FullSnapshot fullSnapshot = fullSnapshots.get(path);
            fullPacketCount.put(path, fullSnapshot.getLobbyData().size());
        }/*  w  w  w  . ja va  2 s . com*/

        for (LobbyPath path : deltaSnapshots.keySet()) {
            DeltaSnapshot deltaSnapshot = deltaSnapshots.get(path);
            deltaPacketCount.put(path, deltaSnapshot.getLobbyData().size());
        }
    }

    String info = "Lobby Snapshots Per Chached Lobby Path\n";
    info += "-----------------------\n";
    info += "Full Packet Path Count:  " + fullPacketCount.size() + "\n";
    info += "Delta Packet Path Count: " + deltaPacketCount.size() + "\n";
    info += "-----------------------\n";
    info += "FULL PACKET COUNT PER PATH\n";
    for (LobbyPath path : fullPacketCount.keySet()) {
        info += StringUtils.rightPad(path.toString(), 60) + "\t : " + fullPacketCount.get(path) + "\n";
    }
    info += "-----------------------\n";
    info += "DELTA PACKET COUNT PER PATH\n";
    for (LobbyPath path : deltaPacketCount.keySet()) {
        info += StringUtils.rightPad(path.toString(), 60) + "\t : " + deltaPacketCount.get(path) + "\n";
        ;
    }

    return info;
}

From source file:com.github.podd.utils.test.OntologyUtilsTest.java

private void assertA1B2C3(final ConcurrentMap<URI, Set<URI>> nextImportsMap) {
    Assert.assertEquals(5, nextImportsMap.size());

    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testVersionUriA1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testVersionUriB1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testVersionUriB2));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testVersionUriC1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testVersionUriC3));

    Assert.assertEquals(0, nextImportsMap.get(OntologyConstant.testVersionUriA1).size());
    Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testVersionUriB1).size());
    Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testVersionUriB2).size());
    Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testVersionUriC1).size());
    Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testVersionUriC3).size());

    Assert.assertTrue(//  w w  w  .j a  va 2 s.c o  m
            nextImportsMap.get(OntologyConstant.testVersionUriB1).contains(OntologyConstant.testVersionUriA1));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testVersionUriB2).contains(OntologyConstant.testVersionUriA1));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testVersionUriC1).contains(OntologyConstant.testVersionUriA1));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testVersionUriC1).contains(OntologyConstant.testVersionUriB1));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testVersionUriC3).contains(OntologyConstant.testVersionUriA1));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testVersionUriC3).contains(OntologyConstant.testVersionUriB2));
}

From source file:com.github.podd.utils.test.OntologyUtilsTest.java

private void assertRealisticImportsMapV2(final ConcurrentMap<URI, Set<URI>> nextImportsMap) {
    Assert.assertEquals(12, nextImportsMap.size());

    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddDcUriV1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddDcUriV2));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddFoafUriV1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddFoafUriV2));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddUserUriV1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddUserUriV2));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddBaseUriV1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddBaseUriV2));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddScienceUriV1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddScienceUriV2));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddPlantUriV1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddPlantUriV2));

    Assert.assertEquals(0, nextImportsMap.get(OntologyConstant.testPoddDcUriV1).size());
    Assert.assertEquals(0, nextImportsMap.get(OntologyConstant.testPoddDcUriV2).size());
    Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testPoddFoafUriV1).size());
    Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testPoddFoafUriV2).size());
    Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testPoddUserUriV1).size());
    Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testPoddUserUriV2).size());
    Assert.assertEquals(3, nextImportsMap.get(OntologyConstant.testPoddBaseUriV1).size());
    Assert.assertEquals(3, nextImportsMap.get(OntologyConstant.testPoddBaseUriV2).size());
    Assert.assertEquals(4, nextImportsMap.get(OntologyConstant.testPoddScienceUriV1).size());
    Assert.assertEquals(4, nextImportsMap.get(OntologyConstant.testPoddScienceUriV2).size());
    Assert.assertEquals(5, nextImportsMap.get(OntologyConstant.testPoddPlantUriV1).size());
    Assert.assertEquals(5, nextImportsMap.get(OntologyConstant.testPoddPlantUriV2).size());

    Assert.assertTrue(/*  www  .  jav  a2  s  .c  o m*/
            nextImportsMap.get(OntologyConstant.testPoddFoafUriV1).contains(OntologyConstant.testPoddDcUriV1));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddFoafUriV2).contains(OntologyConstant.testPoddDcUriV2));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddUserUriV1).contains(OntologyConstant.testPoddDcUriV1));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddUserUriV2).contains(OntologyConstant.testPoddDcUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddUserUriV1)
            .contains(OntologyConstant.testPoddFoafUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddUserUriV2)
            .contains(OntologyConstant.testPoddFoafUriV2));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddBaseUriV1).contains(OntologyConstant.testPoddDcUriV1));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddBaseUriV2).contains(OntologyConstant.testPoddDcUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV1)
            .contains(OntologyConstant.testPoddFoafUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV2)
            .contains(OntologyConstant.testPoddFoafUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV1)
            .contains(OntologyConstant.testPoddUserUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV2)
            .contains(OntologyConstant.testPoddUserUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1)
            .contains(OntologyConstant.testPoddDcUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2)
            .contains(OntologyConstant.testPoddDcUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1)
            .contains(OntologyConstant.testPoddFoafUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2)
            .contains(OntologyConstant.testPoddFoafUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1)
            .contains(OntologyConstant.testPoddUserUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2)
            .contains(OntologyConstant.testPoddUserUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1)
            .contains(OntologyConstant.testPoddBaseUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2)
            .contains(OntologyConstant.testPoddBaseUriV2));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddPlantUriV1).contains(OntologyConstant.testPoddDcUriV1));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddPlantUriV2).contains(OntologyConstant.testPoddDcUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1)
            .contains(OntologyConstant.testPoddFoafUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2)
            .contains(OntologyConstant.testPoddFoafUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1)
            .contains(OntologyConstant.testPoddUserUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2)
            .contains(OntologyConstant.testPoddUserUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1)
            .contains(OntologyConstant.testPoddBaseUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2)
            .contains(OntologyConstant.testPoddBaseUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1)
            .contains(OntologyConstant.testPoddScienceUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2)
            .contains(OntologyConstant.testPoddScienceUriV2));
}

From source file:com.edgenius.wiki.service.impl.PageServiceImpl.java

@SuppressWarnings("unchecked")
public void stopEditing(String pageUuid, User user) {
    Element ele = pageEditingCache.get(pageUuid);
    if (ele != null) {
        ConcurrentMap<String, Long> map = (ConcurrentMap<String, Long>) ele.getValue();
        if (map != null)
            map.remove(user.getUsername());
        if (map == null || map.size() == 0)
            pageEditingCache.remove(pageUuid);
    }/* w w  w. j a  v  a2 s. com*/
}

From source file:com.github.podd.utils.test.OntologyUtilsTest.java

private void assertRealisticImportsMapV3(final ConcurrentMap<URI, Set<URI>> nextImportsMap) {
    Assert.assertEquals(22, nextImportsMap.size());

    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddDcUriV1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddDcUriV2));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddDcUriV3));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddFoafUriV1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddFoafUriV2));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddFoafUriV3));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddUserUriV1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddUserUriV2));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddUserUriV3));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddBaseUriV1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddBaseUriV2));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddBaseUriV3));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddScienceUriV1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddScienceUriV2));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddScienceUriV3));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddPlantUriV1));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddPlantUriV2));
    Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddPlantUriV3));

    Assert.assertEquals(0, nextImportsMap.get(OntologyConstant.testPoddDcUriV1).size());
    Assert.assertEquals(0, nextImportsMap.get(OntologyConstant.testPoddDcUriV2).size());
    Assert.assertEquals(0, nextImportsMap.get(OntologyConstant.testPoddDcUriV3).size());
    Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testPoddFoafUriV1).size());
    Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testPoddFoafUriV2).size());
    Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testPoddFoafUriV3).size());
    Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testPoddUserUriV1).size());
    Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testPoddUserUriV2).size());
    Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testPoddUserUriV3).size());
    Assert.assertEquals(3, nextImportsMap.get(OntologyConstant.testPoddBaseUriV1).size());
    Assert.assertEquals(3, nextImportsMap.get(OntologyConstant.testPoddBaseUriV2).size());
    Assert.assertEquals(3, nextImportsMap.get(OntologyConstant.testPoddBaseUriV3).size());
    Assert.assertEquals(4, nextImportsMap.get(OntologyConstant.testPoddScienceUriV1).size());
    Assert.assertEquals(6, nextImportsMap.get(OntologyConstant.testPoddScienceUriV2).size());
    Assert.assertEquals(4, nextImportsMap.get(OntologyConstant.testPoddScienceUriV3).size());
    Assert.assertEquals(5, nextImportsMap.get(OntologyConstant.testPoddPlantUriV1).size());
    Assert.assertEquals(7, nextImportsMap.get(OntologyConstant.testPoddPlantUriV2).size());
    Assert.assertEquals(5, nextImportsMap.get(OntologyConstant.testPoddPlantUriV3).size());

    Assert.assertTrue(/*  w w  w. ja v  a  2s  .c  o  m*/
            nextImportsMap.get(OntologyConstant.testPoddFoafUriV1).contains(OntologyConstant.testPoddDcUriV1));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddFoafUriV2).contains(OntologyConstant.testPoddDcUriV2));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddFoafUriV3).contains(OntologyConstant.testPoddDcUriV3));

    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddUserUriV1).contains(OntologyConstant.testPoddDcUriV1));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddUserUriV2).contains(OntologyConstant.testPoddDcUriV2));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddUserUriV3).contains(OntologyConstant.testPoddDcUriV3));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddUserUriV1)
            .contains(OntologyConstant.testPoddFoafUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddUserUriV2)
            .contains(OntologyConstant.testPoddFoafUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddUserUriV3)
            .contains(OntologyConstant.testPoddFoafUriV3));

    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddBaseUriV1).contains(OntologyConstant.testPoddDcUriV1));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddBaseUriV2).contains(OntologyConstant.testPoddDcUriV2));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddBaseUriV3).contains(OntologyConstant.testPoddDcUriV3));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV1)
            .contains(OntologyConstant.testPoddFoafUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV2)
            .contains(OntologyConstant.testPoddFoafUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV3)
            .contains(OntologyConstant.testPoddFoafUriV3));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV1)
            .contains(OntologyConstant.testPoddUserUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV2)
            .contains(OntologyConstant.testPoddUserUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV3)
            .contains(OntologyConstant.testPoddUserUriV3));

    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1)
            .contains(OntologyConstant.testPoddDcUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2)
            .contains(OntologyConstant.testPoddDcUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV3)
            .contains(OntologyConstant.testPoddDcUriV3));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1)
            .contains(OntologyConstant.testPoddFoafUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2)
            .contains(OntologyConstant.testPoddFoafUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV3)
            .contains(OntologyConstant.testPoddFoafUriV3));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1)
            .contains(OntologyConstant.testPoddUserUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2)
            .contains(OntologyConstant.testPoddUserUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV3)
            .contains(OntologyConstant.testPoddUserUriV3));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1)
            .contains(OntologyConstant.testPoddBaseUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2)
            .contains(OntologyConstant.testPoddBaseUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV3)
            .contains(OntologyConstant.testPoddBaseUriV3));

    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddPlantUriV1).contains(OntologyConstant.testPoddDcUriV1));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddPlantUriV2).contains(OntologyConstant.testPoddDcUriV2));
    Assert.assertTrue(
            nextImportsMap.get(OntologyConstant.testPoddPlantUriV3).contains(OntologyConstant.testPoddDcUriV3));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1)
            .contains(OntologyConstant.testPoddFoafUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2)
            .contains(OntologyConstant.testPoddFoafUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV3)
            .contains(OntologyConstant.testPoddFoafUriV3));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1)
            .contains(OntologyConstant.testPoddUserUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2)
            .contains(OntologyConstant.testPoddUserUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV3)
            .contains(OntologyConstant.testPoddUserUriV3));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1)
            .contains(OntologyConstant.testPoddBaseUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2)
            .contains(OntologyConstant.testPoddBaseUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV3)
            .contains(OntologyConstant.testPoddBaseUriV3));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1)
            .contains(OntologyConstant.testPoddScienceUriV1));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2)
            .contains(OntologyConstant.testPoddScienceUriV2));
    Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV3)
            .contains(OntologyConstant.testPoddScienceUriV3));
}

From source file:com.github.podd.utils.test.OntologyUtilsTest.java

@Test
public void testImportsOrderZeroLevels() throws Exception {
    final Model model = new LinkedHashModel();
    OntologyUtils.ontologyIDsToModel(Arrays.asList(OntologyConstant.testOntologyID), model);

    final Set<URI> schemaOntologyUris = new HashSet<URI>();
    final Set<URI> schemaVersionUris = new HashSet<URI>();

    schemaOntologyUris.add(OntologyConstant.testOntologyUri1);

    schemaVersionUris.add(OntologyConstant.testVersionUri1);

    final ConcurrentMap<URI, Set<URI>> importsMap = new ConcurrentHashMap<URI, Set<URI>>();
    // Expected output solution from importsMap after calling orderImports
    // importsMap.put(testVersionUri1, new HashSet<URI>());

    final List<URI> orderImports = OntologyUtils.orderImports(model, schemaOntologyUris, schemaVersionUris,
            importsMap, false);//w  w w.j av a2s.  c o m

    Assert.assertEquals(1, orderImports.size());
    Assert.assertEquals(OntologyConstant.testVersionUri1, orderImports.get(0));

    Assert.assertEquals(1, importsMap.size());
    Assert.assertTrue(importsMap.containsKey(OntologyConstant.testVersionUri1));

    final Set<URI> importsRoot = importsMap.get(OntologyConstant.testVersionUri1);
    Assert.assertNotNull(importsRoot);
    Assert.assertEquals(0, importsRoot.size());
}

From source file:com.github.podd.utils.test.OntologyUtilsTest.java

@Test
public void testImportsOrderOneLevel() throws Exception {
    final Model model = new LinkedHashModel();
    OntologyUtils.ontologyIDsToModel(Arrays.asList(OntologyConstant.testOntologyID), model);
    model.add(OntologyConstant.testVersionUri1, OWL.IMPORTS, OntologyConstant.testImportOntologyUri1);
    model.add(OntologyConstant.testImportOntologyUri1, RDF.TYPE, OWL.ONTOLOGY);
    model.add(OntologyConstant.testImportOntologyUri1, OWL.VERSIONIRI, OntologyConstant.testImportVersionUri1);
    model.add(OntologyConstant.testImportVersionUri1, RDF.TYPE, OWL.ONTOLOGY);

    final Set<URI> schemaOntologyUris = new HashSet<URI>();
    final Set<URI> schemaVersionUris = new HashSet<URI>();

    schemaOntologyUris.add(OntologyConstant.testOntologyUri1);
    schemaOntologyUris.add(OntologyConstant.testImportOntologyUri1);

    schemaVersionUris.add(OntologyConstant.testVersionUri1);
    schemaVersionUris.add(OntologyConstant.testImportVersionUri1);

    final ConcurrentMap<URI, Set<URI>> importsMap = new ConcurrentHashMap<URI, Set<URI>>();
    // Expected output solution from importsMap after calling orderImports
    // importsMap.put(testVersionUri1,
    // Collections.singleton(OntologyConstant.testImportVersionUri1));
    // importsMap.put(testImportVersionUri1, new HashSet<URI>());

    final List<URI> orderImports = OntologyUtils.orderImports(model, schemaOntologyUris, schemaVersionUris,
            importsMap, false);//w w w  . j av  a2 s  .com

    Assert.assertEquals(2, orderImports.size());
    Assert.assertEquals(OntologyConstant.testImportVersionUri1, orderImports.get(0));
    Assert.assertEquals(OntologyConstant.testVersionUri1, orderImports.get(1));

    Assert.assertEquals(2, importsMap.size());
    Assert.assertTrue(importsMap.containsKey(OntologyConstant.testImportVersionUri1));
    Assert.assertTrue(importsMap.containsKey(OntologyConstant.testVersionUri1));

    final Set<URI> imports1 = importsMap.get(OntologyConstant.testImportVersionUri1);
    Assert.assertNotNull(imports1);
    Assert.assertEquals(0, imports1.size());

    final Set<URI> importsRoot = importsMap.get(OntologyConstant.testVersionUri1);
    Assert.assertNotNull(importsRoot);
    Assert.assertEquals(1, importsRoot.size());
    Assert.assertEquals(OntologyConstant.testImportVersionUri1, importsRoot.iterator().next());
}

From source file:com.github.podd.utils.test.OntologyUtilsTest.java

@Test
public void testImportsOrderOneLevelOutOfOrder() throws Exception {
    final Model model = new LinkedHashModel();
    OntologyUtils.ontologyIDsToModel(Arrays.asList(OntologyConstant.testOntologyID), model);
    model.add(OntologyConstant.testImportOntologyUri1, RDF.TYPE, OWL.ONTOLOGY);
    model.add(OntologyConstant.testImportOntologyUri1, OWL.VERSIONIRI, OntologyConstant.testImportVersionUri1);
    model.add(OntologyConstant.testImportVersionUri1, RDF.TYPE, OWL.ONTOLOGY);
    model.add(OntologyConstant.testVersionUri1, OWL.IMPORTS, OntologyConstant.testImportOntologyUri1);

    final Set<URI> schemaOntologyUris = new LinkedHashSet<URI>();
    final Set<URI> schemaVersionUris = new LinkedHashSet<URI>();

    schemaOntologyUris.add(OntologyConstant.testImportOntologyUri1);
    schemaOntologyUris.add(OntologyConstant.testOntologyUri1);

    schemaVersionUris.add(OntologyConstant.testImportVersionUri1);
    schemaVersionUris.add(OntologyConstant.testVersionUri1);

    final ConcurrentMap<URI, Set<URI>> importsMap = new ConcurrentHashMap<URI, Set<URI>>();
    // Expected output solution from importsMap after calling orderImports
    // importsMap.put(testVersionUri1,
    // Collections.singleton(OntologyConstant.testImportVersionUri1));
    // importsMap.put(testImportVersionUri1, new HashSet<URI>());

    final List<URI> orderImports = OntologyUtils.orderImports(model, schemaOntologyUris, schemaVersionUris,
            importsMap, false);//  w ww.  j  a v a 2s .  com

    Assert.assertEquals(2, orderImports.size());
    Assert.assertEquals(OntologyConstant.testImportVersionUri1, orderImports.get(0));
    Assert.assertEquals(OntologyConstant.testVersionUri1, orderImports.get(1));

    Assert.assertEquals(2, importsMap.size());
    Assert.assertTrue(importsMap.containsKey(OntologyConstant.testImportVersionUri1));
    Assert.assertTrue(importsMap.containsKey(OntologyConstant.testVersionUri1));

    final Set<URI> imports1 = importsMap.get(OntologyConstant.testImportVersionUri1);
    Assert.assertNotNull(imports1);
    Assert.assertEquals(0, imports1.size());

    final Set<URI> importsRoot = importsMap.get(OntologyConstant.testVersionUri1);
    Assert.assertNotNull(importsRoot);
    Assert.assertEquals(1, importsRoot.size());
    Assert.assertEquals(OntologyConstant.testImportVersionUri1, importsRoot.iterator().next());
}