Beispiel #1
0
  public String getEnumType(String enumType, String fieldTitle) {

    try {
      EnumerationBean enumBean = EnumerationType.getEnu(enumType);

      // Iterator keys=enumBean.getEnu().keySet().iterator();
      Object[] keys = enumBean.getKeys().toArray();

      StringBuffer StrBuf = new StringBuffer();

      String[] fieldTitlearr = fieldTitle.split(",");

      StrBuf.append(
          "<table id='Data_dropDown' class=\"dropDownTable\"  width='100%' border='0'  cellspacing='1' cellpadding='1' >");

      StrBuf.append("<tr height='20'   class=\"dropDownHead\" >");

      for (int i = 0; i < fieldTitlearr.length; i++) {
        StrBuf.append("<td align=\"center\">" + fieldTitlearr[i] + "</td> ");
      }
      StrBuf.append("</tr>");

      for (int i = 0; i < keys.length; i++) {
        Object key = keys[i];

        StrBuf.append("<tr  onclick=\"TRClick(this)\" height='20' class=\"gridEvenRow\">");
        String[] enumStr = ((String) enumBean.getValue(key)).split(";");
        StrBuf.append("<td  align =\"left\" >" + key.toString() + "</td>");
        StrBuf.append("<td  align =\"left\" >" + enumStr[0] + "</td>");
        StrBuf.append("</tr>");
      }
      StrBuf.append("</table>");

      return StrBuf.toString();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "";
  }
  @Test
  public void canCreateEnumerationType() {
    MockitoAnnotations.initMocks(this);

    QName qName = QName.create("TestQName");
    SchemaPath schemaPath = SchemaPath.create(Collections.singletonList(qName), true);

    List<EnumTypeDefinition.EnumPair> listEnumPair = Collections.singletonList(enumPair);
    Optional<EnumTypeDefinition.EnumPair> defaultValue = Optional.of(enumPair);

    EnumerationType enumerationType =
        EnumerationType.create(schemaPath, listEnumPair, defaultValue);

    assertNotEquals("Description is not null", null, enumerationType.getDescription());
    assertEquals("QName", BaseTypes.ENUMERATION_QNAME, enumerationType.getQName());
    assertEquals("Should be empty string", "", enumerationType.getUnits());
    assertNotEquals("Description should not be null", null, enumerationType.toString());
    assertNotEquals("Reference is not null", null, enumerationType.getReference());
    assertEquals("BaseType should be null", null, enumerationType.getBaseType());
    assertEquals("Default value should be enumPair", enumPair, enumerationType.getDefaultValue());
    assertEquals("getPath should equal schemaPath", schemaPath, enumerationType.getPath());
    assertEquals("Status should be CURRENT", Status.CURRENT, enumerationType.getStatus());
    assertEquals(
        "Should be empty list", Collections.EMPTY_LIST, enumerationType.getUnknownSchemaNodes());
    assertEquals("Values should be [enumPair]", listEnumPair, enumerationType.getValues());

    assertEquals(
        "Hash code of enumerationType should be equal",
        enumerationType.hashCode(),
        enumerationType.hashCode());
    assertNotEquals("EnumerationType shouldn't equal to null", null, enumerationType);
    assertEquals("EnumerationType should equals to itself", enumerationType, enumerationType);
    assertNotEquals(
        "EnumerationType shouldn't equal to object of other type", "str", enumerationType);
  }