/
Setup.java
2124 lines (1919 loc) · 99 KB
/
Setup.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Personium
* Copyright 2014-2022 Personium Project Authors
* - FUJITSU LIMITED
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.personium.test.setup;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.io.StringReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import javax.ws.rs.core.MediaType;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpStatus;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.odata4j.edm.EdmSimpleType;
import io.personium.common.utils.CommonUtils;
import io.personium.core.PersoniumUnitConfig;
import io.personium.core.auth.OAuth2Helper;
import io.personium.core.model.Box;
import io.personium.core.model.Cell;
import io.personium.core.model.ctl.Relation;
import io.personium.core.model.ctl.Role;
import io.personium.core.model.lock.LockManager;
import io.personium.core.rs.PersoniumCoreApplication;
import io.personium.test.jersey.AbstractCase;
import io.personium.test.jersey.ODataCommon;
import io.personium.test.jersey.PersoniumIntegTestRunner;
import io.personium.test.jersey.PersoniumRequest;
import io.personium.test.jersey.PersoniumResponse;
import io.personium.test.jersey.PersoniumRestAdapter;
import io.personium.test.jersey.box.odatacol.UserDataListWithNPTest;
import io.personium.test.jersey.box.odatacol.schema.property.PropertyUtils;
import io.personium.test.utils.AccountUtils;
import io.personium.test.utils.AssociationEndUtils;
import io.personium.test.utils.BoxUtils;
import io.personium.test.utils.CellUtils;
import io.personium.test.utils.DavResourceUtils;
import io.personium.test.utils.EntityTypeUtils;
import io.personium.test.utils.ExtRoleUtils;
import io.personium.test.utils.Http;
import io.personium.test.utils.LinksUtils;
import io.personium.test.utils.RelationUtils;
import io.personium.test.utils.RoleUtils;
import io.personium.test.utils.RuleUtils;
import io.personium.test.utils.TResponse;
import io.personium.test.utils.UrlUtils;
import io.personium.test.utils.UserDataUtils;
/**
* テスト環境の構築.
*/
@RunWith(PersoniumIntegTestRunner.class)
public class Setup extends AbstractCase {
/** 作成するテスト環境情報を格納する。複数のセル環境を作ることを想定しているためListで用意. */
List<Config> confs = new ArrayList<Config>();
List<Config> eventLogConfs = new ArrayList<Config>();
static final int NUM_ACCOUNTS = 32;
static final int NUM_APP_AUTH_ACCOUNTS = 2;
static final int NUM_ROLES = NUM_ACCOUNTS;
static final int NUM_USERDATA = 10;
/** テストセル1の名前. */
public static final String TEST_CELL1 = "testcell1";
/** テストセル2の名前. */
public static final String TEST_CELL2 = "testcell2";
/** テストSchemaセル1の名前. */
public static final String TEST_CELL_SCHEMA1 = "schema1";
/** テストSchemaセル2の名前. */
public static final String TEST_CELL_SCHEMA2 = "schema2";
/** EventLog用テストセルの名前. */
public static final String TEST_CELL_EVENTLOG = "eventlogtestcell";
/** Basic認証用のテストセルの名前. */
public static final String TEST_CELL_BASIC = "basictestsetupcell";
/** OpenID Connect認証用のテストセルの名前. */
public static final String TEST_CELL_OIDC = "oidctestsetupcell";
/** $filterテスト用セル名. */
public static final String TEST_CELL_FILTER = "filtertypevalidatetest";
/** テストセル1>テストボックス1の名前. */
public static final String TEST_BOX1 = "box1";
/** テストセル1>テストボックス1の名前. */
public static final String TEST_BOX2 = "box2";
/** EngineServiceCollection Name. */
public static final String TEST_ENGINE_SERVICE = "service_relay";
/** テストセル1>テストボックス1>Odataコレクションの名前. */
public static final String TEST_ODATA = "setodata";
/** テストセル1>テストボックス1>検索テスト用Odataコレクションの名前. */
public static final String SEARCH_ODATA = "searchodata";
/** テストセル1>テストボックス1>検索テスト用Odataコレクション内のEntityType一覧. */
public static final String[] SEARCH_ENTITY_TYPES = new String[] {"string", "stringList", "int", "intList",
"single", "singleList", "boolean", "booleanList", "datetime" };
/** テストセル1>テストボックス1>Odataコレクション>EntityTypeの名前. */
public static final String TEST_ENTITYTYPE_M1 = "entityMulti_1";
/** テストセル1>テストボックス1>Odataコレクション>EntityTypeの名前. */
public static final String TEST_ENTITYTYPE_MN = "entityMulti_N";
/** テストセル1>テストボックス1>Odataコレクション>EntityTypeの名前. */
public static final String TEST_ENTITYTYPE_MDP = "entityMaxDynamicProp";
/** セル同士の関係名. */
public static final String CELL_RELATION = "cellrelation";
/** VETオーナー. */
public static final String OWNER_VET = "https://example.com/test#vet";
/** HMCオーナー. */
public static final String OWNER_HMC = "https://example.com/test#hmc";
/** EVTオーナー. */
// eventLogTestCell 用のオーナー
public static final String OWNER_EVT = "https://example.com/test#evt";
static final double DECIMAL = 0.1;
static final String TEST_RULE_NAME = "rule1";
static final long WAIT_TIME_FOR_EVENT = 3000; // msec
static final long WAIT_TIME_FOR_BULK_DELETE = 1000L;
/**
* コンストラクタ. テスト対象のパッケージをsuperに渡す必要がある
*/
public Setup() {
super(new PersoniumCoreApplication());
// アカウント生成
List<AccountConfig> accounts = new ArrayList<AccountConfig>();
for (int i = 0; i < NUM_ACCOUNTS; i++) {
AccountConfig account = new AccountConfig();
account.accountName = "account" + i;
account.accountPass = "password" + i;
accounts.add(account);
}
// BOX2個 1つ目にはサービス・Odata・WebDAVコレクションを作成
BoxConfig box1 = new BoxConfig();
box1.boxName = "box1";
box1.boxSchema = UrlUtils.cellRoot("schema1");
SvcCollectionConfig svcColl = new SvcCollectionConfig();
OdataSvcCollectionConfig odataColl = new OdataSvcCollectionConfig();
DavSvcCollectionConfig davColl = new DavSvcCollectionConfig();
box1.davCol.add(davColl);
box1.odataCol.add(odataColl);
box1.svcCol.add(svcColl);
svcColl.patch = new ProppatchConfig();
// box2つ目
BoxConfig box2 = new BoxConfig();
box2.boxName = "box2";
box2.boxSchema = null;
Config conf1 = new Config();
conf1.cellName = "testcell1";
conf1.owner = OWNER_VET;
conf1.account = accounts;
conf1.extRole = settingExtRole(TEST_CELL2);
conf1.role = settingRole(conf1.account, conf1.extRole);
conf1.rule = settingRule();
conf1.box.add(box1);
conf1.box.add(box2);
confs.add(conf1);
Config conf2 = new Config();
conf2.cellName = "testcell2";
conf2.owner = OWNER_HMC;
conf2.account = accounts;
conf2.extRole = settingExtRole(TEST_CELL1);
conf2.role = settingRole(conf2.account, conf2.extRole);
conf2.box.add(box1);
conf2.box.add(box2);
confs.add(conf2);
// ExtCellの登録
conf1.extCellUrl.add(UrlUtils.cellRoot(TEST_CELL2));
conf2.extCellUrl.add(UrlUtils.cellRoot(TEST_CELL1));
// 関係
RelationConfig relation1 = new RelationConfig();
relation1.name = CELL_RELATION;
relation1.boxName = null;
relation1.linkExtCell.add(UrlUtils.cellRoot(conf2.cellName));
conf1.relation.add(relation1);
RelationConfig relation2 = new RelationConfig();
relation2.name = CELL_RELATION;
relation2.boxName = null;
relation2.linkExtCell.add(UrlUtils.cellRoot(conf1.cellName));
conf2.relation.add(relation2);
// アプリ認証セルアカウント2件
List<AccountConfig> appAuthAccounts = new ArrayList<AccountConfig>();
for (int i = 0; i < NUM_APP_AUTH_ACCOUNTS; i++) {
AccountConfig account = new AccountConfig();
account.accountName = "account" + i;
account.accountPass = "password" + i;
appAuthAccounts.add(account);
}
// アプリ認証セル1
Config appAuthConf1 = new Config();
appAuthConf1.cellName = TEST_CELL_SCHEMA1;
appAuthConf1.owner = OWNER_VET;
appAuthConf1.account = appAuthAccounts;
confs.add(appAuthConf1);
// アプリ認証セルのアカウントにconfidentialRole結びつけ(account1 が confidentialRoleを持つ)
RoleConfig role = new RoleConfig();
role.roleName = OAuth2Helper.Key.CONFIDENTIAL_ROLE_NAME;
appAuthConf1.role.add(role);
role.linkAccounts.add(appAuthAccounts.get(1));
// アプリ認証セル2
Config appAuthConf2 = new Config();
appAuthConf2.cellName = TEST_CELL_SCHEMA2;
appAuthConf2.owner = OWNER_HMC;
appAuthConf2.account = appAuthAccounts;
confs.add(appAuthConf2);
// $filterテスト用セル(他のテストに影響がでるので匿名ユーザに作成)
Config filterConf = new Config();
filterConf.cellName = TEST_CELL_FILTER;
filterConf.owner = null;
confs.add(filterConf);
// EventLog用セル(セル名のみ)
Config eventLogConf = new Config();
eventLogConf.cellName = TEST_CELL_EVENTLOG;
eventLogConf.owner = OWNER_EVT;
eventLogConf.rule = settingRule();
eventLogConfs.add(eventLogConf);
// Basic認証テスト用のセル
BoxConfig basicTestBox = new BoxConfig();
basicTestBox.boxName = "box1";
basicTestBox.boxSchema = null;
svcColl = new SvcCollectionConfig();
odataColl = new OdataSvcCollectionConfig();
davColl = new DavSvcCollectionConfig();
basicTestBox.davCol.add(davColl);
basicTestBox.odataCol.add(odataColl);
basicTestBox.svcCol.add(svcColl);
svcColl.patch = new ProppatchConfig();
Config basicTestCellConf = new Config();
basicTestCellConf.cellName = TEST_CELL_BASIC;
basicTestCellConf.owner = null;
basicTestCellConf.account = accounts;
basicTestCellConf.extRole = new ArrayList<ExtRoleConfig>();
basicTestCellConf.role = settingRole(basicTestCellConf.account, basicTestCellConf.extRole);
basicTestCellConf.box.add(basicTestBox);
confs.add(basicTestCellConf);
// TODO OIDC用のTestCell作成
// IDToken取得機構を作るときに対応予定
}
/**
* テスト環境構築. テストで共通で使用するセル等を作成する。すでに環境があったら削除してから作成するので環境をリセットするときにも利用する。
* 単独でJUnitのテストとして起動して使ってください。
*/
@Test
public void reset() {
LockManager.deleteAllLocks();
for (Config conf : confs) {
this.delete(conf);
this.create(conf);
}
}
/**
* EventLog用テスト環境を構築する.
* @throws InterruptedException InterruptedException
*/
@Test
public void resetEventLog() throws InterruptedException {
LockManager.deleteAllLocks();
for (Config conf : eventLogConfs) {
this.delete(conf);
this.createCell(conf);
for (RuleConfig rule : conf.rule) {
RuleUtils.create(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, rule.toJson(), HttpStatus.SC_CREATED);
}
Thread.sleep(WAIT_TIME_FOR_EVENT);
this.createEventLog(conf);
Thread.sleep(WAIT_TIME_FOR_EVENT);
}
}
/**
* テスト環境削除. テストで共通で使用するセル等を削除する。 単独でJUnitのテストとして起動して使ってください。
*/
@Test
public void destroy() {
for (Config conf : confs) {
this.delete(conf);
}
}
/**
* Roleの設定を行う.
* @param ExtRoleConfig
* ExtRoleの設定
*/
private List<RoleConfig> settingRole(List<AccountConfig> accounts, List<ExtRoleConfig> extRoles) {
List<RoleConfig> roles = new ArrayList<RoleConfig>();
for (int i = 0; i < NUM_ROLES; i++) {
// ロール作成
RoleConfig role = new RoleConfig();
role.roleName = "role" + i;
role.linkAccounts.add(accounts.get(i));
if (extRoles != null && extRoles.size() > 0) {
role.linkExtRole.add(extRoles.get(i));
}
roles.add(role);
}
return roles;
}
/**
* ExtRoleの設定を行う.
* @param extCell
* ExtRoleの向け先のCellURL
*/
private List<ExtRoleConfig> settingExtRole(String extCell) {
List<ExtRoleConfig> extRoles = new ArrayList<ExtRoleConfig>();
for (int i = 0; i < NUM_ROLES; i++) {
// ExtRole作成
ExtRoleConfig extRole = new ExtRoleConfig();
extRole.extRole = UrlUtils.roleResource(extCell, Box.MAIN_BOX_NAME, "role" + i);
extRole.relationName = CELL_RELATION;
extRole.relationBoxName = null;
extRoles.add(extRole);
}
return extRoles;
}
private List<RuleConfig> settingRule() {
List<RuleConfig> rules = new ArrayList<RuleConfig>();
RuleConfig rule = new RuleConfig();
rule.name = TEST_RULE_NAME;
rule.external = true;
rule.action = "log";
rules.add(rule);
return rules;
}
/**
* テスト環境構築.
* @param conf
* 設定情報
*/
private void create(Config conf) {
// Cell作成
createCell(conf);
// ExtCell作成
createExtCell(conf);
// Relation作成
for (RelationConfig relation : conf.relation) {
RelationUtils.create(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, relation.toJson(),
HttpStatus.SC_CREATED);
// RelationとExtCellの$link
for (String extCell : relation.linkExtCell) {
LinksUtils.createLinksExtCell(conf.cellName, CommonUtils.encodeUrlComp(extCell),
Relation.EDM_TYPE_NAME, relation.name, null,
AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_NO_CONTENT);
}
}
// アカウント作成
for (AccountConfig account : conf.account) {
this.createAccount(conf.cellName, account.accountName, account.accountPass);
}
// ExtRole作成
for (ExtRoleConfig extRole : conf.extRole) {
ExtRoleUtils.create(AbstractCase.MASTER_TOKEN_NAME, conf.cellName, extRole.toJson(), HttpStatus.SC_CREATED);
}
// Role作成
for (RoleConfig role : conf.role) {
TResponse res = createRole(conf.cellName, role.roleName);
String roleUrl = res.getLocationHeader();
// Role紐付け作成
if (role.linkAccounts != null) {
for (AccountConfig account : role.linkAccounts) {
this.linkAccountAndRole(conf.cellName, account.accountName, roleUrl);
}
}
// ExtRoleとRoleの紐付け
if (role.linkExtRole != null) {
for (ExtRoleConfig extRole : role.linkExtRole) {
LinksUtils.createLinksExtRole(conf.cellName, CommonUtils.encodeUrlComp(extRole.extRole),
extRole.relationName, extRole.relationBoxName, Role.EDM_TYPE_NAME, role.roleName, null,
AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_NO_CONTENT);
}
}
if ("testcell2".equals(conf.cellName)) {
// ExtCellとロールの結びつけ
// testcell2のtestxell1向けのExtCellにrole2(readができるロール)を結びつけてやる
this.linkExtCelltoRole(CommonUtils.encodeUrlComp(UrlUtils.cellRoot("testcell1")), conf.cellName,
roleUrl);
}
}
// Box作成
for (BoxConfig box : conf.box) {
this.createBox(conf.cellName, box.boxName, box.boxSchema);
// box1にのみACL設定
if ("box1".equals(box.boxName)) {
// BoxレベルACLテスト用
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, "",
"box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
}
}
// Rule
for (RuleConfig rule : conf.rule) {
RuleUtils.create(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, rule.toJson(), HttpStatus.SC_CREATED);
}
if ("testcell1".equals(conf.cellName) || "testcell2".equals(conf.cellName)) {
createServiceCollection(conf.cellName, TEST_BOX1, "setservice");
createOdataCollection(conf.cellName, TEST_BOX1, TEST_ODATA);
createOdataCollection(conf.cellName, TEST_BOX1, SEARCH_ODATA);
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, TEST_ODATA,
"box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
createWebdavCollection(conf.cellName, TEST_BOX1, "setdavcol");
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, "setdavcol",
"box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
this.createPatch2("setservice", conf.cellName);
createServiceCollection(conf.cellName, TEST_BOX1, TEST_ENGINE_SERVICE);
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK,
TEST_ENGINE_SERVICE, "box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
// テストコレクションのエンティティ作成
createTestCollectionSchema(conf.cellName);
createMaxPropTestCollectionSchema(conf.cellName);
createTestCollectionSchemaToSearchOdata(conf.cellName);
// コレクションへのリソースPUT
this.resourcesPut("setdavcol/dav.txt", conf.cellName);
// ユーザーデータの登録
createUserDatas(conf.cellName);
createUserDatasToSearchOdata(conf.cellName);
// NPテスト用のODATACollectionを作成する
createNPTestCollectionSchema(conf);
// ComplexType NPテスト用のスキーマを作成する
createComplexTypeNPSchema(conf);
}
if (TEST_CELL_BASIC.equals(conf.cellName)) {
createServiceCollection(conf.cellName, TEST_BOX1, "setservice");
createOdataCollection(conf.cellName, TEST_BOX1, TEST_ODATA);
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, TEST_ODATA,
"box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
createWebdavCollection(conf.cellName, TEST_BOX1, "setdavcol");
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, "setdavcol",
"box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
this.createPatch2("setservice", conf.cellName);
createServiceCollection(conf.cellName, TEST_BOX1, TEST_ENGINE_SERVICE);
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK,
TEST_ENGINE_SERVICE, "box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
// テストコレクションのエンティティ作成
createTestCollectionSchema(conf.cellName);
// コレクションへのリソースPUT
this.resourcesPut("setdavcol/dav.txt", conf.cellName);
}
// アカウントの一覧取得用のベースデータを作成する
createAccountforList(conf.cellName);
// $filterテスト用のデータ作成
setupFilterTestCell(conf);
}
/**
* 最大プロパティ数テストコレクションの作成.
* @param cellName
* セル名
*/
public static void createMaxPropTestCollectionSchema(String cellName) {
// EntityTypeを登録
entityTypePost(TEST_ODATA, TEST_BOX1, TEST_ENTITYTYPE_M1, cellName);
entityTypePost(TEST_ODATA, TEST_BOX1, TEST_ENTITYTYPE_MN, cellName);
entityTypePost(TEST_ODATA, TEST_BOX1, TEST_ENTITYTYPE_MDP, cellName);
// AssociationEndのlink作成
associationEndPost(TEST_ODATA, TEST_ENTITYTYPE_M1, "Multi_1_to_MaxDynamicProp", "0..1", cellName);
associationEndPost(TEST_ODATA, TEST_ENTITYTYPE_MN, "Multi_N_to_MaxDynamicProp", "\\*", cellName);
associationEndPost(TEST_ODATA, TEST_ENTITYTYPE_MDP, "MaxDynamicProp_to_Multi_1", "\\*", cellName);
associationEndPost(TEST_ODATA, TEST_ENTITYTYPE_MDP, "MaxDynamicProp_to_Multi_N", "\\*", cellName);
createAssociationEndLink(TEST_ODATA, new String[] {TEST_ENTITYTYPE_M1, TEST_ENTITYTYPE_MDP},
new String[] {"Multi_1_to_MaxDynamicProp", "MaxDynamicProp_to_Multi_1"}, cellName);
createAssociationEndLink(TEST_ODATA, new String[] {TEST_ENTITYTYPE_MN, TEST_ENTITYTYPE_MDP},
new String[] {"Multi_N_to_MaxDynamicProp", "MaxDynamicProp_to_Multi_N"}, cellName);
}
/**
* テストコレクションの作成.
* @param cellName
* セル名
*/
public static void createTestCollectionSchema(String cellName) {
// EntityTypeを登録
entityTypePost(TEST_ODATA, TEST_BOX1, "Sales", cellName);
entityTypePost(TEST_ODATA, TEST_BOX1, "SalesDetail", cellName);
entityTypePost(TEST_ODATA, TEST_BOX1, "Product", cellName);
entityTypePost(TEST_ODATA, TEST_BOX1, "Category", cellName);
entityTypePost(TEST_ODATA, TEST_BOX1, "Supplier", cellName);
entityTypePost(TEST_ODATA, TEST_BOX1, "Price", cellName);
// AssociationEndを登録
associationEndPost(TEST_ODATA, "Sales", "sales2salesDetail", "1", cellName);
associationEndPost(TEST_ODATA, "SalesDetail", "salesDetail2sales", "\\*", cellName);
associationEndPost(TEST_ODATA, "Product", "product2Sales", "\\*", cellName);
associationEndPost(TEST_ODATA, "Sales", "sales2product", "\\*", cellName);
associationEndPost(TEST_ODATA, "Product", "product2category", "1", cellName);
associationEndPost(TEST_ODATA, "Category", "category2product", "1", cellName);
associationEndPost(TEST_ODATA, "Supplier", "supplier2product", "0..1", cellName);
associationEndPost(TEST_ODATA, "Product", "product2supplier", "1", cellName);
associationEndPost(TEST_ODATA, "Sales", "sales2supplier", "0..1", cellName);
associationEndPost(TEST_ODATA, "Supplier", "supplier2sales", "\\*", cellName);
associationEndPost(TEST_ODATA, "Price", "price2sales", "0..1", cellName);
associationEndPost(TEST_ODATA, "Sales", "sales2price", "0..1", cellName);
createAssociationEndLink(TEST_ODATA, new String[] {"SalesDetail", "Sales" },
new String[] {"salesDetail2sales", "sales2salesDetail" }, cellName);
createAssociationEndLink(TEST_ODATA, new String[] {"Product", "Sales" },
new String[] {"product2Sales", "sales2product" }, cellName);
createAssociationEndLink(TEST_ODATA, new String[] {"Supplier", "Product" },
new String[] {"supplier2product", "product2supplier" }, cellName);
createAssociationEndLink(TEST_ODATA, new String[] {"Sales", "Supplier" },
new String[] {"sales2supplier", "supplier2sales" }, cellName);
createAssociationEndLink(TEST_ODATA, new String[] {"Price", "Sales" },
new String[] {"price2sales", "sales2price" }, cellName);
}
/**
* テストコレクションの作成.
* @param cellName
* セル名
*/
public static void createTestCollectionSchemaToSearchOdata(String cellName) {
// EntityTypeを登録
for (String entityType : SEARCH_ENTITY_TYPES) {
entityTypePost(SEARCH_ODATA, TEST_BOX1, entityType, cellName);
}
entityTypePost(SEARCH_ODATA, TEST_BOX1, "dynamic", cellName);
// Propertyを登録
final int count = 5;
for (int i = 0; i < count; i++) {
UserDataUtils.createProperty(cellName, TEST_BOX1, SEARCH_ODATA, "property" + i, "string",
EdmSimpleType.STRING.getFullyQualifiedTypeName(), true, null, null, false, null);
UserDataUtils.createProperty(cellName, TEST_BOX1, SEARCH_ODATA, "property" + i, "stringList",
EdmSimpleType.STRING.getFullyQualifiedTypeName(), true, null, "List", false, null);
UserDataUtils.createProperty(cellName, TEST_BOX1, SEARCH_ODATA, "property" + i, "int",
EdmSimpleType.INT32.getFullyQualifiedTypeName(), true, null, null, false, null);
UserDataUtils.createProperty(cellName, TEST_BOX1, SEARCH_ODATA, "property" + i, "intList",
EdmSimpleType.INT32.getFullyQualifiedTypeName(), true, null, "List", false, null);
UserDataUtils.createProperty(cellName, TEST_BOX1, SEARCH_ODATA, "property" + i, "single",
EdmSimpleType.SINGLE.getFullyQualifiedTypeName(), true, null, null, false, null);
UserDataUtils.createProperty(cellName, TEST_BOX1, SEARCH_ODATA, "property" + i, "singleList",
EdmSimpleType.SINGLE.getFullyQualifiedTypeName(), true, null, "List", false, null);
UserDataUtils.createProperty(cellName, TEST_BOX1, SEARCH_ODATA, "property" + i, "boolean",
EdmSimpleType.BOOLEAN.getFullyQualifiedTypeName(), true, null, null, false, null);
UserDataUtils.createProperty(cellName, TEST_BOX1, SEARCH_ODATA, "property" + i, "booleanList",
EdmSimpleType.BOOLEAN.getFullyQualifiedTypeName(), true, null, "List", false, null);
UserDataUtils.createProperty(cellName, TEST_BOX1, SEARCH_ODATA, "property" + i, "datetime",
EdmSimpleType.DATETIME.getFullyQualifiedTypeName(), true, null, null, false, null);
}
}
/**
* 以下のようなODataスキーマを作成. A(0..1) - B(0..1) | C(1) - A(0..1) | D(*) - A(0..1)
* A(0..1) - C(1) | B(1) - C(1) | D(*) - B(1) A(0..1) - D(*) | B(1) - D(*) |
* C(*) - D(*)
* @param conf
* 設定ファイル
*/
public void createNPTestCollectionSchema(Config conf) {
createOdataCollection(conf.cellName, TEST_BOX1, UserDataListWithNPTest.ODATA_COLLECTION);
// EntitySetを登録する
entityTypePost(UserDataListWithNPTest.ODATA_COLLECTION, TEST_BOX1, UserDataListWithNPTest.ENTITY_TYPE_A,
conf.cellName);
entityTypePost(UserDataListWithNPTest.ODATA_COLLECTION, TEST_BOX1, UserDataListWithNPTest.ENTITY_TYPE_B,
conf.cellName);
entityTypePost(UserDataListWithNPTest.ODATA_COLLECTION, TEST_BOX1, UserDataListWithNPTest.ENTITY_TYPE_C,
conf.cellName);
entityTypePost(UserDataListWithNPTest.ODATA_COLLECTION, TEST_BOX1, UserDataListWithNPTest.ENTITY_TYPE_D,
conf.cellName);
// AssociationEndを登録する
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.ENTITY_TYPE_A,
UserDataListWithNPTest.ASSOC_AB_A, UserDataListWithNPTest.MULTI_ZERO_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.ENTITY_TYPE_A,
UserDataListWithNPTest.ASSOC_AC_A, UserDataListWithNPTest.MULTI_ZERO_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.ENTITY_TYPE_A,
UserDataListWithNPTest.ASSOC_AD_A, UserDataListWithNPTest.MULTI_ZERO_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.ENTITY_TYPE_B,
UserDataListWithNPTest.ASSOC_AB_B, UserDataListWithNPTest.MULTI_ZERO_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.ENTITY_TYPE_C,
UserDataListWithNPTest.ASSOC_AC_C, UserDataListWithNPTest.MULTI_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.ENTITY_TYPE_D,
UserDataListWithNPTest.ASSOC_AD_D, UserDataListWithNPTest.MULTI_AST, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.ENTITY_TYPE_B,
UserDataListWithNPTest.ASSOC_BC_B, UserDataListWithNPTest.MULTI_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.ENTITY_TYPE_C,
UserDataListWithNPTest.ASSOC_BC_C, UserDataListWithNPTest.MULTI_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.ENTITY_TYPE_B,
UserDataListWithNPTest.ASSOC_BD_B, UserDataListWithNPTest.MULTI_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.ENTITY_TYPE_D,
UserDataListWithNPTest.ASSOC_BD_D, UserDataListWithNPTest.MULTI_AST, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.ENTITY_TYPE_C,
UserDataListWithNPTest.ASSOC_CD_C, UserDataListWithNPTest.MULTI_AST, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.ENTITY_TYPE_D,
UserDataListWithNPTest.ASSOC_CD_D, UserDataListWithNPTest.MULTI_AST, conf.cellName);
// AssociationEndの関係を結ぶ
createAssociationEndLink(UserDataListWithNPTest.ODATA_COLLECTION,
new String[] {UserDataListWithNPTest.ENTITY_TYPE_A, UserDataListWithNPTest.ENTITY_TYPE_B },
new String[] {UserDataListWithNPTest.ASSOC_AB_A, UserDataListWithNPTest.ASSOC_AB_B }, conf.cellName);
createAssociationEndLink(UserDataListWithNPTest.ODATA_COLLECTION,
new String[] {UserDataListWithNPTest.ENTITY_TYPE_A, UserDataListWithNPTest.ENTITY_TYPE_C },
new String[] {UserDataListWithNPTest.ASSOC_AC_A, UserDataListWithNPTest.ASSOC_AC_C }, conf.cellName);
createAssociationEndLink(UserDataListWithNPTest.ODATA_COLLECTION,
new String[] {UserDataListWithNPTest.ENTITY_TYPE_A, UserDataListWithNPTest.ENTITY_TYPE_D },
new String[] {UserDataListWithNPTest.ASSOC_AD_A, UserDataListWithNPTest.ASSOC_AD_D }, conf.cellName);
createAssociationEndLink(UserDataListWithNPTest.ODATA_COLLECTION,
new String[] {UserDataListWithNPTest.ENTITY_TYPE_B, UserDataListWithNPTest.ENTITY_TYPE_C },
new String[] {UserDataListWithNPTest.ASSOC_BC_B, UserDataListWithNPTest.ASSOC_BC_C }, conf.cellName);
createAssociationEndLink(UserDataListWithNPTest.ODATA_COLLECTION,
new String[] {UserDataListWithNPTest.ENTITY_TYPE_B, UserDataListWithNPTest.ENTITY_TYPE_D },
new String[] {UserDataListWithNPTest.ASSOC_BD_B, UserDataListWithNPTest.ASSOC_BD_D }, conf.cellName);
createAssociationEndLink(UserDataListWithNPTest.ODATA_COLLECTION,
new String[] {UserDataListWithNPTest.ENTITY_TYPE_C, UserDataListWithNPTest.ENTITY_TYPE_D },
new String[] {UserDataListWithNPTest.ASSOC_CD_C, UserDataListWithNPTest.ASSOC_CD_D }, conf.cellName);
}
/**
* 以下のようなODataスキーマを作成. A(0..1) - B(0..1) | C(1) - A(0..1) | D(*) - A(0..1)
* A(0..1) - C(1) | B(1) - C(1) | D(*) - B(1) A(0..1) - D(*) | B(1) - D(*) |
* C(*) - D(*)
* @param conf
* 設定ファイル
*/
public static void createComplexTypeNPSchema(Config conf) {
// ComplexTypeスキーマを登録する
createComplexTypeSchema(conf, UserDataListWithNPTest.CT_ENTITY_TYPE_A, "complexType1stA", "etStrProp",
"etComplexProp", "ct1stStrProp");
createComplexTypeSchema(conf, UserDataListWithNPTest.CT_ENTITY_TYPE_B, "complexType1stB", "etStrProp",
"etComplexProp", "ct1stStrProp");
createComplexTypeSchema(conf, UserDataListWithNPTest.CT_ENTITY_TYPE_C, "complexType1stC", "etStrProp",
"etComplexProp", "ct1stStrProp");
createComplexTypeSchema(conf, UserDataListWithNPTest.CT_ENTITY_TYPE_D, "complexType1stD", "etStrProp",
"etComplexProp", "ct1stStrProp");
// AssociationEndを登録する
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.CT_ENTITY_TYPE_A,
UserDataListWithNPTest.ASSOC_AB_A, UserDataListWithNPTest.MULTI_ZERO_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.CT_ENTITY_TYPE_A,
UserDataListWithNPTest.ASSOC_AC_A, UserDataListWithNPTest.MULTI_ZERO_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.CT_ENTITY_TYPE_A,
UserDataListWithNPTest.ASSOC_AD_A, UserDataListWithNPTest.MULTI_ZERO_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.CT_ENTITY_TYPE_B,
UserDataListWithNPTest.ASSOC_AB_B, UserDataListWithNPTest.MULTI_ZERO_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.CT_ENTITY_TYPE_C,
UserDataListWithNPTest.ASSOC_AC_C, UserDataListWithNPTest.MULTI_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.CT_ENTITY_TYPE_D,
UserDataListWithNPTest.ASSOC_AD_D, UserDataListWithNPTest.MULTI_AST, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.CT_ENTITY_TYPE_B,
UserDataListWithNPTest.ASSOC_BC_B, UserDataListWithNPTest.MULTI_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.CT_ENTITY_TYPE_C,
UserDataListWithNPTest.ASSOC_BC_C, UserDataListWithNPTest.MULTI_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.CT_ENTITY_TYPE_B,
UserDataListWithNPTest.ASSOC_BD_B, UserDataListWithNPTest.MULTI_ONE, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.CT_ENTITY_TYPE_D,
UserDataListWithNPTest.ASSOC_BD_D, UserDataListWithNPTest.MULTI_AST, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.CT_ENTITY_TYPE_C,
UserDataListWithNPTest.ASSOC_CD_C, UserDataListWithNPTest.MULTI_AST, conf.cellName);
associationEndPost(UserDataListWithNPTest.ODATA_COLLECTION, UserDataListWithNPTest.CT_ENTITY_TYPE_D,
UserDataListWithNPTest.ASSOC_CD_D, UserDataListWithNPTest.MULTI_AST, conf.cellName);
// AssociationEndの関係を結ぶ
createAssociationEndLink(UserDataListWithNPTest.ODATA_COLLECTION,
new String[] {UserDataListWithNPTest.CT_ENTITY_TYPE_A, UserDataListWithNPTest.CT_ENTITY_TYPE_B },
new String[] {UserDataListWithNPTest.ASSOC_AB_A, UserDataListWithNPTest.ASSOC_AB_B }, conf.cellName);
createAssociationEndLink(UserDataListWithNPTest.ODATA_COLLECTION,
new String[] {UserDataListWithNPTest.CT_ENTITY_TYPE_A, UserDataListWithNPTest.CT_ENTITY_TYPE_C },
new String[] {UserDataListWithNPTest.ASSOC_AC_A, UserDataListWithNPTest.ASSOC_AC_C }, conf.cellName);
createAssociationEndLink(UserDataListWithNPTest.ODATA_COLLECTION,
new String[] {UserDataListWithNPTest.CT_ENTITY_TYPE_A, UserDataListWithNPTest.CT_ENTITY_TYPE_D },
new String[] {UserDataListWithNPTest.ASSOC_AD_A, UserDataListWithNPTest.ASSOC_AD_D }, conf.cellName);
createAssociationEndLink(UserDataListWithNPTest.ODATA_COLLECTION,
new String[] {UserDataListWithNPTest.CT_ENTITY_TYPE_B, UserDataListWithNPTest.CT_ENTITY_TYPE_D },
new String[] {UserDataListWithNPTest.ASSOC_BD_B, UserDataListWithNPTest.ASSOC_BD_D }, conf.cellName);
createAssociationEndLink(UserDataListWithNPTest.ODATA_COLLECTION,
new String[] {UserDataListWithNPTest.CT_ENTITY_TYPE_C, UserDataListWithNPTest.CT_ENTITY_TYPE_D },
new String[] {UserDataListWithNPTest.ASSOC_CD_C, UserDataListWithNPTest.ASSOC_CD_D }, conf.cellName);
}
/**
* 指定したCellにユーザーデータを作成する.
* @param cellName
* セル名
*/
@SuppressWarnings("unchecked")
public static void createUserDatas(String cellName) {
JSONObject body;
String userDataId;
// ユーザーデータの登録(10個)
for (int i = 0; i < NUM_USERDATA; i++) {
body = new JSONObject();
userDataId = "userdata00" + i;
body.put("__id", userDataId);
body.put("dynamicProperty", "dynamicPropertyValue" + i);
body.put("sample", "sample" + i);
body.put("test", "test" + i);
body.put("number", i);
body.put("decimal", i + DECIMAL);
createUserData(cellName, "box1", TEST_ODATA, "SalesDetail", body);
}
// userdata001のdynamicPropertyのみ違うデータ
userDataId = "userdata001_dynamicProperty2";
body = new JSONObject();
body.put("__id", userDataId);
body.put("dynamicProperty", "dynamicPropertyValue2");
body.put("sample", "sample1");
body.put("test", "test1");
body.put("decimal", 1 + DECIMAL);
body.put("truth", true);
createUserData(cellName, "box1", TEST_ODATA, "SalesDetail", body);
// userdata001のsampleのみ違うデータ
userDataId = "userdata001_sample2";
body = new JSONObject();
body.put("__id", userDataId);
body.put("dynamicProperty", "dynamicPropertyValue1");
body.put("sample", "sample2");
body.put("test", "test1");
body.put("number", null);
body.put("decimal", 1 + DECIMAL);
body.put("truth", false);
createUserData(cellName, "box1", TEST_ODATA, "SalesDetail", body);
// userdata001のtestのみ違うデータ
userDataId = "userdata001_test2";
body = new JSONObject();
body.put("__id", userDataId);
body.put("dynamicProperty", "dynamicPropertyValue1");
body.put("sample", "sample1");
body.put("test", "test2");
body.put("number", 1);
body.put("decimal", 1 + DECIMAL);
createUserData(cellName, "box1", TEST_ODATA, "SalesDetail", body);
// 部分一致検索用データの登録
body = new JSONObject();
userDataId = "userdata100";
body.put("__id", userDataId);
body.put("japanese", "部分一致検索テスト");
body.put("english", "Search substringof Test");
body.put("test", "atest");
body.put("number", 1);
body.put("decimal", 1 + DECIMAL);
createUserDataWithDcClient(cellName, "box1", TEST_ODATA, "SalesDetail", body);
body = new JSONObject();
userDataId = "userdata101";
body.put("__id", userDataId);
body.put("japanese", "部分一致検索漢字のテスト");
body.put("english", "Test Substringof Search value");
body.put("test", "btest");
body.put("number", 1);
body.put("decimal", 1 + DECIMAL);
createUserDataWithDcClient(cellName, "box1", TEST_ODATA, "SalesDetail", body);
body = new JSONObject();
userDataId = "userdata102";
body.put("__id", userDataId);
body.put("japanese", "部分一致けんさくのテスト");
body.put("english", "test substringof search");
body.put("test", "ctest");
body.put("number", 1);
body.put("decimal", 1 + DECIMAL);
createUserDataWithDcClient(cellName, "box1", TEST_ODATA, "SalesDetail", body);
body = new JSONObject();
userDataId = "userdata001";
body.put("__id", userDataId);
int maxPropNum = PersoniumUnitConfig.getMaxPropertyCountInEntityType();
for (int i = 0; i < maxPropNum; i++) {
body.put("dynamicProperty" + i, "dynamicPropertyValue" + i);
}
createUserDataWithDcClient(cellName, "box1", TEST_ODATA, TEST_ENTITYTYPE_MDP, body);
deleteUserData(cellName, "box1", TEST_ODATA, TEST_ENTITYTYPE_MDP, userDataId);
}
/**
* 指定したCellに検索用のユーザーデータを作成する.
* @param cellName
* セル名
*/
@SuppressWarnings("unchecked")
public static void createUserDatasToSearchOdata(String cellName) {
JSONObject body;
String userDataId;
// 文字列エンティティに登録
for (int i = 0; i < NUM_USERDATA; i++) {
body = new JSONObject();
userDataId = "userdata00" + i;
body.put("__id", userDataId);
body.put("property1", null);
body.put("property2", "");
body.put("property3", "Value" + System.currentTimeMillis());
if (i % 2 == 0) {
body.put("property4", "Value1");
} else {
body.put("property4", "Value2");
}
createUserData(cellName, TEST_BOX1, SEARCH_ODATA, "string", body);
}
// 文字列配列エンティティに登録
for (int i = 0; i < NUM_USERDATA; i++) {
body = new JSONObject();
userDataId = "userdata00" + i;
body.put("__id", userDataId);
body.put("property1", null);
body.put("property2", Arrays.asList());
body.put("property3", Arrays.asList("Value" + System.currentTimeMillis()));
body.put("property4",
Arrays.asList("Value" + System.currentTimeMillis(), "Value" + System.currentTimeMillis()));
createUserData(cellName, TEST_BOX1, SEARCH_ODATA, "stringList", body);
}
// 整数値エンティティに登録
for (int i = 0; i < NUM_USERDATA; i++) {
body = new JSONObject();
userDataId = "userdata00" + i;
body.put("__id", userDataId);
body.put("property1", null);
body.put("property2", 0);
body.put("property3", i + 1);
body.put("property4", i - 1);
createUserData(cellName, TEST_BOX1, SEARCH_ODATA, "int", body);
}
// 整数値配列エンティティに登録
for (int i = 0; i < NUM_USERDATA; i++) {
body = new JSONObject();
userDataId = "userdata00" + i;
body.put("__id", userDataId);
body.put("property1", null);
body.put("property2", Arrays.asList());
body.put("property3", Arrays.asList(i));
body.put("property4", Arrays.asList(i - 1, i + 1));
createUserData(cellName, TEST_BOX1, SEARCH_ODATA, "intList", body);
}
// 小数値エンティティに登録
final float num = 10.5F;
for (int i = 0; i < NUM_USERDATA; i++) {
body = new JSONObject();
userDataId = "userdata00" + i;
body.put("__id", userDataId);
body.put("property1", null);
body.put("property2", 0.0F);
body.put("property3", (i + 1) * num);
body.put("property4", (i - 1) * num);
createUserData(cellName, TEST_BOX1, SEARCH_ODATA, "single", body);
}
// 小数値配列エンティティに登録
for (int i = 0; i < NUM_USERDATA; i++) {
body = new JSONObject();
userDataId = "userdata00" + i;
body.put("__id", userDataId);
body.put("property1", null);
body.put("property2", Arrays.asList());
body.put("property3", Arrays.asList(i * num));
body.put("property4", Arrays.asList((i - 1) * num, (i + 1) * num));
createUserData(cellName, TEST_BOX1, SEARCH_ODATA, "singleList", body);
}
// 真偽値エンティティに登録
for (int i = 0; i < NUM_USERDATA; i++) {
body = new JSONObject();
userDataId = "userdata00" + i;
body.put("__id", userDataId);
body.put("property1", null);
body.put("property2", true);
if (i % 2 == 0) {
body.put("property3", false);
} else {
body.put("property3", true);
}
body.put("property4", true);
createUserData(cellName, TEST_BOX1, SEARCH_ODATA, "boolean", body);
}
// 真偽値配列エンティティに登録
for (int i = 0; i < NUM_USERDATA; i++) {
body = new JSONObject();
userDataId = "userdata00" + i;
body.put("__id", userDataId);
body.put("property1", null);
body.put("property2", Arrays.asList());
body.put("property3", Arrays.asList(false));
body.put("property4", Arrays.asList(false, true));
createUserData(cellName, TEST_BOX1, SEARCH_ODATA, "booleanList", body);
}
// 日付型エンティティに登録
for (int i = 0; i < NUM_USERDATA; i++) {
body = new JSONObject();
userDataId = "userdata00" + i;
body.put("__id", userDataId);
body.put("property1", null);
body.put("property2", String.format("/Date(1398991538%03d)/", i));
body.put("property3", "/Date(1398991538550)/");
body.put("property4", "/Date(1398991538551)/");
createUserData(cellName, TEST_BOX1, SEARCH_ODATA, "datetime", body);
}
// 動的プロパティ用エンティティに登録
body = new JSONObject();
userDataId = "userdata000";
body.put("__id", userDataId);
body.put("property1", "Value2");
body.put("property2", 0.0);
createUserData(cellName, TEST_BOX1, SEARCH_ODATA, "dynamic", body);
body = new JSONObject();
userDataId = "userdata001";
body.put("__id", userDataId);
body.put("property1", "Value1");
body.put("property2", 2);
createUserData(cellName, TEST_BOX1, SEARCH_ODATA, "dynamic", body);
body = new JSONObject();
userDataId = "userdata002";
body.put("__id", userDataId);
body.put("property1", "Value1");
body.put("property2", num);
createUserData(cellName, TEST_BOX1, SEARCH_ODATA, "dynamic", body);
}
/**
* ユーザーデータを1件作成する.
* @param cellName
* セル名
* @param boxName