### Question:
LdContext { public boolean contains(LdContext otherContext) { final boolean ret; if (!hasSameVocabAs(otherContext)) { ret = false; } else { ret = this.hasTermsOf(otherContext); } return ret; } LdContext(LdContext parentContext, String vocab, Map<String, Object> terms); boolean contains(LdContext otherContext); boolean hasSameVocabAs(LdContext otherContext); boolean hasTermsOf(LdContext otherContext); boolean hasEqualTerm(String term, Object value); final String vocab; final Map<String, Object> terms; }### Answer:
@Test public void allTermsContainsSomeTerms() throws Exception { assertTrue(contextWithAllTerms.contains(contextWithSomeTerms)); }
@Test public void someTermsDoesNotContainAllTerms() throws Exception { assertFalse(contextWithSomeTerms.contains(contextWithAllTerms)); }
@Test public void differentVocabMeansDifferenContext() throws Exception { LdContext contextWithDifferentVocab = new LdContext(null, "http: assertFalse(contextWithDifferentVocab.contains(contextWithAllTerms)); assertFalse(contextWithAllTerms.contains(contextWithDifferentVocab)); }
@Test public void considersVocabFromParent() { LdContext childContext = new LdContext(contextWithAllTerms, null, allTerms); assertTrue(childContext.contains(contextWithSomeTerms)); }
@Test public void considersTermsFromParent() { LdContext childContext = new LdContext(contextWithAllTerms, null, Collections.<String, Object>emptyMap()); assertTrue(childContext.contains(contextWithSomeTerms)); }