private void assertContainsCaption( String caption, List<Item> items ) { boolean found = false; for ( Item item : items ) { if ( caption.equals( item.getCaption() ) ) { found = true; } } assertTrue( "Find caption", found ); }
@Test public void testContentInScopeNonProjectPath() throws Exception { final Bean explorerServiceBean = (Bean) beanManager.getBeans( ExplorerService.class ).iterator().next(); final CreationalContext cc = beanManager.createCreationalContext( explorerServiceBean ); final ExplorerService explorerService = (ExplorerService) beanManager.getReference( explorerServiceBean, ExplorerService.class, cc ); final URL testUrl = this.getClass().getResource( "/" ); final org.kie.commons.java.nio.file.Path testNioPath = fs.getPath( testUrl.toURI() ); final Path testPath = paths.convert( testNioPath ); //Depending on where this Test runs the actual results are undetermined as the VFS root is in a sub-folder on the hosts actual FS final ExplorerContent result = explorerService.getContentInScope( testPath ); assertNotNull( result ); assertTrue( result.getItems().size() > 0 ); assertTrue( result.getBreadCrumbs().size() > 0 ); //But there should be a single Project called 'ProjectStructureValid' boolean fail = true; for ( final Item item : result.getItems() ) { if ( item instanceof ProjectItem ) { assertEquals( "ExplorerBackendTestProjectStructureValid", item.getCaption() ); if ( fail == false ) { fail( "There should be only one ProjectItem called 'ProjectStructureValid'" ); } fail = false; } } }
items.get( 0 ).getCaption() ); assertEquals( "External imports", items.get( 1 ).getCaption() ); assertEquals( ItemNames.SOURCE_JAVA, items.get( 2 ).getCaption() ); assertEquals( ItemNames.SOURCE_RESOURCES, items.get( 3 ).getCaption() ); assertEquals( "..", items.get( 4 ).getCaption() );
items.get( 0 ).getCaption() ); assertEquals( "..", items.get( 1 ).getCaption() );