PdpPolicyContainer extends PolicyItemSetChangeNotifier implements PolicyContainer.Indexed { @SuppressWarnings("unchecked") public PdpPolicyContainer(Object data) { super(); this.data = data; if (this.data instanceof PDPGroup) { policies = new ArrayList<>(((PDPGroup) this.data).getPolicies()); } if (this.data instanceof PDP) { policies = new ArrayList<>(((PDP) this.data).getPolicies()); } if (this.data instanceof Set) { policies = new ArrayList<>((Set<PDPPolicy>) data); } if (this.policies == null) { LOGGER.info("NULL policies"); throw new NullPointerException("PDPPolicyContainer created with unexpected Object type '" + data.getClass().getName() + "'"); } this.setContainer(this); } @SuppressWarnings("unchecked")  PdpPolicyContainer(Object data); @Override Object nextItemId(Object itemId); @Override Object prevItemId(Object itemId); @Override Object firstItemId(); @Override Object lastItemId(); @Override boolean isFirstId(Object itemId); @Override boolean isLastId(Object itemId); @Override Object addItemAfter(Object previousItemId); @Override Collection<?> getContainerPropertyIds(); @Override Collection<?> getItemIds(); @Override List<?> getItemIds(int startIndex, int numberOfItems); @Override Class<?> getType(Object propertyId); @Override int size(); @Override boolean containsId(Object itemId); @Override Object addItem(); @Override boolean removeItem(Object itemId); @Override boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue); @Override boolean removeContainerProperty(Object propertyId); @Override boolean removeAllItems(); @Override int indexOfId(Object itemId); @Override Object getIdByIndex(int index); @Override Object addItemAt(int index);  }
@Test public void testPdpPolicyContainer() { container.nextItemId(policy); container.prevItemId(policy); container.firstItemId(); container.lastItemId(); container.isFirstId(policy); container.isLastId(policy); container.addItemAfter(policy); container.getContainerPropertyIds(); container.getItemIds(); container.getType("Id"); assertNull(container.getType("NonExistant")); assertTrue(String.class.equals(String.class)); container.getType("Name"); assertTrue(String.class.equals(String.class)); container.getType("Version"); assertTrue(String.class.equals(String.class)); container.getType("Description"); assertTrue(String.class.equals(String.class)); container.getType("Root"); assertTrue(Boolean.class.equals(Boolean.class)); assertTrue(container.size() == 1); container.containsId(policy); container.removeItem(policy); container.addContainerProperty(null, null, null); container.removeContainerProperty(policy); container.removeAllItems(); assertFalse(container.isFirstId(policy)); assertFalse(container.isLastId(policy)); assertNull(container.firstItemId()); assertNull(container.lastItemId()); assertNull(container.prevItemId(policy)); assertThatThrownBy(() -> container.getItemIds(0, -1)).isInstanceOf(IllegalArgumentException.class); container.addItemAt(0); }