Exemplo n.º 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;
  }
Exemplo n.º 2
0
  /* (non-Javadoc)
   * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
   */
  @Override
  //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
  //    dependsOnMethods = {"create"})
  public void read(String testName) throws Exception {
    // Perform setup.
    setupRead();

    // Submit the request to the service and store the response.
    LoaninClient client = new LoaninClient();
    Response res = client.read(knownResourceId);
    PoxPayloadIn input = null;
    try {
      assertStatusCode(res, testName);
      input = new PoxPayloadIn(res.readEntity(String.class));
    } finally {
      if (res != null) {
        res.close();
      }
    }

    // Get the common part of the response and verify that it is not null.
    PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
    LoansinCommon loaninCommon = null;
    if (payloadInputPart != null) {
      loaninCommon = (LoansinCommon) payloadInputPart.getBody();
    }
    Assert.assertNotNull(loaninCommon);

    // Check selected fields.
    LenderGroupList lenderGroupList = loaninCommon.getLenderGroupList();
    Assert.assertNotNull(lenderGroupList);
    List<LenderGroup> lenderGroups = lenderGroupList.getLenderGroup();
    Assert.assertNotNull(lenderGroups);
    Assert.assertTrue(lenderGroups.size() > 0);
    String lender = lenderGroups.get(0).getLender();
    Assert.assertEquals(lender, LENDER_REF_NAME);

    if (logger.isDebugEnabled()) {
      logger.debug(
          "UTF-8 data sent="
              + getUTF8DataFragment()
              + "\n"
              + "UTF-8 data received="
              + loaninCommon.getLoanInNote());
    }

    Assert.assertEquals(
        loaninCommon.getLoanInNote(),
        getUTF8DataFragment(),
        "UTF-8 data retrieved '"
            + loaninCommon.getLoanInNote()
            + "' does not match expected data '"
            + getUTF8DataFragment());
  }