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.drools.workbench.models.datamodel.oracle.ProjectDataModelOracle;
 import  org.jboss.weld.environment.se.StartMain;
import  org.kie.workbench.common.services.datamodel.backend.server.service.DataModelService;
import  org.uberfire.backend.server.util.Paths;
import  org.uberfire.backend.vfs.Path;
import  org.uberfire.java.nio.fs.file.SimpleFileSystemProvider;
import static org.junit.Assert.*;
import static org.kie.workbench.common.services.datamodel.backend.server.ProjectDataModelOracleTestUtils.*;

Tests for DataModelService
    private final SimpleFileSystemProvider fs = new SimpleFileSystemProvider();
    private BeanManager beanManager;
    private Paths paths;
    @Before
    public void setUp() throws Exception {
        //Bootstrap WELD container
        StartMain startMain = new StartMain( new 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
        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"/DataModelBackendExtendJavaTypeTest1" );
        final org.uberfire.java.nio.file.Path nioPackagePath = .getPath( packageUrl.toURI() );
        final Path packagePath = .convert( nioPackagePath );
        final ProjectDataModelOracle oracle = dataModelService.getProjectDataModel( packagePath );
        assertNotNulloracle );
        assertEquals( 1,
                      oracle.getProjectModelFields().size() );
        assertContains"t4p1.Bean1",
                        oracle.getProjectModelFields().keySet() );
        assertTrueoracle.getProjectEventTypes().get( "t4p1.Bean1" ) );
    }
    @Test
    public void testProjectExtendJavaTypeWithImport() 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"/DataModelBackendExtendJavaTypeTest2" );
        final org.uberfire.java.nio.file.Path nioPackagePath = .getPath( packageUrl.toURI() );
        final Path packagePath = .convert( nioPackagePath );
        final ProjectDataModelOracle oracle = dataModelService.getProjectDataModel( packagePath );
        assertNotNulloracle );
        assertEquals( 1,
                      oracle.getProjectModelFields().size() );
        assertContains"t5p1.Bean1",
                        oracle.getProjectModelFields().keySet() );
        assertTrueoracle.getProjectEventTypes().get( "t5p1.Bean1" ) );
    }
New to GrepCode? Check out our FAQ X