### Question:
InternalPartDecorate extends  AbstractDetailDecorator { @Override public void decorate(JSONObject jsonObject, Map<String, Object> runtimeContext) { if (jsonObject.has("pid")) { try { String pid = jsonObject.getString("pid"); Element doc = this.memo.getRememberedIndexedDoc(pid); if (doc == null) { doc = this.memo.askForIndexDocument(pid); } if (doc != null) { List<String> array = SOLRUtils.array(doc, "details", String.class); if (!array.isEmpty()) { String[] details = super.details(array.get(0)); JSONObject detailsJSONObject = new JSONObject(); if (details.length > 0) { detailsJSONObject.put("pagenumber", ItemResourceUtils.preventAutomaticConversion(details[0])); } if (details.length > 1) { detailsJSONObject.put("type", details[1]); } if (details.length > 2) { detailsJSONObject.put("title", details[2]); } if (details.length > 3) { detailsJSONObject.put("pageRange", details[3]); } boolean moreThanZero = detailsJSONObject.keys().hasNext(); if (moreThanZero) { jsonObject.put("details", detailsJSONObject); } } } } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); throw new GenericApplicationException(e.getMessage()); } catch (JSONException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); throw new GenericApplicationException(e.getMessage()); } } }  @Override String getKey(); @Override void decorate(JSONObject jsonObject, Map<String, Object> runtimeContext); @Override boolean apply(JSONObject jsonObject, String context); static final String INTERNALPART; }### Answer:
@Test public void testDecorator() throws IOException, ParserConfigurationException, SAXException, JSONException, TransformerException { URL res = InternalPartDecorateTest.class.getResource("solr-internalpart.xml"); Document document = XMLUtils.parseDocument(res.openStream(), true); SolrMemoizationImpl memoization = new SolrMemoizationImpl(); SolrAccess sa = EasyMock.createMock(SolrAccess.class); EasyMock.expect(sa.getSolrDataDocument("uuid:0bf8e0f3-9c1a-40ca-a23f-c8a52e9e0359")).andReturn(document).anyTimes(); EasyMock.replay(sa); InternalPartDecorate dec = new InternalPartDecorate(); dec.solrAccess = sa; dec.memo = memoization; memoization.setSolrAccess(sa); JSONObject jsonObject = new JSONObject(); jsonObject.put("pid", "uuid:0bf8e0f3-9c1a-40ca-a23f-c8a52e9e0359"); Map<String, Object> runtimeContext = new HashMap<String, Object>(); dec.decorate(jsonObject, runtimeContext); Assert.assertNotNull(jsonObject.getJSONObject("details")); Assert.assertNotNull(jsonObject.getJSONObject("details").getString("pageRange")); Assert.assertNotNull(jsonObject.getJSONObject("details").getString("type")); Assert.assertNotNull(jsonObject.getJSONObject("details").getString("title")); }