コード例 #1
0
  @Test
  public void testPolicies() throws ModelConversionException, FileNotFoundException, JAXBException {

    File file = getResourceFile("/samples/test_parse_windows.xml");
    eu.atos.sla.parser.data.wsag.Agreement agreementXML = readXml(file);
    IAgreement a =
        modelConverter.getAgreementFromAgreementXML(
            (eu.atos.sla.parser.data.wsag.IAgreement) agreementXML, "");

    checkPolicyExists(
        new Policy(2, new Date(120 * 1000)), a.getGuaranteeTerms().get(0).getPolicies());
    checkPolicyExists(
        new Policy(3, new Date(3600 * 1000)), a.getGuaranteeTerms().get(0).getPolicies());
  }
コード例 #2
0
  private void checkParseAgreementContext(
      eu.atos.sla.parser.data.wsag.Agreement agreementXML, ServiceProvider rol)
      throws JAXBException, FileNotFoundException, ModelConversionException {

    String expectedProvider;
    String expectedConsumer;

    if (rol == null) {
      agreementXML.getContext().setServiceProvider("invalid value here");
      expectedProvider = null;
      expectedConsumer = null;
    } else {
      agreementXML.getContext().setServiceProvider(rol.toString());
      if (rol == ServiceProvider.AGREEMENT_INITIATOR) {
        expectedProvider = "initiator";
        expectedConsumer = "responder";
      } else if (rol == ServiceProvider.AGREEMENT_RESPONDER) {
        expectedConsumer = "initiator";
        expectedProvider = "responder";
      } else {
        throw new AssertionError();
      }
    }

    String actualProvider;
    String actualConsumer;
    try {
      IAgreement a =
          modelConverter.getAgreementFromAgreementXML(
              (eu.atos.sla.parser.data.wsag.IAgreement) agreementXML, "");
      actualProvider = a.getProvider().getUuid();
      actualConsumer = a.getConsumer();
    } catch (ModelConversionException e) {
      actualProvider = null;
      actualConsumer = null;
    }

    /*
     * Match provider
     */
    if (rol == null) {
      assertNull(actualProvider);
      assertNull(actualConsumer);
    } else {
      assertEquals(expectedProvider, actualProvider);
      assertEquals(expectedConsumer, actualConsumer);
    }
  }
コード例 #3
0
  @Test
  public void testCustomBusinessValue()
      throws JAXBException, FileNotFoundException, ModelConversionException {

    File file = getResourceFile("/samples/test_parse_business.xml");
    eu.atos.sla.parser.data.wsag.Agreement agreementXML = readXml(file);
    IAgreement a =
        modelConverter.getAgreementFromAgreementXML(
            (eu.atos.sla.parser.data.wsag.IAgreement) agreementXML, "");

    IPenaltyDefinition[] expected =
        new IPenaltyDefinition[] {
          new PenaltyDefinition(1, new Date(0), "discount", "%", "35", "P1D"),
          new PenaltyDefinition(5, new Date(24 * 60 * 60 * 1000), "service", "", "sms", "P1M")
        };
    for (IGuaranteeTerm gt : a.getGuaranteeTerms()) {
      int i = 0;
      for (IPenaltyDefinition actual : gt.getBusinessValueList().getPenalties()) {

        assertEquals(expected[i], actual);
        i++;
      }
    }
  }