Search in sources :

Example 56 with SortedSet

use of java.util.SortedSet in project sling by apache.

the class BundleTaskCreatorTest method testBundleUpgradeSnapshot.

@Test
public void testBundleUpgradeSnapshot() throws IOException {
    // Need to use OSGi-compliant version number, in bundles
    // bnd and other tools generate correct numbers.
    final String v = "2.0.7.SNAPSHOT";
    final TaskResource[] r = { new MockBundleResource(SN, v) };
    {
        final MockBundleTaskCreator c = new MockBundleTaskCreator();
        c.addBundleInfo(SN, v, Bundle.ACTIVE);
        final SortedSet<InstallTask> s = getTasks(r, c);
        assertEquals("Expected one task", 1, s.size());
        assertTrue("Expected a BundleUpdateTask", s.first() instanceof BundleUpdateTask);
    }
}
Also used : TaskResource(org.apache.sling.installer.api.tasks.TaskResource) MockBundleResource(org.apache.sling.installer.core.impl.MockBundleResource) SortedSet(java.util.SortedSet) Test(org.junit.Test)

Example 57 with SortedSet

use of java.util.SortedSet in project sling by apache.

the class BundleTaskCreatorTest method testDowngradeOfRemovedResource.

@Test
public void testDowngradeOfRemovedResource() throws IOException {
    final MockBundleResource[] r = { new MockBundleResource(SN, "1.0.0"), new MockBundleResource(SN, "1.1.0") };
    // Simulate V1.1 installed but resource is gone -> downgrade to 1.0
    r[1].setState(ResourceState.UNINSTALL);
    {
        final MockBundleTaskCreator c = new MockBundleTaskCreator();
        c.addBundleInfo(SN, "1.1.0", Bundle.ACTIVE);
        final SortedSet<InstallTask> s = getTasks(r, c);
        assertEquals("Expected two tasks", 2, s.size());
        final Iterator<InstallTask> i = s.iterator();
        final InstallTask first = i.next();
        assertTrue("Expected a ChangeStateTask:" + first, first instanceof ChangeStateTask);
        final InstallTask second = i.next();
        assertTrue("Expected a BundleRemoveTask", second instanceof BundleRemoveTask);
        final BundleRemoveTask t = (BundleRemoveTask) second;
        assertEquals("Remove should be to V1.1", r[1].getEntityId(), t.getResource().getEntityId());
    }
}
Also used : MockBundleResource(org.apache.sling.installer.core.impl.MockBundleResource) Iterator(java.util.Iterator) ChangeStateTask(org.apache.sling.installer.api.tasks.ChangeStateTask) SortedSet(java.util.SortedSet) InstallTask(org.apache.sling.installer.api.tasks.InstallTask) Test(org.junit.Test)

Example 58 with SortedSet

use of java.util.SortedSet in project processdash by dtuma.

the class EVTaskDependencyResolver method getTaskListsContaining.

public List getTaskListsContaining(String taskID) {
    if (taskID == null)
        return null;
    Matcher m = TASK_ID_PATTERN.matcher(taskID);
    if (!m.matches())
        return null;
    else
        // At the moment, this will ignore the extra path info on the
        // task ID, and resolve only based on the initial task ID portion.
        // this should not cause problems, because all dependencies with
        // extra path information should have been created with an
        // explicit task list target, and this routine might never get
        // called.  If it does, we'll return all task lists which contain
        // the base taskID, regardless of whether they actually contain a
        // task descendant named by the extra path.
        taskID = m.group(PAT_GROUP_TASK_ID);
    maybeRefreshCache();
    SortedSet infoList = (SortedSet) taskCache.get(taskID);
    if (infoList == null || infoList.isEmpty())
        return null;
    else {
        List result = new LinkedList();
        for (Iterator i = infoList.iterator(); i.hasNext(); ) {
            TaskListInfo info = (TaskListInfo) i.next();
            result.add(info.getTaskListName());
        }
        return result;
    }
}
Also used : Matcher(java.util.regex.Matcher) Iterator(java.util.Iterator) XMLDepthFirstIterator(net.sourceforge.processdash.util.XMLDepthFirstIterator) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) SortedSet(java.util.SortedSet) LinkedList(java.util.LinkedList)

Example 59 with SortedSet

use of java.util.SortedSet in project processdash by dtuma.

the class EVTaskDependencyResolver method getCanonicalTaskName.

public String getCanonicalTaskName(String taskID) {
    maybeRefreshNameCache();
    SortedSet infoList = (SortedSet) nameCache.get(taskID);
    if (infoList == null || infoList.isEmpty())
        return null;
    else {
        TaskNameInfo info = (TaskNameInfo) infoList.first();
        return info.getTaskName();
    }
}
Also used : SortedSet(java.util.SortedSet)

Example 60 with SortedSet

use of java.util.SortedSet in project winery by eclipse.

the class Util method convertQNameListToNamespaceToLocalNameList.

public static SortedMap<String, SortedSet<String>> convertQNameListToNamespaceToLocalNameList(List<QName> list) {
    SortedMap<String, SortedSet<String>> res = new TreeMap<>();
    for (QName qname : list) {
        SortedSet<String> localNameSet = res.computeIfAbsent(qname.getNamespaceURI(), k -> new TreeSet<>());
        localNameSet.add(qname.getLocalPart());
    }
    return res;
}
Also used : QName(javax.xml.namespace.QName) TreeMap(java.util.TreeMap) SortedSet(java.util.SortedSet)

Aggregations

SortedSet (java.util.SortedSet)127 TreeSet (java.util.TreeSet)49 Iterator (java.util.Iterator)43 HashMap (java.util.HashMap)24 NavigableSet (java.util.NavigableSet)22 ArrayList (java.util.ArrayList)20 Map (java.util.Map)20 List (java.util.List)19 Set (java.util.Set)19 TreeMap (java.util.TreeMap)18 HashSet (java.util.HashSet)15 Test (org.junit.Test)13 IOException (java.io.IOException)12 Collection (java.util.Collection)10 Comparator (java.util.Comparator)7 LinkedHashMap (java.util.LinkedHashMap)7 LinkedList (java.util.LinkedList)5 SolverException (cbit.vcell.solver.SolverException)3 TestStringSortedSetGenerator (com.google.common.collect.testing.TestStringSortedSetGenerator)3 File (java.io.File)3