Mercurial > hg > Database > jungle-network
changeset 72:2520a5bd3dac
Added NetworkDeleteAttributeOperation and NetworkDeleteAttributeOperationTest
author | one |
---|---|
date | Tue, 15 Oct 2013 09:13:18 +0900 |
parents | f1aef52c0611 |
children | 9ab7d515e076 |
files | src/alice/jungle/operations/NetworkDeleteAttributeOperation.java src/test/alice/jungle/core/operations/NetworkDeleteAttributeOprationTest.java |
diffstat | 2 files changed, 84 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/jungle/operations/NetworkDeleteAttributeOperation.java Tue Oct 15 09:13:18 2013 +0900 @@ -0,0 +1,60 @@ +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.DeleteAttribute; +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 NetworkDeleteAttributeOperation implements NodeOperation +{ + //private final String key; + private String key; + + public NetworkDeleteAttributeOperation() + { + key = null; + } + + public NetworkDeleteAttributeOperation(String _key) + { + key = _key; + } + + @Override + public Command getCommand() + { + return Command.DELETE_ATTRIBUTE; + } + + @Override + public <T extends EditableNode<T>> Either<Error, T> invoke(T _target) + { + DeleteAttribute deleteAttribute = new DeleteAttribute(key); + return deleteAttribute.edit(_target); + } + + @Override + public int getPosition() + { + return -1; + } + + @Override + public String getKey() + { + return key; + } + + @Override + public ByteBuffer getValue() + { + return null; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/alice/jungle/core/operations/NetworkDeleteAttributeOprationTest.java Tue Oct 15 09:13:18 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.NetworkDeleteAttributeOperation; +import junit.framework.TestCase; + +public class NetworkDeleteAttributeOprationTest extends TestCase { + + public void testMsgpackConvert() throws IOException { + NetworkDeleteAttributeOperation op = new NetworkDeleteAttributeOperation("hoge"); + MessagePack msgpack = new MessagePack(); + Value v = msgpack.unconvert(op); + NetworkDeleteAttributeOperation mOp = msgpack.convert(v, NetworkDeleteAttributeOperation.class); + assertEquals(op.getCommand(), mOp.getCommand()); + assertEquals(mOp.getKey(), "hoge"); + + } + + +}