Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.kie.workbench.common.services.datamodel.backend.server;
  
  import java.net.URL;
  
  import org.junit.Before;
 import org.junit.Test;
 import  org.kie.commons.java.nio.fs.file.SimpleFileSystemProvider;
 import  org.kie.workbench.common.services.datamodel.oracle.PackageDataModelOracle;
 import  org.kie.workbench.common.services.datamodel.oracle.ProjectDataModelOracle;
 import  org.kie.workbench.common.services.datamodel.service.DataModelService;
 import  org.uberfire.backend.server.util.Paths;
 import  org.uberfire.backend.vfs.Path;
 
 import static org.junit.Assert.*;
 import static org.kie.workbench.common.services.datamodel.backend.server.DataModelOracleTestUtils.assertContains;

Tests for DataModelService
 
 public class DataModelSuperTypesTests {
 
     private final SimpleFileSystemProvider fs = new SimpleFileSystemProvider();
     private BeanManager beanManager;
     private Paths paths;
 
     @Before
     public void setUp() throws Exception {
         //Bootstrap WELD container
         StartMain startMain = new StartMainnew String[ 0 ] );
          = startMain.go().getBeanManager();
 
         //Instantiate Paths used in tests for Path conversion
         final Bean pathsBean = (Bean.getBeans( Paths.class ).iterator().next();
         final CreationalContext cc = .createCreationalContextpathsBean );
          = (Paths) .getReferencepathsBean,
                                                   Paths.class,
                                                   cc );
 
         //Ensure URLs use the default:// scheme
         .forceAsDefault();
     }
 
     @Test
     public void testPackageSuperTypes() throws Exception {
         final Bean dataModelServiceBean = (Bean.getBeans( DataModelService.class ).iterator().next();
         final CreationalContext cc = .createCreationalContextdataModelServiceBean );
         final DataModelService dataModelService = (DataModelService) .getReferencedataModelServiceBean,
                                                                                                DataModelService.class,
                                                                                                cc );
 
         final URL packageUrl = this.getClass().getResource"/DataModelBackendSuperTypesTest1/src/main/java/t2p1" );
         final org.kie.commons.java.nio.file.Path nioPackagePath = .getPath( packageUrl.toURI() );
         final Path packagePath = .convert( nioPackagePath );
 
         final PackageDataModelOracle oracle = dataModelService.getDataModel( packagePath );
 
         assertNotNulloracle );
 
         assertEquals( 3,
                       oracle.getFactTypes().length );
         assertContains"Bean1",
                         oracle.getFactTypes() );
         assertContains"Bean2",
                         oracle.getFactTypes() );
         assertContains"Bean4",
                         oracle.getFactTypes() );
 
         assertNulloracle.getSuperType( "Bean1" ) );
         assertEquals"Bean1",
                       oracle.getSuperType( "Bean2" ) );
         assertEquals"t2p2.Bean3",
                       oracle.getSuperType( "Bean4" ) );
     }
 
     @Test
     public void testProjectSuperTypes() throws Exception {
         final Bean dataModelServiceBean = (Bean.getBeans( DataModelService.class ).iterator().next();
         final CreationalContext cc = .createCreationalContextdataModelServiceBean );
         final DataModelService dataModelService = (DataModelService) .getReferencedataModelServiceBean,
                                                                                                DataModelService.class,
                                                                                                cc );
 
         final URL packageUrl = this.getClass().getResource"/DataModelBackendSuperTypesTest1/src/main/java/t2p1" );
         final org.kie.commons.java.nio.file.Path nioPackagePath = .getPath( packageUrl.toURI() );
         final Path packagePath = .convert( nioPackagePath );
 
         final ProjectDataModelOracle oracle = dataModelService.getProjectDataModel( packagePath );
 
         assertNotNulloracle );
 
         assertEquals( 4,
                       oracle.getFactTypes().length );
         assertContains"t2p1.Bean1",
                         oracle.getFactTypes() );
         assertContains"t2p1.Bean2",
                        oracle.getFactTypes() );
        assertContains"t2p2.Bean3",
                        oracle.getFactTypes() );
        assertContains"t2p1.Bean4",
                        oracle.getFactTypes() );
        assertNulloracle.getSuperType( "t2p1.Bean1" ) );
        assertEquals"t2p1.Bean1",
                      oracle.getSuperType( "t2p1.Bean2" ) );
        assertEquals"t2p1.Bean1",
                      oracle.getSuperType( "t2p2.Bean3" ) );
        assertEquals"t2p2.Bean3",
                      oracle.getSuperType( "t2p1.Bean4" ) );
    }
New to GrepCode? Check out our FAQ X