コード例 #1
0
  /**
   * Creates the loanin instance.
   *
   * @param loaninNumber the loanin number
   * @param returnDate the return date
   * @return the multipart output
   * @throws Exception
   */
  private PoxPayloadOut createLoaninInstance(String loaninNumber, String returnDate)
      throws Exception {

    LoansinCommon loaninCommon = new LoansinCommon();
    loaninCommon.setLoanInNumber(loaninNumber);
    loaninCommon.setLoanReturnDate(CURRENT_DATE_UTC);
    LenderGroupList lenderGroupList = new LenderGroupList();
    LenderGroup lenderGroup = new LenderGroup();
    lenderGroup.setLender(LENDER_REF_NAME);
    lenderGroupList.getLenderGroup().add(lenderGroup);
    loaninCommon.setLenderGroupList(lenderGroupList);
    loaninCommon.setLoanPurpose("For Surfboards of the 1960s exhibition.");
    loaninCommon.setLoanInNote(getUTF8DataFragment());

    PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
    PayloadOutputPart commonPart =
        multipart.addPart(new LoaninClient().getCommonPartName(), loaninCommon);

    if (logger.isDebugEnabled()) {
      logger.debug("to be created, loanin common");
      logger.debug(objectAsXmlString(loaninCommon, LoansinCommon.class));
    }

    return multipart;
  }
コード例 #2
0
  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;
  }
コード例 #3
0
  private PoxPayloadOut createIntakeInstance(
      String entryNumber,
      String entryDate,
      String currentOwner,
      String depositor,
      String conditionCheckerAssessor,
      String insurer,
      String Valuer) {
    IntakesCommon intake = new IntakesCommon();
    intake.setEntryNumber(entryNumber);
    intake.setEntryDate(entryDate);
    intake.setCurrentOwner(currentOwner);
    intake.setDepositor(depositor);
    intake.setValuer(Valuer);

    ConditionCheckerOrAssessorList checkerOrAssessorList = new ConditionCheckerOrAssessorList();
    List<String> checkersOrAssessors = checkerOrAssessorList.getConditionCheckerOrAssessor();
    checkersOrAssessors.add(conditionCheckerAssessor);
    intake.setConditionCheckersOrAssessors(checkerOrAssessorList);

    InsurerList insurerList = new InsurerList();
    List<String> insurers = insurerList.getInsurer();
    insurers.add(insurer);
    intake.setInsurers(insurerList);

    PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
    PayloadOutputPart commonPart =
        multipart.addPart(new IntakeClient().getCommonPartName(), intake);

    if (logger.isDebugEnabled()) {
      logger.debug("to be created, intake common");
      logger.debug(objectAsXmlString(intake, IntakesCommon.class));
    }

    return multipart;
  }
コード例 #4
0
  /**
   * Creates an instance of a Movement record for testing.
   *
   * @param movementReferenceNumber A movement reference number.
   * @return Multipart output suitable for use as a payload in a create or update request.
   */
  @Override
  protected PoxPayloadOut createInstance(String movementReferenceNumber) {
    MovementsCommon movementCommon = new MovementsCommon();
    // FIXME: Values of currentLocation, normalLocation,
    // and movementContact should be refNames.
    movementCommon.setCurrentLocation("currentLocation value");
    movementCommon.setCurrentLocationFitness("currentLocationFitness value");
    movementCommon.setCurrentLocationNote("currentLocationNote value");
    movementCommon.setLocationDate(TIMESTAMP_UTC);
    movementCommon.setNormalLocation("normalLocation value");
    movementCommon.setMovementContact("movementContact value");
    MovementMethodsList movementMethodsList = new MovementMethodsList();
    List<String> methods = movementMethodsList.getMovementMethod();
    // @TODO Use properly formatted refNames for representative movement
    // methods in this example record. The values below are placeholders.
    String identifier = createIdentifier();
    methods.add("First Movement Method-" + identifier);
    methods.add("Second Movement Method-" + identifier);
    movementCommon.setMovementMethods(movementMethodsList);
    movementCommon.setMovementNote(getUTF8DataFragment());
    movementCommon.setMovementReferenceNumber(movementReferenceNumber);
    movementCommon.setPlannedRemovalDate(TIMESTAMP_UTC);
    movementCommon.setRemovalDate(""); // Test empty date value
    movementCommon.setReasonForMove("reasonForMove value");

    PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
    PayloadOutputPart commonPart =
        multipart.addPart(new MovementClient().getCommonPartName(), movementCommon);

    if (logger.isDebugEnabled()) {
      logger.debug("to be created, movement common");
      logger.debug(objectAsXmlString(movementCommon, MovementsCommon.class));
    }

    return multipart;
  }
