# HG changeset patch # User one # Date 1381814785 -32400 # Node ID 9ab7d515e076b593cd8aacbdddc9619f6610e883 # Parent 2520a5bd3dac75e4bb78b2b1b086934f2dbb2e39 Added NetworkDeleteChildAtOpration and Test diff -r 2520a5bd3dac -r 9ab7d515e076 src/alice/jungle/operations/NetworkDeleteChildAtOperation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/jungle/operations/NetworkDeleteChildAtOperation.java Tue Oct 15 14:26:25 2013 +0900 @@ -0,0 +1,58 @@ +package alice.jungle.operations; + +import java.nio.ByteBuffer; + +import org.msgpack.annotation.Message; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.DeleteChildAt; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; + +@Message +public class NetworkDeleteChildAtOperation implements NodeOperation +{ + //private final int pos; + /* MessagePack can not handle final.*/ + private int pos; + + + /* Position -1 represent root position. */ + public NetworkDeleteChildAtOperation(int _pos) + { + pos = _pos; + } + + @Override + public Command getCommand() + { + return Command.DELETE_CHILD; + } + + @Override + public > Either invoke(T _target) + { + DeleteChildAt deleteChildAt = new DeleteChildAt(pos); + return deleteChildAt.edit(_target); + } + + @Override + public int getPosition() + { + return pos; + } + + @Override + public String getKey() + { + return null; + } + + @Override + public ByteBuffer getValue() + { + return null; + } +} diff -r 2520a5bd3dac -r 9ab7d515e076 src/test/alice/jungle/core/operations/NetworkAppendChildOperationTest.java --- a/src/test/alice/jungle/core/operations/NetworkAppendChildOperationTest.java Tue Oct 15 09:13:18 2013 +0900 +++ b/src/test/alice/jungle/core/operations/NetworkAppendChildOperationTest.java Tue Oct 15 14:26:25 2013 +0900 @@ -15,6 +15,7 @@ MessagePack msgpack = new MessagePack(); Value v = msgpack.unconvert(op); NetworkAppendChildAtOperation mOp = msgpack.convert(v, NetworkAppendChildAtOperation.class); +// NodeOperation mOp = msgpack.convert(v, NodeOperation.class); assertEquals(op.getCommand(), mOp.getCommand()); assertEquals(op.getPosition(), 1); assertEquals(op.getPosition(), mOp.getPosition()); diff -r 2520a5bd3dac -r 9ab7d515e076 src/test/alice/jungle/core/operations/NetworkDeleteChildAtOperationTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/alice/jungle/core/operations/NetworkDeleteChildAtOperationTest.java Tue Oct 15 14:26:25 2013 +0900 @@ -0,0 +1,24 @@ +package test.alice.jungle.core.operations; + +import java.io.IOException; + +import org.msgpack.MessagePack; +import org.msgpack.type.Value; + +import alice.jungle.operations.NetworkDeleteChildAtOperation; +import junit.framework.TestCase; + +public class NetworkDeleteChildAtOperationTest extends TestCase { + + + public void testMsgpackConvert() throws IOException { + NetworkDeleteChildAtOperation op = new NetworkDeleteChildAtOperation(1); + MessagePack msgpack = new MessagePack(); + Value v = msgpack.unconvert(op); + NetworkDeleteChildAtOperation mOp = msgpack.convert(v, NetworkDeleteChildAtOperation.class); + assertEquals(op.getCommand(), mOp.getCommand()); + assertEquals(op.getPosition(), mOp.getPosition()); + + } + +}