Example #1
0
 @Test
 public void testExtensionRenamingIsReversible() {
   Renaming r = Renaming.extension(sid, ssid, name, sname);
   assertTrue(r.isReversible());
   Renaming reverse = Renaming.extension(ssid, sid, sname, name);
   assertEquals(reverse, r.reverse());
 }
Example #2
0
  @Test
  public void testProjectOnExtension() {
    Renaming r = Renaming.extension(sid, ssid, name, sname);
    Renaming expected = Renaming.extension(name, sname);

    // it works with a subset of original attributes
    AttrList list = AttrList.attrs(name);
    Renaming got = r.project(list);
    assertEquals(expected, got);

    // it is robust to a superset too (city was not part of it)
    list = AttrList.attrs(name, city);
    got = r.project(list);
    assertEquals(expected, got);
  }
Example #3
0
 /**
  * Returns a new tuple by renaming some attributes.
  *
  * <p>Note: despite its visibility, this method is part of JAlf protected API. It should not be
  * used by end users. TODO: how to fix this without hurting performance too much?
  *
  * @param r renaming function mapping old to new attribute names.
  * @pre `resultingType` should be faithful to the actual result, that it it must guarantee the
  *     post condition.
  * @return the renamed tuple.
  * @post `resultingType.contains(rename(r, resultingType))` is true
  */
 public Tuple rename(Renaming r, TupleType resultingType) {
   return new Tuple(resultingType, rekey(attrs, (k, v) -> r.apply(k)));
 }
Example #4
0
 @Test
 public void testSuffixRenamingIsReversible() {
   Renaming r = Renaming.suffix("foo");
   assertTrue(r.isReversible());
   assertEquals(attr("sid"), r.reverse().apply(attr("sidfoo")));
 }
Example #5
0
 @Test
 public void testItSupportsSuffixRenaming() {
   Renaming r = Renaming.suffix("foo");
   assertEquals(r.apply(sid), attr("sidfoo"));
 }
Example #6
0
 @Test
 public void testItSupportsPrefixRenaming() {
   Renaming r = Renaming.prefix("foo");
   assertEquals(r.apply(sid), attr("foosid"));
 }
Example #7
0
 @Test
 public void testItSupportsIntensionRenaming() {
   AttrName SID = attr("SID");
   Renaming r = Renaming.intension(a -> attr(a.getName().toUpperCase()));
   assertEquals(r.apply(sid), SID);
 }
Example #8
0
 @Test
 public void testExtensionRenamingIsTotal() {
   Renaming r = Renaming.extension(sid, ssid, name, sname);
   assertEquals(r.apply(city), city);
 }
Example #9
0
 @Test
 public void testItSupportsExtensionRenaming() {
   Renaming r = Renaming.extension(sid, ssid, name, sname);
   assertEquals(r.apply(sid), ssid);
   assertEquals(r.apply(name), sname);
 }