### Question:
ModelToIndexMapper { public final String createIndexDocument(Model model, XURI xuri) { Model massagedModel = massageModel(model, xuri); if (massagedModel.isEmpty()) { throw new RuntimeException("Massaged model of " + xuri.getUri() + " is empty"); } String json = null; try { json = GSON.toJson(applyContext(massagedModel, xuri.getTypeAsEntityType())); } catch (IOException | JsonLdError e) { throw new RuntimeException("Exception raised when applying context to json-ld", e); } return json; } ModelToIndexMapper(String type); final String createIndexDocument(Model model, XURI xuri); final Map<String, Object> createIndexObject(Model model, XURI xuri); static final Gson GSON; }### Answer:
@Test public void should_throw_runtime_exception_if_empty_massaged_model() throws Exception { expectedEx.expect(RuntimeException.class); String uri = "http: XURI xuri = new XURI(uri); expectedEx.expectMessage(uri); new ModelToIndexMapper("work").createIndexDocument(ModelFactory.createDefaultModel(), xuri); }
@Test public void should_throw_runtime_exception_if_framing_fails() throws Exception { expectedEx.expect(RuntimeException.class); String uri = "http: XURI xuri = new XURI(uri); expectedEx.expectMessage(uri); Model model = RDFModelUtil.modelFrom("{" + " \"@id\" : \"http: + " \"@type\" : \"deichman:Work\"," + " \"deichman:mainTitle\" : \"Test\"," + " \"@context\" : {" + " \"deichman\" : \"http: + " \"rdfs\" : \"http: + " }" + "}", Lang.JSONLD); ModelToIndexMapper modelToIndexMapper = new ModelToIndexMapper("work"); Class<?> clazz = modelToIndexMapper.getClass(); Field field = clazz.getDeclaredField("context"); field.setAccessible(true); field.set(modelToIndexMapper, new HashMap()); modelToIndexMapper.createIndexDocument(model, xuri); }