1616package com .marklogic .client .test ;
1717
1818import 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 .*;
2120import com .marklogic .client .document .DocumentPatchBuilder .Position ;
22- import com .marklogic .client .document .DocumentWriteSet ;
23- import com .marklogic .client .document .XMLDocumentManager ;
2421import com .marklogic .client .io .Format ;
2522import com .marklogic .client .io .SearchHandle ;
2623import com .marklogic .client .io .StringHandle ;
@@ -51,8 +48,10 @@ public class BitemporalFeaturesTest {
5148 static String temporalDocument4 = "temporal-document4" ;
5249 static String temporalDocument5 = "temporal-document5" ;
5350
54- static XMLDocumentManager docMgr ;
55- static QueryManager queryMgr ;
51+ static XMLDocumentManager xmlDocumentManager ;
52+ static GenericDocumentManager genericDocumentManager ;
53+ static QueryManager queryManager ;
54+
5655 static String uniqueBulkTerm = "temporalBulkDocTerm" ;
5756 static String uniqueTerm1 = "temporalDocTerm1" ;
5857 static String uniqueTerm2 = "temporalDocTerm2" ;
@@ -64,8 +63,9 @@ public class BitemporalFeaturesTest {
6463 @ BeforeAll
6564 public static void beforeClass () {
6665 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 ();
6969 }
7070
7171 @ AfterAll
@@ -97,11 +97,11 @@ public void testBitemporalDocument() {
9797 "<valid-end>2014-08-19T00:00:01Z</valid-end>" +
9898 "</test>" ;
9999 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 );
101101 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 );
103103 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 );
105105 QueryManager queryMgr = Common .restAdminClient .newQueryManager ();
106106 queryMgr .setPageLength (1000 );
107107 QueryDefinition query = queryMgr .newStringDefinition ();
@@ -142,13 +142,12 @@ public void testBitemporalDocumentBulk() {
142142 "<valid-start>2014-08-19T00:00:05Z</valid-start>" +
143143 "<valid-end>2014-08-19T00:00:06Z</valid-end>" +
144144 "</test>" ;
145- DocumentWriteSet writeSet = docMgr .newWriteSet ();
145+ DocumentWriteSet writeSet = genericDocumentManager .newWriteSet ();
146146 writeSet .add (prefix + "_A.xml" , new StringHandle (doc1 ).withFormat (Format .XML ), temporalDocument1 );
147147 writeSet .add (prefix + "_B.xml" , new StringHandle (doc2 ).withFormat (Format .XML ), temporalDocument2 );
148148 writeSet .add (prefix + "_C.xml" , new StringHandle (doc3 ).withFormat (Format .XML ), temporalDocument3 );
149149 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 );
152151 QueryManager queryMgr = Common .restAdminClient .newQueryManager ();
153152 queryMgr .setPageLength (1000 );
154153 QueryDefinition query = queryMgr .newStringDefinition ();
@@ -175,34 +174,34 @@ public void testTemporalDocumentPatch() throws XpathException, SAXException, IOE
175174 "</test>" ;
176175
177176 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 );
179178
180- DocumentPatchBuilder patchBldr = docMgr .newPatchBuilder ();
179+ DocumentPatchBuilder patchBldr = xmlDocumentManager .newPatchBuilder ();
181180 patchBldr .insertFragment ("/test/song" , Position .AFTER , "<song>Kryptonite</song>" );
182181 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 ();
185184 assertXpathEvaluatesTo ("2" ,"count(/*[local-name()='test']/*[local-name()='song'])" ,content );
186185
187- DocumentMetadataPatchBuilder metadatapatchBldr = docMgr .newPatchBuilder (Format .XML );
186+ DocumentMetadataPatchBuilder metadatapatchBldr = genericDocumentManager .newPatchBuilder (Format .XML );
188187 DocumentPatchHandle metadatapatchHandle = metadatapatchBldr
189188 .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 ();
192191 assertXpathEvaluatesTo ("2" ,"count(/*[local-name()='metadata']/*[local-name()='metadata-values']/*[local-name()='metadata-value'])" ,metadata );
193192
194- patchBldr = docMgr .newPatchBuilder ();
193+ patchBldr = xmlDocumentManager .newPatchBuilder ();
195194 patchBldr .insertFragment ("/test" , Position .LAST_CHILD , "<song>Here I am</song>" );
196195 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 ();
199198 assertXpathEvaluatesTo ("3" ,"count(/*[local-name()='test']/*[local-name()='song'])" ,content );
200199
201- patchBldr = docMgr .newPatchBuilder ();
200+ patchBldr = xmlDocumentManager .newPatchBuilder ();
202201 patchBldr .insertFragment ("/test" , Position .LAST_CHILD , "<song>Please forgive me</song>" );
203202 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 ();
206205 assertXpathEvaluatesTo ("4" ,"count(/*[local-name()='test']/*[local-name()='song'])" ,content );
207206 }
208207
@@ -226,14 +225,14 @@ public void testProtectWipe() throws DatatypeConfigurationException {
226225 "<valid-end>2014-08-19T00:00:02Z</valid-end>" +
227226 "</test>" ;
228227 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 );
230229 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" ));
233232
234233 Common .waitFor (1500 );
235234
236- docMgr .wipe (logicalID , temporalCollection );
235+ genericDocumentManager .wipe (logicalID , temporalCollection );
237236 QueryManager queryMgr = Common .restAdminClient .newQueryManager ();
238237 queryMgr .setPageLength (1000 );
239238 QueryDefinition query = queryMgr .newStringDefinition ();
@@ -246,14 +245,14 @@ public void testProtectWipe() throws DatatypeConfigurationException {
246245 static public void cleanUp () throws DatatypeConfigurationException {
247246 String temporalDoc = "temporal-document" ;
248247 for (int i = 1 ; i < 6 ; i ++) {
249- docMgr .protect (temporalDoc + i , temporalCollection , ProtectionLevel .NOWIPE ,
248+ genericDocumentManager .protect (temporalDoc + i , temporalCollection , ProtectionLevel .NOWIPE ,
250249 DatatypeFactory .newInstance ().newDuration ("PT1S" ));
251250 }
252251
253252 Common .waitFor (1500 );
254253
255254 for (int i = 1 ; i < 6 ; i ++) {
256- docMgr .wipe (temporalDoc + i , temporalCollection );
255+ genericDocumentManager .wipe (temporalDoc + i , temporalCollection );
257256 }
258257 }
259258}
0 commit comments