Author: ruschein
Date: 2010-11-10 15:17:40 -0800 (Wed, 10 Nov 2010)
New Revision: 22813
Added:
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/AbstractNestedNetworkEvent.java
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/SetNestedNetworkEvent.java
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/SetNestedNetworkListener.java
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/UnsetNestedNetworkEvent.java
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/UnsetNestedNetworkListener.java
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/SetNestedNetworkEventTest.java
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/UnsetNestedNetworkEventTest.java
Log:
Added nested network related events and listeners as well as corresponding
tests.
Copied:
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/AbstractNestedNetworkEvent.java
(from rev 22810,
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/AbstractNodeEvent.java)
===================================================================
---
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/AbstractNestedNetworkEvent.java
(rev 0)
+++
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/AbstractNestedNetworkEvent.java
2010-11-10 23:17:40 UTC (rev 22813)
@@ -0,0 +1,67 @@
+/*
+ Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.model.events;
+
+
+import org.cytoscape.event.AbstractCyEvent;
+
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+
+
+/** Base class for all nested network events. */
+class AbstractNestedNetworkEvent extends AbstractCyEvent<CyNode> {
+ private final CyNode node;
+ private final CyNetwork network;
+
+ AbstractNestedNetworkEvent(final Class listenerClass, final CyNode
node, final CyNetwork network) {
+ super(node, listenerClass);
+ if (node == null)
+ throw new NullPointerException("node cannot be null!");
+ if (network == null)
+ throw new NullPointerException("network cannot be
null!");
+ this.node = node;
+ this.network = network;
+ }
+
+ /**
+ * Returns the CyNode for this event.
+ * @return The CyNode for this event.
+ */
+ public CyNode getNode() {
+ return node;
+ }
+
+ /**
+ * Returns the CyNetwork for this event.
+ * @return The CyNetwork for this event.
+ */
+ public CyNetwork getNetwork() {
+ return network;
+ }
+}
Copied:
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/SetNestedNetworkEvent.java
(from rev 22810,
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/AddedNodeEvent.java)
===================================================================
---
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/SetNestedNetworkEvent.java
(rev 0)
+++
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/SetNestedNetworkEvent.java
2010-11-10 23:17:40 UTC (rev 22813)
@@ -0,0 +1,45 @@
+/*
+ Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.model.events;
+
+
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+
+
+/** Used to track setting of nested networks on nodes. */
+public final class SetNestedNetworkEvent extends AbstractNestedNetworkEvent {
+ /**
+ * Constructs event.
+ * @param node the node that the nested network was set on
+ * @param network the network that was set as the nested network on
"node"
+ */
+ public SetNestedNetworkEvent(final CyNode node, final CyNetwork
network) {
+ super(SetNestedNetworkListener.class, node, network);
+ }
+}
Copied:
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/SetNestedNetworkListener.java
(from rev 22810,
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/AddedNodeListener.java)
===================================================================
---
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/SetNestedNetworkListener.java
(rev 0)
+++
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/SetNestedNetworkListener.java
2010-11-10 23:17:40 UTC (rev 22813)
@@ -0,0 +1,41 @@
+/*
+ Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.model.events;
+
+
+import org.cytoscape.event.CyListener;
+
+
+/** Listener for SetNestedNetworkEvents. */
+public interface SetNestedNetworkListener extends CyListener {
+ /**
+ * The method that should handle the specified event.
+ * @param e The event to be handled.
+ */
+ void handleEvent(SetNestedNetworkEvent e);
+}
Copied:
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/UnsetNestedNetworkEvent.java
(from rev 22810,
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/AddedNodeEvent.java)
===================================================================
---
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/UnsetNestedNetworkEvent.java
(rev 0)
+++
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/UnsetNestedNetworkEvent.java
2010-11-10 23:17:40 UTC (rev 22813)
@@ -0,0 +1,45 @@
+/*
+ Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.model.events;
+
+
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+
+
+/** Used to track removing of nested networks from nodes. */
+public final class UnsetNestedNetworkEvent extends AbstractNestedNetworkEvent {
+ /**
+ * Constructs event.
+ * @param node the node that the nested network was removed from
+ * @param network the network that was removed as the nested network
on "node"
+ */
+ public UnsetNestedNetworkEvent(final CyNode node, final CyNetwork
network) {
+ super(UnsetNestedNetworkListener.class, node, network);
+ }
+}
Copied:
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/UnsetNestedNetworkListener.java
(from rev 22810,
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/AddedNodeListener.java)
===================================================================
---
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/UnsetNestedNetworkListener.java
(rev 0)
+++
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/UnsetNestedNetworkListener.java
2010-11-10 23:17:40 UTC (rev 22813)
@@ -0,0 +1,41 @@
+/*
+ Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.model.events;
+
+
+import org.cytoscape.event.CyListener;
+
+
+/** Listener for UnsetNestedNetworkEvents. */
+public interface UnsetNestedNetworkListener extends CyListener {
+ /**
+ * The method that should handle the specified event.
+ * @param e The event to be handled.
+ */
+ void handleEvent(UnsetNestedNetworkEvent e);
+}
Copied:
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/SetNestedNetworkEventTest.java
(from rev 22810,
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/AboutToRemoveEdgeEventTest.java)
===================================================================
---
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/SetNestedNetworkEventTest.java
(rev 0)
+++
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/SetNestedNetworkEventTest.java
2010-11-10 23:17:40 UTC (rev 22813)
@@ -0,0 +1,92 @@
+/*
+ Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.model.events;
+
+
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.mockito.Mockito.*;
+
+
+public class SetNestedNetworkEventTest {
+ private SetNestedNetworkEvent event;
+ private CyNode node;
+ private CyNetwork net;
+
+ @Before
+ public void init() {
+ node = mock(CyNode.class);
+ net = mock(CyNetwork.class);
+ event = new SetNestedNetworkEvent(node, net);
+ }
+
+ @Test
+ public void testGetNode() {
+ assertEquals("getNode() failed!", event.getNode(), node);
+ }
+
+ @Test
+ public void testGetNetwork() {
+ assertEquals("getNode() failed!", event.getNetwork(), net);
+ }
+
+ @Test
+ public void testGetSource() {
+ assertEquals("getSource() failed!", event.getSource(), node);
+ }
+
+ @Test
+ public void testGetListenerClass() {
+ assertEquals("Invalid listener class!",
event.getListenerClass(), SetNestedNetworkListener.class);
+ }
+
+ @Test
+ public void testNullNode() {
+ try {
+ SetNestedNetworkEvent ev = new
SetNestedNetworkEvent(null, net);
+ } catch (NullPointerException npe) {
+ return;
+ }
+ fail("didn't catch expected npe for node");
+ }
+
+ @Test
+ public void testNullNetwork() {
+ try {
+ SetNestedNetworkEvent ev = new
SetNestedNetworkEvent(node, null);
+ } catch (NullPointerException npe) {
+ return;
+ }
+ fail("didn't catch expected npe for network");
+ }
+}
Copied:
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/UnsetNestedNetworkEventTest.java
(from rev 22810,
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/AboutToRemoveEdgeEventTest.java)
===================================================================
---
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/UnsetNestedNetworkEventTest.java
(rev 0)
+++
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/UnsetNestedNetworkEventTest.java
2010-11-10 23:17:40 UTC (rev 22813)
@@ -0,0 +1,92 @@
+/*
+ Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.model.events;
+
+
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.mockito.Mockito.*;
+
+
+public class UnsetNestedNetworkEventTest {
+ private UnsetNestedNetworkEvent event;
+ private CyNode node;
+ private CyNetwork net;
+
+ @Before
+ public void init() {
+ node = mock(CyNode.class);
+ net = mock(CyNetwork.class);
+ event = new UnsetNestedNetworkEvent(node, net);
+ }
+
+ @Test
+ public void testGetNode() {
+ assertEquals("getNode() failed!", event.getNode(), node);
+ }
+
+ @Test
+ public void testGetNetwork() {
+ assertEquals("getNode() failed!", event.getNetwork(), net);
+ }
+
+ @Test
+ public void testGetSource() {
+ assertEquals("getSource() failed!", event.getSource(), node);
+ }
+
+ @Test
+ public void testGetListenerClass() {
+ assertEquals("Invalid listener class!",
event.getListenerClass(), UnsetNestedNetworkListener.class);
+ }
+
+ @Test
+ public void testNullNode() {
+ try {
+ UnsetNestedNetworkEvent ev = new
UnsetNestedNetworkEvent(null, net);
+ } catch (NullPointerException npe) {
+ return;
+ }
+ fail("didn't catch expected npe for node");
+ }
+
+ @Test
+ public void testNullNetwork() {
+ try {
+ UnsetNestedNetworkEvent ev = new
UnsetNestedNetworkEvent(node, null);
+ } catch (NullPointerException npe) {
+ return;
+ }
+ fail("didn't catch expected npe for network");
+ }
+}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.