Ejemplo n.º 1
0
 private static void assertTypesEquality(
     FakeExtDocElement expected, ExtDocTypeSimpleElement element) {
   if (expected.getProperty("type").indexOf("|") != -1) {
     String[] splitedType = expected.getProperty("type").split("[|]");
     for (int i = 0; i < splitedType.length; i++) {
       assertEquals(splitedType[i], element.getDeclaredTypes().get(i).getType());
     }
   } else {
     assertEquals(expected.getProperty("type"), element.getDeclaredTypes().get(0).getType());
   }
 }
Ejemplo n.º 2
0
 /** The string should look like: <type>||<key1>=<value1>:<key2>=<value2>;<type> */
 private static List<ExtDocElement> parseExpected(String expected) {
   List<ExtDocElement> elements = new ArrayList<ExtDocElement>();
   String[] tags = expected.split("[;]+");
   for (String tag : tags) {
     String[] tmp = tag.split("[|][|]");
     FakeExtDocElement element = new FakeExtDocElement(ExtDocElementType.fromString(tmp[0]));
     if (tmp.length > 1) {
       String[] keyValues = tmp[1].split("[:]+");
       for (String keyValue : keyValues) {
         String[] items = keyValue.split("[=]+");
         if (items.length == 1) {
           // in context sensitive cases
           element.addProperty("desc", items[0]);
         } else {
           element.addProperty(items[0], items[1]);
         }
       }
     }
     elements.add(element);
   }
   return elements;
 }
Ejemplo n.º 3
0
 /**
  * Examples of expected values:
  *
  * @private
  * @alias <ident>
  * @class <ident> <desc>
  * @type <type>
  * @return <type> <desc>
  * @param <type> <name> <desc>
  */
 private static void assertElementEquality(FakeExtDocElement expected, ExtDocElement parsed) {
   assertEquals(expected.getType(), parsed.getType());
   switch (parsed.getType().getCategory()) {
     case IDENT_SIMPLE:
       assertTrue(parsed instanceof ExtDocIdentSimpleElement);
       ExtDocIdentSimpleElement identSimpleElement = (ExtDocIdentSimpleElement) parsed;
       assertEquals(expected.getProperty("ident"), identSimpleElement.getIdentifier());
       break;
     case IDENT_DESCRIBED:
       assertTrue(parsed instanceof ExtDocIdentDescribedElement);
       ExtDocIdentDescribedElement identDescribedElement = (ExtDocIdentDescribedElement) parsed;
       assertEquals(expected.getProperty("ident"), identDescribedElement.getIdentifier());
       assertEquals(expected.getProperty("desc"), identDescribedElement.getDescription());
       break;
     case DESCRIPTION:
       assertTrue(parsed instanceof ExtDocDescriptionElement);
       ExtDocDescriptionElement descElement = (ExtDocDescriptionElement) parsed;
       assertEquals(expected.getProperty("desc"), descElement.getDescription());
       break;
     case SIMPLE:
       assertTrue(parsed instanceof ExtDocSimpleElement);
       break;
     case UNKNOWN:
       assertTrue(parsed instanceof ExtDocDescriptionElement);
       break;
     case TYPE_SIMPLE:
       assertTrue(parsed instanceof ExtDocTypeSimpleElement);
       ExtDocTypeSimpleElement typeSimpleElement = (ExtDocTypeSimpleElement) parsed;
       assertTypesEquality(expected, typeSimpleElement);
       break;
     case TYPE_DESCRIBED:
       assertTrue(parsed instanceof ExtDocTypeDescribedElement);
       ExtDocTypeDescribedElement typeDescElement = (ExtDocTypeDescribedElement) parsed;
       assertEquals(expected.getProperty("desc"), typeDescElement.getTypeDescription());
       assertTypesEquality(expected, typeDescElement);
       break;
     case TYPE_NAMED:
       assertTrue(parsed instanceof ExtDocTypeNamedElement);
       ExtDocTypeNamedElement typeNamedElement = (ExtDocTypeNamedElement) parsed;
       assertEquals(expected.getProperty("name"), typeNamedElement.getTypeName().getName());
       assertEquals(expected.getProperty("desc"), typeNamedElement.getTypeDescription());
       assertTypesEquality(expected, typeNamedElement);
       break;
     default:
       throw new AssertionError();
   }
 }