16
16
package com .marklogic .client .test ;
17
17
18
18
import com .marklogic .client .bitemporal .TemporalDocumentManager .ProtectionLevel ;
19
- import com .marklogic .client .document .DocumentMetadataPatchBuilder ;
20
- import com .marklogic .client .document .DocumentPatchBuilder ;
19
+ import com .marklogic .client .document .*;
21
20
import com .marklogic .client .document .DocumentPatchBuilder .Position ;
22
- import com .marklogic .client .document .DocumentWriteSet ;
23
- import com .marklogic .client .document .XMLDocumentManager ;
24
21
import com .marklogic .client .io .Format ;
25
22
import com .marklogic .client .io .SearchHandle ;
26
23
import com .marklogic .client .io .StringHandle ;
@@ -51,8 +48,10 @@ public class BitemporalFeaturesTest {
51
48
static String temporalDocument4 = "temporal-document4" ;
52
49
static String temporalDocument5 = "temporal-document5" ;
53
50
54
- static XMLDocumentManager docMgr ;
55
- static QueryManager queryMgr ;
51
+ static XMLDocumentManager xmlDocumentManager ;
52
+ static GenericDocumentManager genericDocumentManager ;
53
+ static QueryManager queryManager ;
54
+
56
55
static String uniqueBulkTerm = "temporalBulkDocTerm" ;
57
56
static String uniqueTerm1 = "temporalDocTerm1" ;
58
57
static String uniqueTerm2 = "temporalDocTerm2" ;
@@ -64,8 +63,9 @@ public class BitemporalFeaturesTest {
64
63
@ BeforeAll
65
64
public static void beforeClass () {
66
65
Common .connectRestAdmin ();
67
- docMgr = Common .restAdminClient .newXMLDocumentManager ();
68
- queryMgr = Common .restAdminClient .newQueryManager ();
66
+ xmlDocumentManager = Common .restAdminClient .newXMLDocumentManager ();
67
+ genericDocumentManager = Common .restAdminClient .newDocumentManager ();
68
+ queryManager = Common .restAdminClient .newQueryManager ();
69
69
}
70
70
71
71
@ AfterAll
@@ -97,11 +97,11 @@ public void testBitemporalDocument() {
97
97
"<valid-end>2014-08-19T00:00:01Z</valid-end>" +
98
98
"</test>" ;
99
99
StringHandle handle1 = new StringHandle (doc1 ).withFormat (Format .XML );
100
- docMgr .write (docId1 , temporalDocument1 , null , handle1 , null , null , temporalCollection );
100
+ xmlDocumentManager .write (docId1 , temporalDocument1 , null , handle1 , null , null , temporalCollection );
101
101
StringHandle handle2 = new StringHandle (doc2 ).withFormat (Format .XML );
102
- docMgr .write (docId2 , temporalDocument2 , null , handle2 , null , null , temporalCollection );
102
+ xmlDocumentManager .write (docId2 , temporalDocument2 , null , handle2 , null , null , temporalCollection );
103
103
StringHandle handle3 = new StringHandle (doc3 ).withFormat (Format .XML );
104
- docMgr .write (docId3 , temporalDocument1 , null , handle3 , null , null , temporalCollection );
104
+ xmlDocumentManager .write (docId3 , temporalDocument1 , null , handle3 , null , null , temporalCollection );
105
105
QueryManager queryMgr = Common .restAdminClient .newQueryManager ();
106
106
queryMgr .setPageLength (1000 );
107
107
QueryDefinition query = queryMgr .newStringDefinition ();
@@ -142,13 +142,12 @@ public void testBitemporalDocumentBulk() {
142
142
"<valid-start>2014-08-19T00:00:05Z</valid-start>" +
143
143
"<valid-end>2014-08-19T00:00:06Z</valid-end>" +
144
144
"</test>" ;
145
- DocumentWriteSet writeSet = docMgr .newWriteSet ();
145
+ DocumentWriteSet writeSet = genericDocumentManager .newWriteSet ();
146
146
writeSet .add (prefix + "_A.xml" , new StringHandle (doc1 ).withFormat (Format .XML ), temporalDocument1 );
147
147
writeSet .add (prefix + "_B.xml" , new StringHandle (doc2 ).withFormat (Format .XML ), temporalDocument2 );
148
148
writeSet .add (prefix + "_C.xml" , new StringHandle (doc3 ).withFormat (Format .XML ), temporalDocument3 );
149
149
writeSet .add (prefix + "_D.xml" , new StringHandle (doc4 ).withFormat (Format .XML ), temporalDocument4 );
150
- docMgr .write (writeSet , null , null , temporalCollection );
151
- writeSet = docMgr .newWriteSet ();
150
+ genericDocumentManager .write (writeSet , null , null , temporalCollection );
152
151
QueryManager queryMgr = Common .restAdminClient .newQueryManager ();
153
152
queryMgr .setPageLength (1000 );
154
153
QueryDefinition query = queryMgr .newStringDefinition ();
@@ -175,34 +174,34 @@ public void testTemporalDocumentPatch() throws XpathException, SAXException, IOE
175
174
"</test>" ;
176
175
177
176
StringHandle handle1 = new StringHandle (doc1 ).withFormat (Format .XML );
178
- docMgr .write (temporalDocument5 , null , handle1 , null , null , temporalCollection );
177
+ xmlDocumentManager .write (temporalDocument5 , null , handle1 , null , null , temporalCollection );
179
178
180
- DocumentPatchBuilder patchBldr = docMgr .newPatchBuilder ();
179
+ DocumentPatchBuilder patchBldr = xmlDocumentManager .newPatchBuilder ();
181
180
patchBldr .insertFragment ("/test/song" , Position .AFTER , "<song>Kryptonite</song>" );
182
181
DocumentPatchHandle patchHandle = patchBldr .build ();
183
- docMgr .patch (temporalDocument5 , temporalCollection , patchHandle );
184
- String content = docMgr .read (temporalDocument5 , new StringHandle ().withFormat (Format .XML )).get ();
182
+ genericDocumentManager .patch (temporalDocument5 , temporalCollection , patchHandle );
183
+ String content = xmlDocumentManager .read (temporalDocument5 , new StringHandle ().withFormat (Format .XML )).get ();
185
184
assertXpathEvaluatesTo ("2" ,"count(/*[local-name()='test']/*[local-name()='song'])" ,content );
186
185
187
- DocumentMetadataPatchBuilder metadatapatchBldr = docMgr .newPatchBuilder (Format .XML );
186
+ DocumentMetadataPatchBuilder metadatapatchBldr = genericDocumentManager .newPatchBuilder (Format .XML );
188
187
DocumentPatchHandle metadatapatchHandle = metadatapatchBldr
189
188
.addMetadataValue ("key1" , "value1" ).build ();
190
- docMgr .patch (temporalDocument5 , temporalCollection , metadatapatchHandle );
191
- String metadata = docMgr .readMetadata (temporalDocument5 , new StringHandle ().withFormat (Format .XML )).get ();
189
+ genericDocumentManager .patch (temporalDocument5 , temporalCollection , metadatapatchHandle );
190
+ String metadata = genericDocumentManager .readMetadata (temporalDocument5 , new StringHandle ().withFormat (Format .XML )).get ();
192
191
assertXpathEvaluatesTo ("2" ,"count(/*[local-name()='metadata']/*[local-name()='metadata-values']/*[local-name()='metadata-value'])" ,metadata );
193
192
194
- patchBldr = docMgr .newPatchBuilder ();
193
+ patchBldr = xmlDocumentManager .newPatchBuilder ();
195
194
patchBldr .insertFragment ("/test" , Position .LAST_CHILD , "<song>Here I am</song>" );
196
195
patchHandle = patchBldr .build ();
197
- docMgr .patch ("temporal-document5v1" , temporalDocument5 , temporalCollection , temporalDocument5 , patchHandle );
198
- content = docMgr .read ("temporal-document5v1" , new StringHandle ().withFormat (Format .XML )).get ();
196
+ genericDocumentManager .patch ("temporal-document5v1" , temporalDocument5 , temporalCollection , temporalDocument5 , patchHandle );
197
+ content = xmlDocumentManager .read ("temporal-document5v1" , new StringHandle ().withFormat (Format .XML )).get ();
199
198
assertXpathEvaluatesTo ("3" ,"count(/*[local-name()='test']/*[local-name()='song'])" ,content );
200
199
201
- patchBldr = docMgr .newPatchBuilder ();
200
+ patchBldr = xmlDocumentManager .newPatchBuilder ();
202
201
patchBldr .insertFragment ("/test" , Position .LAST_CHILD , "<song>Please forgive me</song>" );
203
202
patchHandle = patchBldr .build ();
204
- docMgr .patch ("temporal-document5v2" , temporalDocument5 , temporalCollection , "temporal-document5v1" , patchHandle );
205
- content = docMgr .read ("temporal-document5v2" , new StringHandle ().withFormat (Format .XML )).get ();
203
+ genericDocumentManager .patch ("temporal-document5v2" , temporalDocument5 , temporalCollection , "temporal-document5v1" , patchHandle );
204
+ content = xmlDocumentManager .read ("temporal-document5v2" , new StringHandle ().withFormat (Format .XML )).get ();
206
205
assertXpathEvaluatesTo ("4" ,"count(/*[local-name()='test']/*[local-name()='song'])" ,content );
207
206
}
208
207
@@ -226,14 +225,14 @@ public void testProtectWipe() throws DatatypeConfigurationException {
226
225
"<valid-end>2014-08-19T00:00:02Z</valid-end>" +
227
226
"</test>" ;
228
227
StringHandle handle1 = new StringHandle (doc1 ).withFormat (Format .XML );
229
- docMgr .write (protectDocID , logicalID , null , handle1 , null , null , temporalCollection );
228
+ xmlDocumentManager .write (protectDocID , logicalID , null , handle1 , null , null , temporalCollection );
230
229
StringHandle handle2 = new StringHandle (doc2 ).withFormat (Format .XML );
231
- docMgr .write (protectDocIDv2 , logicalID , null , handle2 , null , null , temporalCollection );
232
- docMgr .protect (logicalID , temporalCollection , ProtectionLevel .NOWIPE , DatatypeFactory .newInstance ().newDuration ("PT1S" ));
230
+ xmlDocumentManager .write (protectDocIDv2 , logicalID , null , handle2 , null , null , temporalCollection );
231
+ genericDocumentManager .protect (logicalID , temporalCollection , ProtectionLevel .NOWIPE , DatatypeFactory .newInstance ().newDuration ("PT1S" ));
233
232
234
233
Common .waitFor (1500 );
235
234
236
- docMgr .wipe (logicalID , temporalCollection );
235
+ genericDocumentManager .wipe (logicalID , temporalCollection );
237
236
QueryManager queryMgr = Common .restAdminClient .newQueryManager ();
238
237
queryMgr .setPageLength (1000 );
239
238
QueryDefinition query = queryMgr .newStringDefinition ();
@@ -246,14 +245,14 @@ public void testProtectWipe() throws DatatypeConfigurationException {
246
245
static public void cleanUp () throws DatatypeConfigurationException {
247
246
String temporalDoc = "temporal-document" ;
248
247
for (int i = 1 ; i < 6 ; i ++) {
249
- docMgr .protect (temporalDoc + i , temporalCollection , ProtectionLevel .NOWIPE ,
248
+ genericDocumentManager .protect (temporalDoc + i , temporalCollection , ProtectionLevel .NOWIPE ,
250
249
DatatypeFactory .newInstance ().newDuration ("PT1S" ));
251
250
}
252
251
253
252
Common .waitFor (1500 );
254
253
255
254
for (int i = 1 ; i < 6 ; i ++) {
256
- docMgr .wipe (temporalDoc + i , temporalCollection );
255
+ genericDocumentManager .wipe (temporalDoc + i , temporalCollection );
257
256
}
258
257
}
259
258
}
0 commit comments