Example #1
0
 public void testFunctionBlankOption() {
   Function x = new Function();
   x.setModuleId("MOD");
   x.setBaseLanguage("GB");
   Message message = validateForOneMessage(x);
   Object actual = message == null ? null : message.getText();
   assertEquals(LanguageResources.getString("Language.OptionMustBeSpecified"), actual);
 }
Example #2
0
  public void testValidShortOption() throws EQException {
    Function x = getValidFunction();
    x.setId("D"); // A short option

    Message message = validateForOneMessage(x);
    Object actual = message == null ? null : message.getText();
    assertEquals(null, actual);
  }
Example #3
0
  public void testMultipleMessages() {
    Function x = new Function();
    x.setModuleId("MOD");
    x.setBaseLanguage("GB");
    x.setId("DDD");

    MessageContainer messageContainer = new MessageContainer();
    x.validateBean(messageContainer, null, true);
    assertEquals(2, messageContainer.getMessageCount());
  }
Example #4
0
  /**
   * Ensure that a title longer than 35 characters results in the expected error message
   *
   * @throws EQException
   */
  public void testTitleTooLong() throws EQException {
    Function x = getValidFunction();
    x.setLabel("123456789012345678901234567890123456");

    Message message = validateForOneMessage(x);

    Object actual = message == null ? null : message.getText();
    assertEquals(
        LanguageResources.getString("Language.ServiceTitleCannotBeLongerThan35Characters"), actual);
  }
Example #5
0
  /** Ensure that a blank title results in the expected error message */
  public void testFunctionBlankTitle() {
    Function x = new Function();
    x.setModuleId("MOD");
    x.setId("DDD");

    Message message = validateForOneMessage(x);

    Object actual = message == null ? null : message.getText();
    assertEquals(LanguageResources.getString("Language.ServiceTitleMustBeEntered"), actual);
  }
Example #6
0
  public void testBaseLanguageMustBeEntered() {
    Function x = new Function();
    x.setModuleId("MOD");
    x.setId("DDD");
    x.setLabel("DDD label");
    x.setDescription("DDD description");

    Message message = validateForOneMessage(x);
    Object actual = message == null ? null : message.getText();
    assertEquals(LanguageResources.getString("Language.BaseLanguageMustBeEntered"), actual);
  }
Example #7
0
  public void testOptionTooLong() {
    Function x = new Function();
    x.setModuleId("MOD");
    x.setId("DDDD");

    Message message = validateForOneMessage(x);

    assertNotNull(message);
    assertEquals(
        LanguageResources.getString("Language.OptionCannotBeLongerThan3Characters"),
        message.getText());
  }
Example #8
0
  public void testInvalidCharactersInOption() {
    Function x = new Function();
    x.setModuleId("MOD");
    x.setBaseLanguage("GB");
    x.setId("D?D");
    Message message = validateForOneMessage(x);
    Object actual = message == null ? null : message.getText();
    assertEquals(LanguageResources.getString("Language.InvalidCharactersInOption"), actual);

    // Space
    x.setId("D D");
    message = validateForOneMessage(x);
    actual = message == null ? null : message.getText();
    assertEquals(LanguageResources.getString("Language.InvalidCharactersInOption"), actual);

    // Lower case
    x.setId("d D");
    message = validateForOneMessage(x);
    actual = message == null ? null : message.getText();
    assertEquals(LanguageResources.getString("Language.InvalidCharactersInOption"), actual);

    // Asterisk
    x.setId("* D");
    message = validateForOneMessage(x);
    actual = message == null ? null : message.getText();
    assertEquals(LanguageResources.getString("Language.InvalidCharactersInOption"), actual);
  }
Example #9
0
 /**
  * Creates and returns a valid Function object
  *
  * @return A valid Function object
  * @throws EQException
  */
 private Function getValidFunction() throws EQException {
   Function function = new Function();
   function.setModuleId("MOD");
   function.setBaseLanguage("GB");
   function.setId("DDD");
   function.setLabel("DDD label");
   function.setDescription("DDD description");
   InputFieldSet primary =
       new InputFieldSet(Function.PRIMARY_ID, Function.PRIMARY_ID, Function.PRIMARY_ID);
   InputField field1 = new InputField("FIELD1", "Field 1", "Field 1 Description");
   field1.setDataType(EqDataType.TYPE_CHAR);
   field1.setSize("10");
   primary.addInputField(field1);
   function.addInputFieldSet(primary);
   return function;
 }
Example #10
0
  private void test() {
    // Have a bash...
    try {
      // Create the FUNCTION
      Function function = new Function();
      function.setId("PVJ");
      function.setLabel("Prompt and Validate Test Stub");
      function.setDescription("Prompt and Validate Test Stub");

      // Records
      DisplayFieldSetWrapper setWrapper = getRecord1();
      function.addInputFieldSet(setWrapper.getInputFieldSet());

      Layout layout = new Layout(function, setWrapper.getDisplayAttributesSet());

      // Print the XML
      EqBeanFactory beanFactory = EqBeanFactory.getEqBeanFactory();
      String serviceXML = beanFactory.serialiseBeanAsXML(function);
      System.out.println(serviceXML);

      String layoutXML = beanFactory.serialiseBeanAsXML(layout);
      System.out.println(layoutXML);

      // Write to GAXPF
      XMLToolbox.getXMLToolbox()
          .writeDefinitionXMLtoDB(
              session,
              unit.getKFILLibrary(),
              GAXRecordDataModel.SERVICE_CODE,
              function.getId(),
              Toolbox.formatDate(Calendar.getInstance(), Toolbox.TIMESTAMP_FORMAT),
              serviceXML);

      // Write to GBXPF
      XMLToolbox.getXMLToolbox()
          .writeDefinitionXMLtoDB(
              session,
              unit.getKFILLibrary(),
              GAXRecordDataModel.LAYOUT_CODE,
              layout.getId(),
              Toolbox.formatDate(Calendar.getInstance(), Toolbox.TIMESTAMP_FORMAT),
              layoutXML);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Example #11
0
  /** Test error when the module id is not 3 characters: */
  public void testModuleId() {
    Function x = new Function();
    x.setId("DDD");
    x.setLabel("DDD label");
    x.setDescription("DDD description");

    // If blank
    Message message = validateForOneMessage(x);
    Object actual = message == null ? null : message.getText();
    assertEquals(
        LanguageResources.getFormattedString(
            "Langugae.ModuleIdMustBeThreeCharacters", x.getModuleId()),
        actual);

    // 2 chars:
    x.setModuleId("MO");
    message = validateForOneMessage(x);
    actual = message == null ? null : message.getText();
    assertEquals(
        LanguageResources.getFormattedString(
            "Langugae.ModuleIdMustBeThreeCharacters", x.getModuleId()),
        actual);
  }