package com.github.jsonldjava.core;

import org.junit.Test;

import com.google.common.collect.ImmutableMap;

public class ContextTest {

    @Test
    public void testRemoveBase() {
        // TODO: test if Context.removeBase actually works
    }

    // See https://github.com/jsonld-java/jsonld-java/issues/141

    @Test(expected = JsonLdError.class)
    public void testIssue141_errorOnEmptyKey_compact() {
        JsonLdProcessor.compact(ImmutableMap.of(),
                ImmutableMap.of("","http://example.com"), new JsonLdOptions());
    }

    @Test(expected = JsonLdError.class)
    public void testIssue141_errorOnEmptyKey_expand() {
        JsonLdProcessor.expand(ImmutableMap.of("@context",
                ImmutableMap.of("","http://example.com")), new JsonLdOptions());
    }

    @Test(expected = JsonLdError.class)
    public void testIssue141_errorOnEmptyKey_newContext1() {
        new Context(ImmutableMap.of("","http://example.com"));
    }

    @Test(expected = JsonLdError.class)
    public void testIssue141_errorOnEmptyKey_newContext2() {
        new Context(ImmutableMap.of("","http://example.com"), new JsonLdOptions());
    }

}

@@ -30,16 +30,133 @@
 .core;%0A%0A
+import static org.junit.Assert.assertEquals;%0A%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0A
 import o
@@ -1265,10 +1265,1543 @@
 %0A    %7D%0A%0A
+    /* schema.org documentation says some properties can be either Text or URL,%0A     * but sets %60@type : @id%60 in the context, e.g. for https://schema.org/roleName:%0A     */%0A    Map%3CString,Object%3E schemaOrg =%0A            ImmutableMap.of(%22roleName%22, ImmutableMap.of(%22@id%22, %22http://schema.org/roleName%22, %22@type%22, %22@id%22));%0A%0A    // See https://github.com/jsonld-java/jsonld-java/issues/248%0A%0A    @Test(expected = IllegalArgumentException.class)%0A    public void testCompact_uriExpected() throws Exception %7B%0A        JsonLdProcessor.expand(ImmutableMap.of(%22roleName%22, %22Production Company%22, %22@context%22, schemaOrg));%0A    %7D%0A%0A    @Test%0A    public void testCompact_forceValue() throws Exception %7B%0A        List%3C?%3E value = Arrays.asList(ImmutableMap.of(%22@value%22, %22Production Company%22));%0A        Map%3CString, Object%3E input = ImmutableMap.of(%22roleName%22, value, %22@context%22, schemaOrg);%0A        Object output = JsonLdProcessor.expand(input);%0A        assertEquals(%22%5B%7Bhttp://schema.org/roleName=%5B%7B@value=Production Company%7D%5D%7D%5D%22, output.toString());%0A    %7D%0A%0A    @Test%0A    public void testCompact_overrideContext() throws Exception %7B%0A        List%3C?%3E context = Arrays.asList(schemaOrg,%0A                ImmutableMap.of(%22roleName%22, ImmutableMap.of(%22@id%22, %22http://schema.org/roleName%22)));%0A        Map%3CString, Object%3E input = ImmutableMap.of(%22roleName%22, %22Production Company%22, %22@context%22, context);%0A        Object output = JsonLdProcessor.expand(input);%0A        assertEquals(%22%5B%7Bhttp://schema.org/roleName=%5B%7B@value=Production Company%7D%5D%7D%5D%22, output.toString());%0A    %7D%0A%0A
 %7D%0A

Add tests to show workarounds for #248