ExportEventProcessor { protected boolean shouldProcessEntityType(Item item) throws SQLException { Entity entity = entityService.findByItemId(context, item.getID()); EntityType type = entityService.getType(context, entity); String[] entityTypeStrings = configurationService.getArrayProperty("irus.statistics.tracker.entity-types"); List<String> entityTypes = new ArrayList<>(); if (entityTypeStrings.length != 0) { entityTypes.addAll(Arrays.asList(entityTypeStrings)); } else { entityTypes.add(ENTITY_TYPE_DEFAULT); } if (type != null && entityTypes.contains(type.getLabel())) { return true; } return false; } ExportEventProcessor(Context context, HttpServletRequest request); abstract void processEvent();  }
@Test public void testShouldProcessEntityType() throws SQLException { context.turnOffAuthorisationSystem(); Community community = CommunityBuilder.createCommunity(context).build(); Collection collection = CollectionBuilder.createCollection(context, community).build(); Item item = ItemBuilder.createItem(context, collection).withRelationshipType(publication.getLabel()).build(); context.restoreAuthSystemState(); ExportEventProcessor exportEventProcessor = new ItemEventProcessor(context, request, item); boolean result = exportEventProcessor.shouldProcessEntityType(item); assertTrue(result); }
@Test public void testShouldProcessEntityTypeWhenNotInList() throws SQLException { context.turnOffAuthorisationSystem(); Community community = CommunityBuilder.createCommunity(context).build(); Collection collection = CollectionBuilder.createCollection(context, community).build(); Item item = ItemBuilder.createItem(context, collection).withRelationshipType(otherEntity.getLabel()).build(); context.restoreAuthSystemState(); ExportEventProcessor exportEventProcessor = new ItemEventProcessor(context, request, item); boolean result = exportEventProcessor.shouldProcessEntityType(item); assertFalse(result); }