annotate src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultAttributesTest.java @ 81:715a9fbf02fc

remove <T> many source
author one
date Sun, 31 Aug 2014 07:46:30 +0900
parents 26dfa90016d1
children fb1dc448ac8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
1 package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.impl.node;
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
2
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
3 import java.nio.ByteBuffer;
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
4
39
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
5 import org.junit.Assert;
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
6
38
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
7 import fj.Ord;
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
8 import fj.P2;
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
9 import fj.data.List;
39
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
10 import fj.data.Option;
38
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
11 import fj.data.TreeMap;
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.AttributesTest;
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultAttributes;
81
715a9fbf02fc remove <T> many source
one
parents: 75
diff changeset
14 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
715a9fbf02fc remove <T> many source
one
parents: 75
diff changeset
15 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNodeAttributes;
75
26dfa90016d1 error delete but 2 test program commentout and not action BulletinBoard
one
parents: 39
diff changeset
16 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode;
26dfa90016d1 error delete but 2 test program commentout and not action BulletinBoard
one
parents: 39
diff changeset
17 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNodeAttribute;
38
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
18
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
19 public class DefaultAttributesTest extends AttributesTest
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
20 {
81
715a9fbf02fc remove <T> many source
one
parents: 75
diff changeset
21 public TreeNodeAttributes<TreeNode> instance()
38
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
22 {
81
715a9fbf02fc remove <T> many source
one
parents: 75
diff changeset
23 List<TreeNode> rawList = List.nil();
38
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
24 TreeMap<String,ByteBuffer> rawMap = TreeMap.empty(Ord.stringOrd);
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
25
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
26 // add attributes
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
27
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
28 for(P2<String, ByteBuffer> entry : ENTRIES){
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
29 rawMap = rawMap.set(entry._1(),entry._2());
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
30 }
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
31
81
715a9fbf02fc remove <T> many source
one
parents: 75
diff changeset
32 TreeNode node = new DefaultTreeNode(rawList,rawMap);
38
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
33 return node.getAttributes();
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
34 }
39
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
35
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
36 public void testGetAttributesAsRawMap()
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
37 {
81
715a9fbf02fc remove <T> many source
one
parents: 75
diff changeset
38 TreeNodeAttributes<TreeNode> attrs = instance();
39
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
39 TreeMap<String,ByteBuffer> rawMap = attrs.getAttributesAsRawMap();
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
40
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
41 // testing rawmap is not null.
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
42 Assert.assertNotNull(rawMap);
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
43
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
44 // testing rawmap has correct key values.
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
45 for(P2<String,ByteBuffer> entry : ENTRIES){
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
46 String key = entry._1();
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
47 ByteBuffer value = entry._2();
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
48
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
49 Option<ByteBuffer> option = rawMap.get(key);
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
50 if(option.isNone()){
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
51 Assert.fail();
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
52 }
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
53
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
54 ByteBuffer actual = option.some();
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
55 Assert.assertEquals(0,actual.compareTo(value));
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
56 }
7d78bbf4a9cd added some tests
Shoshi TAMAKI
parents: 38
diff changeset
57 }
38
cb9fabaedfd4 added tests and changed testing provider to junit47
Shoshi TAMAKI
parents:
diff changeset
58 }