コード例 #5
0
  /* (non-Javadoc)
   * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
   */
  @Override
  //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
  //    dependsOnMethods = {"read"})
  public void update(String testName) throws Exception {
    // Perform setup.
    setupRead();

    // Retrieve the contents of a resource to update.
    LoaninClient client = new LoaninClient();
    Response res = client.read(knownResourceId);
    PoxPayloadIn input = null;
    try {
      assertStatusCode(res, testName);
      input = new PoxPayloadIn(res.readEntity(String.class));
      if (logger.isDebugEnabled()) {
        logger.debug("got object to update with ID: " + knownResourceId);
      }
    } finally {
      if (res != null) {
        res.close();
      }
    }

    // Extract the common part from the response.
    PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
    LoansinCommon loaninCommon = null;
    if (payloadInputPart != null) {
      loaninCommon = (LoansinCommon) payloadInputPart.getBody();
    }
    Assert.assertNotNull(loaninCommon);

    // Update the content of this resource.
    loaninCommon.setLoanInNumber("updated-" + loaninCommon.getLoanInNumber());
    loaninCommon.setLoanInNote("updated-" + loaninCommon.getLoanInNote());
    if (logger.isDebugEnabled()) {
      logger.debug("to be updated object");
      logger.debug(objectAsXmlString(loaninCommon, LoansinCommon.class));
    }

    setupUpdate();

    // Submit the updated common part in an update request to the service
    // and store the response.
    PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
    PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), loaninCommon);
    res = client.update(knownResourceId, output);
    try {
      assertStatusCode(res, testName);
      int statusCode = res.getStatus();
      // Check the status code of the response: does it match the expected response(s)?
      if (logger.isDebugEnabled()) {
        logger.debug(testName + ": status = " + statusCode);
      }
      Assert.assertTrue(
          testRequestType.isValidStatusCode(statusCode),
          invalidStatusCodeMessage(testRequestType, statusCode));
      Assert.assertEquals(statusCode, testExpectedStatusCode);
      input = new PoxPayloadIn(res.readEntity(String.class));
    } finally {
      if (res != null) {
        res.close();
      }
    }

    // Extract the updated common part from the response.
    payloadInputPart = input.getPart(client.getCommonPartName());
    LoansinCommon updatedLoaninCommon = null;
    if (payloadInputPart != null) {
      updatedLoaninCommon = (LoansinCommon) payloadInputPart.getBody();
    }
    Assert.assertNotNull(updatedLoaninCommon);

    // Check selected fields in the updated common part.
    Assert.assertEquals(
        updatedLoaninCommon.getLoanInNumber(),
        loaninCommon.getLoanInNumber(),
        "Data in updated object did not match submitted data.");

    if (logger.isDebugEnabled()) {
      logger.debug(
          "UTF-8 data sent="
              + loaninCommon.getLoanInNote()
              + "\n"
              + "UTF-8 data received="
              + updatedLoaninCommon.getLoanInNote());
    }
    Assert.assertTrue(
        updatedLoaninCommon.getLoanInNote().contains(getUTF8DataFragment()),
        "UTF-8 data retrieved '"
            + updatedLoaninCommon.getLoanInNote()
            + "' does not contain expected data '"
            + getUTF8DataFragment());
    Assert.assertEquals(
        updatedLoaninCommon.getLoanInNote(),
        loaninCommon.getLoanInNote(),
        "Data in updated object did not match submitted data.");
  }