@Test public void testDecorateBasicPDF() throws IOException, ParserConfigurationException, SAXException, LexerException, SecurityException, NoSuchMethodException, JSONException { StatisticsAccessLog aclog = EasyMock .createMock(StatisticsAccessLog.class); ProcessingIndexFeeder feeder = createMock(ProcessingIndexFeeder.class); CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder().build(); cacheManager.init(); HazelcastServerNode.ensureHazelcastNode(); FedoraAccessAkubraImpl fa = createMockBuilder(FedoraAccessAkubraImpl.class) .withConstructor(KConfiguration.getInstance(), feeder, aclog, cacheManager) .addMockedMethod("isStreamAvailable") .addMockedMethod("getRelsExt") .createMock(); SolrAccess sa = createMockBuilder(SolrAccessImpl.class) .addMockedMethod( SolrAccess.class.getMethod("request", String.class, String.class)) .addMockedMethod("getSolrDataDocument").createMock(); solrDataDocument(sa, DataPrepare.DROBNUSTKY_PIDS[0] + "/@2"); SolrMemoization memo = EasyMock.createMock(SolrMemoization.class); solrMemoPrepare(memo, DataPrepare.DROBNUSTKY_PIDS[0] + "/@2"); HttpServletRequest request = EasyMock .createMock(HttpServletRequest.class); EasyMock.expect(request.getRequestURL()) .andReturn( new StringBuffer( "http: + DataPrepare.DROBNUSTKY_PIDS[0])) .anyTimes(); EasyMock.expect(request.getHeader("x-forwarded-host")).andReturn(null) .anyTimes(); HttpServletResponse response = EasyMock .createMock(HttpServletResponse.class); replay(fa, aclog, sa, memo, request, response); Injector injector = Guice.createInjector(new JSONDecTestModule(sa, memo, fa, request, response)); JSONDecoratorsAggregate aggregate = injector .getInstance(JSONDecoratorsAggregate.class); List<JSONDecorator> list = aggregate.getDecorators(); String pid = DataPrepare.DROBNUSTKY_PIDS[0] + "/@2"; String basicUrl = ItemResource.basicURL(pid); JSONObject jsonObject = new JSONObject(); jsonObject.put("pid", pid); jsonObject.put("model", "page"); Map<String, Object> context = new HashMap<String, Object>(); for (JSONDecorator jsonDec : list) { if (jsonDec.apply(jsonObject, basicUrl)) { jsonDec.decorate(jsonObject, context); } } Assert.assertTrue(jsonObject.has("title")); Assert.assertTrue(jsonObject.getString("title").equals("Drobnůstky")); Assert.assertTrue(jsonObject.has("root_title")); Assert.assertTrue(jsonObject.getString("root_title").equals( "Drobnůstky")); }
public List<JSONDecorator> getDecorators() { List<JSONDecorator> decorators = new ArrayList<JSONDecorator>(); for (String k : this.keys) { decorators.add(this.decoratorsMap.get(k)); } return decorators; }
JSONDecoratorsAggregate { public List<JSONDecorator> getDecorators() { List<JSONDecorator> decorators = new ArrayList<JSONDecorator>(); for (String k : this.keys) { decorators.add(this.decoratorsMap.get(k)); } return decorators; } }
JSONDecoratorsAggregate { public List<JSONDecorator> getDecorators() { List<JSONDecorator> decorators = new ArrayList<JSONDecorator>(); for (String k : this.keys) { decorators.add(this.decoratorsMap.get(k)); } return decorators; } @Inject  JSONDecoratorsAggregate(Set<JSONDecorator> decs); }
JSONDecoratorsAggregate { public List<JSONDecorator> getDecorators() { List<JSONDecorator> decorators = new ArrayList<JSONDecorator>(); for (String k : this.keys) { decorators.add(this.decoratorsMap.get(k)); } return decorators; } @Inject  JSONDecoratorsAggregate(Set<JSONDecorator> decs); List<JSONDecorator> getDecorators(); }
JSONDecoratorsAggregate { public List<JSONDecorator> getDecorators() { List<JSONDecorator> decorators = new ArrayList<JSONDecorator>(); for (String k : this.keys) { decorators.add(this.decoratorsMap.get(k)); } return decorators; } @Inject  JSONDecoratorsAggregate(Set<JSONDecorator> decs); List<JSONDecorator> getDecorators();  }