コード例 #1
0
 @Test
 public void inputTest2() {
   m.updateSignature(2);
   String expected = "2";
   String result = m.getCurrentSignature();
   assertEquals(expected, result);
 }
コード例 #2
0
 // test deletion
 @Test
 public void deleteTest1() {
   // if there's nothing and we do a deletion, nothing happens
   m.removeLastSignature();
   assertTrue(m.getTexts().isEmpty());
   assertEquals("", m.getCurrentSignature());
 }
コード例 #3
0
 // test word entry
 @Test
 public void entryTest1() {
   m.updateSignature(2); // a
   m.insertWord();
   ArrayList<StringBuffer> expected = new ArrayList<StringBuffer>();
   expected.add(new StringBuffer("a"));
   ArrayList<StringBuffer> result = m.getTexts();
   for (int i = 0; i < expected.size(); i++) {
     assertEquals(expected.get(i).toString(), result.get(i).toString());
   }
 }
コード例 #4
0
  @Test
  public void testTermbindsIncludesMetaproperties() throws URISyntaxException {
    Integer totalResults = null;
    Resource thisMetaPage = createMetadata(false, totalResults);

    for (Property p : expectedTermboundProperties) {
      Model model = thisMetaPage.getModel();
      if (!model.contains(null, API.property, p)) {
        fail("term bindings should include " + model.shortForm(p.getURI()));
      }
    }
  }
コード例 #5
0
 @Test
 public void inputTest3() {
   m.updateSignature(2);
   m.updateSignature(9);
   m.updateSignature(8);
   m.updateSignature(9);
   m.updateSignature(8);
   m.updateSignature(3); // if we keep pressing when there's no more corresponding words,
   m.updateSignature(7); // the signature will not get updated
   String expected = "29898";
   String result = m.getCurrentSignature();
   assertEquals(expected, result);
 }
コード例 #6
0
 @Test
 public void deleteTest2() {
   m.updateSignature(2);
   m.updateSignature(7);
   m.updateSignature(7);
   m.updateSignature(5);
   m.updateSignature(3); // apple
   m.removeLastSignature();
   m.removeLastSignature();
   String expected = "277";
   String result = m.getCurrentSignature();
   assertEquals(expected, result);
 }
コード例 #7
0
 // test the selection cycle
 @Test
 public void cycleTest1() {
   this.m.updateSignature(2);
   String expected = "a";
   String result = m.getListOfPrefixes().get(0).toString();
   assertEquals(expected, result);
 }
コード例 #8
0
 @Test
 public void cycleTest2() {
   this.m.updateSignature(2);
   this.m.cyclePrefixSelection();
   String expected = "b";
   String result = m.getListOfPrefixes().get(1).toString();
   assertEquals(expected, result);
 }
コード例 #9
0
  /**
   * Check that a predicate for which no shortnames are defined in name map still gets a term
   * binding in the metadata.
   */
  @Test
  public void testTermBindingsCoverAllPredicates() throws URISyntaxException {
    Resource thisPage = ResourceFactory.createResource("elda:thisPage");
    String pageNumber = "1";
    Bindings cc = new Bindings();
    URI reqURI = new URI("");
    //
    EndpointDetails spec =
        new EndpointDetails() {

          @Override
          public boolean isListEndpoint() {
            return true;
          }

          @Override
          public boolean hasParameterBasedContentNegotiation() {
            return false;
          }
        };
    EndpointMetadata em = new EndpointMetadata(spec, thisPage, pageNumber, cc, reqURI);
    //
    PrefixMapping pm =
        PrefixMapping.Factory.create().setNsPrefix("this", "http://example.com/root#");
    Model toScan = ModelIOUtils.modelFromTurtle(":a <http://example.com/root#predicate> :b.");
    toScan.setNsPrefixes(pm);
    Resource predicate = toScan.createProperty("http://example.com/root#predicate");
    Model meta = ModelFactory.createDefaultModel();
    Resource exec = meta.createResource("fake:exec");
    ShortnameService sns = new StandardShortnameService();
    //		APIEndpoint.Request r = new APIEndpoint.Request( new Controls(), reqURI, cc );

    CompleteContext c =
        new CompleteContext(CompleteContext.Mode.PreferPrefixes, sns.asContext(), pm)
            .include(toScan);

    em.addTermBindings(toScan, meta, exec, c);

    @SuppressWarnings("unused")
    Map<String, String> termBindings = c.Do();
    Resource tb = meta.listStatements(null, API.termBinding, Any).nextStatement().getResource();
    assertTrue(meta.contains(tb, API.label, "this_predicate"));
    assertTrue(meta.contains(tb, API.property, predicate));
  }
