Skip to content

Commit a228b77

Browse files
Ajit GeorgeAjit George
authored andcommitted
Changed test methods to handle exceptions for invalid datatypes and JSON content
1 parent a1d9bd6 commit a228b77

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

test-complete/src/test/java/com/marklogic/javaclient/TestPOJOWithDocsStoredByOthers.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,16 @@
1616
import com.marklogic.client.DatabaseClient;
1717
import com.marklogic.client.DatabaseClientFactory;
1818
import com.marklogic.client.DatabaseClientFactory.Authentication;
19-
import com.marklogic.client.MarkLogicIOException;
19+
import com.marklogic.client.ResourceNotFoundException;
2020
import com.marklogic.client.document.DocumentManager.Metadata;
21-
import com.marklogic.client.document.DocumentPatchBuilder;
2221
import com.marklogic.client.document.DocumentWriteSet;
2322
import com.marklogic.client.document.JSONDocumentManager;
2423
import com.marklogic.client.io.DocumentMetadataHandle;
2524
import com.marklogic.client.io.DocumentMetadataHandle.Capability;
26-
import com.marklogic.client.io.DocumentMetadataHandle.DocumentCollections;
27-
import com.marklogic.client.io.DocumentMetadataHandle.DocumentPermissions;
28-
import com.marklogic.client.io.DocumentMetadataHandle.DocumentProperties;
2925
import com.marklogic.client.io.Format;
3026
import com.marklogic.client.io.JacksonHandle;
3127
import com.marklogic.client.pojo.PojoRepository;
3228
import com.marklogic.client.pojo.annotation.Id;
33-
import com.marklogic.javaclient.TestPOJOMissingIdGetSetMethod.SmallArtifactMissingGetter;
3429

3530
public class TestPOJOWithDocsStoredByOthers extends BasicJavaClientREST {
3631

@@ -251,7 +246,7 @@ public void validateSmallArtifact(SmallArtifactIdInSuper artifact) {
251246
public void validateSmallArtifactSuper(SmallArtifactNoId artifact) {
252247
assertNotNull("Artifact object should never be Null", artifact);
253248
assertNotNull("Id should never be Null", artifact.getId());
254-
assertEquals("Id of the object is ", -99, artifact.getId());
249+
assertEquals("Id of the object is ", 0, artifact.getId());
255250
assertEquals("Name of the object is ", "SmallArtifactInSuperOnly",
256251
artifact.getName());
257252
assertEquals("Inventory of the object is ", 1000,
@@ -333,7 +328,7 @@ public void validateSubObjReferencedbySuperClassvariableOne(SmallArtifactIdInSup
333328
* Issue 136 might solve this also.
334329
*/
335330

336-
@Test
331+
@Test(expected=IllegalArgumentException.class)
337332
public void testPOJOReadDocStoredWithInvalidContent() throws Exception {
338333

339334
String docId[] = { "com.marklogic.javaclient.TestPOJOWithDocsStoredByOthers$SmallArtifactIdInSuper/SmallArtifactIdInSuper.json" };
@@ -420,11 +415,11 @@ public void testPOJOReadDocStoredWithNoBeanProperty() throws Exception {
420415
* Purpose : This test is to validate read documents with valid POJO
421416
* specific URI and has invalid data-types for one of the bean property.
422417
* Uses SmallArtifact class which has @Id on the name methods. Test result
423-
* expectations are: read should return exception.
418+
* expectations are: read should return ResourceNotFoundException exception.
424419
* Field inventory has a String
425420
*/
426421

427-
@Test(/*expected=MarkLogicIOException.class*/)
422+
@Test(expected=ResourceNotFoundException.class)
428423
public void testPOJOReadDocStoredWithInvalidDataType() throws Exception {
429424

430425
String docId[] = { "com.marklogic.javaclient.TestPOJOWithDocsStoredByOthers$SmallArtifact/SmallArtifact.json" };

0 commit comments

Comments
 (0)