Dashboard extends BaseNameableObject implements MetadataObject { public DashboardItem getAvailableItemByType( DashboardItemType type ) { for ( DashboardItem item : items ) { if ( type.equals( item.getType() ) && item.getContentCount() < DashboardItem.MAX_CONTENT ) { return item; } } return null; } Dashboard();  Dashboard( String name ); boolean moveItem( String uid, int position ); DashboardItem getItemByUid( String uid ); DashboardItem getAvailableItemByType( DashboardItemType type ); boolean hasItems(); @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) int getItemCount(); @JsonProperty( "dashboardItems" ) @JsonSerialize( contentAs = BaseIdentifiableObject.class ) @JacksonXmlElementWrapper( localName = "dashboardItems", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "dashboardItem", namespace = DxfNamespaces.DXF_2_0 ) List<DashboardItem> getItems(); void setItems( List<DashboardItem> items ); static final int MAX_ITEMS; }
@Test public void testGetAvailableItemByType() { Dashboard dashboard = new Dashboard(); DashboardItem diA = new DashboardItem(); DashboardItem diB = new DashboardItem(); DashboardItem diC = new DashboardItem(); diA.setUid( "A" ); diB.setUid( "B" ); diC.setUid( "C" ); diA.setVisualization( new Visualization ( "A" ) ); diB.getReports().add( new Report( "A", null, null, new Visualization() ) ); diB.getReports().add( new Report( "B", null, null, new Visualization() ) ); diC.getResources().add( new Document( "A", null, false, null ) ); diC.getResources().add( new Document( "B", null, false, null ) ); diC.getResources().add( new Document( "C", null, false, null ) ); dashboard.getItems().add( diA ); dashboard.getItems().add( diB ); dashboard.getItems().add( diC ); assertEquals( diB, dashboard.getAvailableItemByType( DashboardItemType.REPORTS ) ); assertEquals( diC, dashboard.getAvailableItemByType( DashboardItemType.RESOURCES ) ); assertNull( dashboard.getAvailableItemByType( DashboardItemType.MAP ) ); }