コード例 #10
0
 @Test
 public void deleteTest3() {
   // if we do a deletion and there's no signature we are working on,
   // it should go back to the previously typed word
   m.updateSignature(2);
   m.updateSignature(3);
   m.insertWord();
   m.updateSignature(2);
   m.updateSignature(2);
   m.insertWord();
   m.removeLastSignature(); // this delete will go back to the previously
   // inserted word
   ArrayList<StringBuffer> expectedList = new ArrayList<StringBuffer>();
   expectedList.add(new StringBuffer("ad"));
   String expectedSig = "22";
   ArrayList<StringBuffer> resultList = m.getTexts();
   String resultSig = m.getCurrentSignature();
   for (int i = 0; i < expectedList.size(); i++) {
     assertEquals(expectedList.get(i).toString(), resultList.get(i).toString());
   }
   assertEquals(expectedSig, resultSig);
 }
コード例 #11
0
  private Resource createMetadata(final boolean isListEndpoint, Integer totalResults)
      throws URISyntaxException {
    Model objectModel = ModelFactory.createDefaultModel();
    MergedModels mergedModels = new MergedModels(objectModel);
    //
    Model meta = mergedModels.getMetaModel();
    //
    Resource thisMetaPage = meta.createResource("eh:/thisMetaPage");
    Resource SEP = meta.createResource("eh:/sparqlEndpoint");
    thisMetaPage.addProperty(API.sparqlEndpoint, SEP);

    Bindings bindings = new Bindings();
    URI ru = new URI(thisMetaPage.getURI());
    Resource uriForDefinition = objectModel.createResource(thisMetaPage.getURI());
    boolean suppressIPTO = true;
    int page = 1, perPage = 10;
    boolean hasMorePages = true;
    Context context = new Context();
    CompleteContext cc = new CompleteContext(Mode.PreferLocalnames, context, objectModel);
    //
    SetsMetadata setsMeta =
        new SetsMetadata() {

          @Override
          public void setMetadata(String type, Model meta) {}
        };
    WantsMetadata wantsMeta =
        new WantsMetadata() {

          @Override
          public boolean wantsMetadata(String name) {
            return true;
          }
        };
    //
    Map<String, View> views = new HashMap<String, View>();
    Set<FormatNameAndType> formats = new HashSet<FormatNameAndType>();
    //
    EndpointDetails details =
        new EndpointDetails() {

          @Override
          public boolean isListEndpoint() {
            return isListEndpoint;
          }

          @Override
          public boolean hasParameterBasedContentNegotiation() {
            return false;
          }
        };
    //
    EndpointMetadata.addAllMetadata(
        mergedModels,
        ru,
        uriForDefinition,
        bindings,
        cc,
        suppressIPTO,
        thisMetaPage,
        page,
        perPage,
        totalResults,
        hasMorePages,
        CollectionUtils.list(objectModel.createResource("eh:/item/_1")),
        setsMeta,
        wantsMeta,
        "SELECT",
        "VIEW",
        new TestCaches.FakeSource("Nemos"),
        views,
        formats,
        details);
    return thisMetaPage;
  }
コード例 #12
0
 // test that the input buttons work
 @Test
 public void inputTest1() {
   String expected = "";
   String result = m.getCurrentSignature();
   assertEquals(expected, result);
 }