private PoxPayloadOut createConditioncheckInstance( String conditionCheckRefNumber, String conditionChecker) throws Exception { ConditionchecksCommon conditioncheckCommon = new ConditionchecksCommon(); conditioncheckCommon.setConditionCheckRefNumber(conditionCheckRefNumber); conditioncheckCommon.setConditionChecker(conditionChecker); PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); PayloadOutputPart commonPart = multipart.addPart(new ConditioncheckClient().getCommonPartName(), conditioncheckCommon); if (logger.isDebugEnabled()) { logger.debug("to be created, conditioncheck common"); logger.debug(objectAsXmlString(conditioncheckCommon, ConditionchecksCommon.class)); } return multipart; }
// Success outcomes @Test( dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createWithAuthRefs"}) public void readAndCheckAuthRefs(String testName) throws Exception { // Perform setup. testSetup(STATUS_OK, ServiceRequestType.READ); // Submit the request to the service and store the response. ConditioncheckClient conditioncheckClient = new ConditioncheckClient(); Response res = conditioncheckClient.read(knownResourceId); ConditionchecksCommon conditioncheckCommon = null; try { assertStatusCode(res, testName); // Extract the common part from the response. PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class)); conditioncheckCommon = (ConditionchecksCommon) extractPart( input, conditioncheckClient.getCommonPartName(), ConditionchecksCommon.class); Assert.assertNotNull(conditioncheckCommon); if (logger.isDebugEnabled()) { logger.debug(objectAsXmlString(conditioncheckCommon, ConditionchecksCommon.class)); } } finally { if (res != null) { res.close(); } } // // Check a couple of fields Assert.assertEquals(conditioncheckCommon.getConditionChecker(), conditionCheckerRefName); // Get the auth refs and check them Response res2 = conditioncheckClient.getAuthorityRefs(knownResourceId); AuthorityRefList list = null; try { assertStatusCode(res2, testName); list = res2.readEntity(AuthorityRefList.class); Assert.assertNotNull(list); } finally { if (res2 != null) { res2.close(); } } List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem(); int numAuthRefsFound = items.size(); if (logger.isDebugEnabled()) { logger.debug( "Expected " + NUM_AUTH_REFS_EXPECTED + " authority references, found " + numAuthRefsFound); } // Optionally output additional data about list members for debugging. boolean iterateThroughList = true; if (iterateThroughList && logger.isDebugEnabled()) { int i = 0; for (AuthorityRefList.AuthorityRefItem item : items) { logger.debug( testName + ": list-item[" + i + "] Field:" + item.getSourceField() + "= " + item.getAuthDisplayName() + item.getItemDisplayName()); logger.debug(testName + ": list-item[" + i + "] refName=" + item.getRefName()); logger.debug(testName + ": list-item[" + i + "] URI=" + item.getUri()); i++; } } Assert.assertEquals( numAuthRefsFound, NUM_AUTH_REFS_EXPECTED, "Did not find all expected authority references! " + "Expected " + NUM_AUTH_REFS_EXPECTED + ", found " + numAuthRefsFound); }