コード例 #1
0
  @Test
  public void createProjetUserParamWithValidUser() throws Exception {
    String filename = testFileDir + "/pm_create_project_user_param_with_valid_user.xml";
    ParamType ctype = null;
    String masterInstanceResult = null;
    try {
      String requestString = getQueryString(filename);
      OMElement requestElement = convertStringToOMElement(requestString);
      OMElement responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);

      // read test file and store query instance ;
      // unmarshall this response string
      JAXBElement responseJaxb =
          PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      ResponseMessageType r = (ResponseMessageType) responseJaxb.getValue();
      JAXBUnWrapHelper helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);

      // Check to see if really added
      filename = testFileDir + "/pm_create_project_user_param_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);

      // read test file and store query instance ;
      // unmarshall this response string
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      ParamsType allParams =
          (ParamsType) helper.getObjectByClass(r.getMessageBody().getAny(), ParamsType.class);

      assertEquals(allParams.getParam().size(), 1);
      for (ParamType param : allParams.getParam()) {
        if (param.getName().equals("Bamboo_Param")) {
          ctype = param;
          break;
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    assertNotNull(masterInstanceResult);
    assertNotNull(ctype);
    assertEquals(ctype.getName(), "Bamboo_Param");
    assertEquals(ctype.getValue(), "my test");
    assertEquals(ctype.getDatatype(), "T");
  }
コード例 #2
0
  @Test
  public void CRUDGlobalParamWithValidUser() throws Exception {
    String filename = testFileDir + "/pm_create_global_param_with_valid_user.xml";
    // ParamType ctype = null;
    int id = -1;
    String masterInstanceResult = null;
    try {
      String requestString = getQueryString(filename);
      OMElement requestElement = convertStringToOMElement(requestString);
      OMElement responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      JAXBElement responseJaxb =
          PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      ResponseMessageType r = (ResponseMessageType) responseJaxb.getValue();
      JAXBUnWrapHelper helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really added
      filename = testFileDir + "/pm_create_global_param_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      ParamsType allParams =
          (ParamsType) helper.getObjectByClass(r.getMessageBody().getAny(), ParamsType.class);

      for (ParamType param : allParams.getParam()) {
        if (param.getName().equals("Global") && param.getValue().equals("Global Value")) {
          assertNotNull(param);
          assertEquals(param.getName(), "Global");
          assertEquals(param.getValue(), "Global Value");
          assertEquals(param.getDatatype(), "T");
          id = param.getId();
          break;
        }
      }

      // Update the project
      filename = testFileDir + "/pm_update_global_param_with_valid_user.xml";
      requestString = getQueryString(filename);
      requestString = requestString.replace("{{{id}}}", Integer.toString(id));
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really added
      filename = testFileDir + "/pm_recreate_global_param_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestString = requestString.replace("{{{id}}}", Integer.toString(id));
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      GlobalDataType global =
          (GlobalDataType)
              helper.getObjectByClass(r.getMessageBody().getAny(), GlobalDataType.class);

      for (ParamType param : global.getParam()) {
        if (param.getId() == id) {
          assertNotNull(param);
          assertEquals(param.getName(), "Global");
          assertEquals(param.getValue(), "Global Value2");
          assertEquals(param.getDatatype(), "N");
          break;
        }
      }

      // Delete project
      filename = testFileDir + "/pm_delete_global_param_with_valid_user.xml";
      requestString = getQueryString(filename);
      requestString = requestString.replace("{{{id}}}", Integer.toString(id));
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really deleted
      filename = testFileDir + "/pm_recreate_global_param_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestString = requestString.replace("{{{id}}}", Integer.toString(id));
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      String err = r.getResponseHeader().getResultStatus().getStatus().getType();
      assertEquals("ERROR", err);

      // Reenable project
      // Update the project
      filename = testFileDir + "/pm_update_global_param_with_valid_user.xml";
      requestString = getQueryString(filename);
      requestString = requestString.replace("{{{id}}}", Integer.toString(id));
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really reenabled
      filename = testFileDir + "/pm_recreate_global_param_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestString = requestString.replace("{{{id}}}", Integer.toString(id));
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      global =
          (GlobalDataType)
              helper.getObjectByClass(r.getMessageBody().getAny(), GlobalDataType.class);

      for (ParamType param : global.getParam()) {
        if (param.getId() == id) {
          assertNotNull(param);
          assertEquals(param.getName(), "Global");
          assertEquals(param.getValue(), "Global Value2");
          assertEquals(param.getDatatype(), "N");
          break;
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
      assertTrue(false);
    }
  }