### Question:
InverseDefinitionParser implements DefinitionParser { @Override public ViewProperty getViewProperty(String definition, ViewProperty.Factory factory) { ViewProperty vp = factory.getImpl(definition); return new InverseProperty(vp); }  @Override Pattern pattern(); @Override ViewProperty getViewProperty(String definition, ViewProperty.Factory factory);  }### Answer:
@Test public void viewProperty_shortName_ReturnsShortName() { when(vp.shortName(ctx)).thenReturn("def"); String name = getViewProperty().shortName(ctx); assertEquals("~def", name); }
@Test public void viewProperty_asTriple_TransposesSubjectAndObject() { Any subject = mock(Any.class); Any object = mock(Any.class); VarSupply vars = mock(VarSupply.class); RDFQ.Triple triple = mock(RDFQ.Triple.class); when(vp.asTriple(object, subject, vars)).thenReturn(triple); RDFQ.Triple result = getViewProperty().asTriple(subject, object, vars); assertEquals(triple, result); }
@Test public void viewProperty_toString_PrefixesWithTilde() { when(vp.toString()).thenReturn("defn"); String result = getViewProperty().toString(); assertEquals("~defn", result); }
@Test public void viewProperty_asProperty_delegatesToViewProperty() { Property prop = getViewProperty().asProperty(); assertEquals(this.prop, prop); }