Mercurial > hg > Members > tatsuki > bench > jungle-core
view src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/nodeeditor/EditableAttributesTest.java @ 81:715a9fbf02fc
remove <T> many source
author | one |
---|---|
date | Sun, 31 Aug 2014 07:46:30 +0900 |
parents | a833000f64bf |
children |
line wrap: on
line source
/*package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.nodeeditor; import java.nio.ByteBuffer; import org.junit.Assert; import fj.P; import fj.P2; import fj.data.List; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNodeAttributes; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableAttributes; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.NodeEditorError; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; import junit.framework.TestCase; public abstract class EditableAttributesTest<T extends TreeNode<T>> extends TestCase { public abstract TreeNodeAttributes<T> instance(); @SuppressWarnings("unchecked") public static final List<P2<String,ByteBuffer>> ENTRIES = List.list( P.p("KEY1",ByteBuffer.wrap("VALUE1".getBytes())), P.p("KEY2",ByteBuffer.wrap("VALUE2".getBytes())), P.p("KEY3",ByteBuffer.wrap("VALUE3".getBytes())) ); public TreeNodeAttributes<T> createTestData() { TreeNodeAttributes<T> instance = instance(); T node; TreeNodeAttributes<T> attr = instance; for(P2<String,ByteBuffer> entry : ENTRIES){ Either<Error,T> either = attr.put(entry._1(),entry._2()); if(either.isA()){ Assert.fail("error during creating the data."); } node = either.b(); attr = node.getAttributes(); } return attr; } public void testPutDoesNotAcceptNullValue() { TreeNodeAttributes<T> instance = instance(); Either<Error,T> either = instance.put("KEY",null); if(!either.isA()){ Assert.fail("put must returns NULL_VALUE_NOT_ALLOWED when the value was null."); } Assert.assertEquals(NodeEditorError.NULL_VALUE_NOT_ALLOWED,either.a()); either = instance.put(null,ByteBuffer.wrap("VALUE".getBytes())); if(!either.isA()){ Assert.fail("put must returns NULL_VALUE_NOT_ALLOWED when the key was null."); } Assert.assertEquals(NodeEditorError.NULL_VALUE_NOT_ALLOWED,either.a()); } public void testPut() { createTestData(); } public void testDeleteIfKeyExsist() { TreeNodeAttributes<T> attr = createTestData(); for(P2<String,ByteBuffer> entry : ENTRIES){ Either<Error,T> either = attr.delete(entry._1()); if(either.isA()){ Assert.fail("error during deleting exist key."); } attr = either.b().getAttributes(); } } public static final String DUMMY_KEY = "dummy"; public void testDeleteIfKeyNotExist() { TreeNodeAttributes<T> attr = createTestData(); Either<Error,T> either = attr.delete(DUMMY_KEY); if(!either.isA()){ Assert.fail("delete must returns DELETE_KEY_NOT_FOUND when the deleting invalid key."); } } } */