diff options
author | Axel Richard | 2015-03-17 16:47:30 +0000 |
---|---|---|
committer | Axel Richard | 2015-03-17 16:47:30 +0000 |
commit | 7b5a217a67bc4b703e431de19e6ed103379a2dc4 (patch) | |
tree | ddd08e80c6de8eea8c738566ad07685f2357c408 /plugins/org.eclipse.emf.compare.tests/src | |
parent | c9b3c3357beeafd0b5fa34684641d54f223d1f88 (diff) | |
download | org.eclipse.emf.compare-7b5a217a67bc4b703e431de19e6ed103379a2dc4.tar.gz org.eclipse.emf.compare-7b5a217a67bc4b703e431de19e6ed103379a2dc4.tar.xz org.eclipse.emf.compare-7b5a217a67bc4b703e431de19e6ed103379a2dc4.zip |
[461224] Fix NoSuchElementException in Graph.
Also add test case to reproduce the problem.
Bug: 461224
Change-Id: I15b287997f96ea6b2c9516040a3a45c91c08a6ba
Signed-off-by: Axel Richard <axel.richard@obeo.fr>
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src')
-rw-r--r-- | plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/GraphTest.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/GraphTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/GraphTest.java new file mode 100644 index 000000000..01cf4ddd8 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/GraphTest.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2015 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.tests.utils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; + +import java.util.Set; + +import org.eclipse.emf.compare.internal.utils.Graph; +import org.junit.Test; + +/** + * We will use this to test the utility methods exposed by the {@link Graph}. + * + * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a> + */ +@SuppressWarnings("nls") +public class GraphTest { + + @Test + public void testBuildSubGraph() { + Graph<String> graph = new Graph<String>(); + //@formatter:off + /* + * Add the following graph: + * e f + * | | + * b c d + * \ | / + * \ | / + * --------- + * | + * a + */ + //@formatter:on + graph.addChildren("a", ImmutableSet.of("b", "c", "d")); + graph.addChildren("c", ImmutableSet.of("e")); + graph.addChildren("d", ImmutableSet.of("f")); + + Set<String> subgraph = graph.getSubgraphContaining("d", ImmutableSet.of("c")); + assertEquals(4, subgraph.size()); + assertTrue(subgraph.containsAll(Lists.newArrayList("a", "b", "d", "f"))); + } +} |