Ejemplo n.º 1
0
 private JSONObject makeJson() {
   response.setContentType("text/json");
   JSONObject jsonObject = new JSONObject();
   String attributes[] =
       new String[] {
         TEST.toString(),
         PropertySEARCH,
         PropertyEDIT,
         PropertyPROPERTIES,
         PropertyVERSIONS,
         PropertyREFACTOR,
         PropertyWHERE_USED,
         PropertyRECENT_CHANGES,
         SUITE.toString(),
         PropertyPRUNE,
         PropertySECURE_READ,
         PropertySECURE_WRITE,
         PropertySECURE_TEST,
         PropertyFILES
       };
   for (String attribute : attributes) addJsonAttribute(jsonObject, attribute);
   if (pageData.hasAttribute(PropertyHELP)) {
     jsonObject.put(PropertyHELP, pageData.getAttribute(PropertyHELP));
   }
   if (pageData.hasAttribute(PropertySUITES)) {
     JSONArray tags = new JSONArray();
     for (String tag : pageData.getAttribute(PropertySUITES).split(",")) {
       if (StringUtils.isNotBlank(tag)) {
         tags.put(tag.trim());
       }
     }
     jsonObject.put(PropertySUITES, tags);
   }
   return jsonObject;
 }
Ejemplo n.º 2
0
 @Test
 public void testDefaultAttributesForSuitePageNames() throws Exception {
   WikiPage suitePage3 = WikiPageUtil.addPage(root, PathParser.parse("TestPageSuite"));
   PageData data = suitePage3.getData();
   assertFalse(data.hasAttribute(TEST.toString()));
   assertTrue(data.hasAttribute(SUITE.toString()));
 }
Ejemplo n.º 3
0
 @Test
 public void testThatTestAtEndOfNameSetsTestProperty() throws Exception {
   WikiPage testPage2 = WikiPageUtil.addPage(root, PathParser.parse("PageTest"));
   PageData data = testPage2.getData();
   assertTrue(data.hasAttribute(TEST.toString()));
   assertFalse(data.hasAttribute(SUITE.toString()));
 }
Ejemplo n.º 4
0
 @Test
 public void testThatSuiteAtBeginningOfNameSetsSuiteProperty() throws Exception {
   WikiPage suitePage1 = WikiPageUtil.addPage(root, PathParser.parse("SuitePage"));
   PageData data = suitePage1.getData();
   assertFalse(data.hasAttribute(TEST.toString()));
   assertTrue(data.hasAttribute(SUITE.toString()));
 }
Ejemplo n.º 5
0
 @Test
 public void testDefaultAttributesForNormalPageNames() throws Exception {
   WikiPage normalPage = WikiPageUtil.addPage(root, PathParser.parse("NormalPage"));
   PageData data = normalPage.getData();
   assertTrue(data.hasAttribute(PropertyEDIT));
   assertTrue(data.hasAttribute(PropertySEARCH));
   assertTrue(data.hasAttribute(PropertyVERSIONS));
   assertTrue(data.hasAttribute(PropertyFILES));
   assertFalse(data.hasAttribute(TEST.toString()));
   assertFalse(data.hasAttribute(SUITE.toString()));
 }
Ejemplo n.º 6
0
  public static PageType fromWikiPage(WikiPage page) {
    PageData data = page.getData();
    if (data.hasAttribute(SUITE.toString())) {
      return SUITE;
    }

    if (data.hasAttribute(TEST.toString())) {
      return TEST;
    }

    return STATIC;
  }
Ejemplo n.º 7
0
  private JSONObject makeJson() {
    response.setContentType("text/json");
    JSONObject jsonObject = new JSONObject();
    String attributes[] =
        new String[] {
          TEST.toString(),
          PropertySEARCH,
          PropertyEDIT,
          PropertyPROPERTIES,
          PropertyVERSIONS,
          PropertyREFACTOR,
          PropertyWHERE_USED,
          PropertyRECENT_CHANGES,
          SUITE.toString(),
          PropertyPRUNE,
          PropertySECURE_READ,
          PropertySECURE_WRITE,
          PropertySECURE_TEST
        };
    for (String attribute : attributes) addJsonAttribute(jsonObject, attribute);

    return jsonObject;
  }
Ejemplo n.º 8
0
 @Test
 public void testThatExampleAtEndOfNameSetsTestProperty() throws Exception {
   WikiPage page = WikiPageUtil.addPage(root, PathParser.parse("PageExample"));
   PageData data = page.getData();
   assertTrue(data.hasAttribute(TEST.toString()));
 }