Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.kie.workbench.common.services.datamodel.backend.server;
 
 import java.util.Map;
 import java.util.Set;
 
 import  org.drools.workbench.models.commons.backend.oracle.ProjectDataModelOracleImpl;
 import  org.drools.workbench.models.datamodel.oracle.Annotation;
 import  org.drools.workbench.models.datamodel.oracle.TypeSource;
 import org.junit.Test;
import static org.junit.Assert.*;
import static org.kie.workbench.common.services.datamodel.backend.server.ProjectDataModelOracleTestUtils.*;

Tests for Fact's annotations
    @Test
    public void testProjectDMOZeroAnnotationAttributes() throws Exception {
        final ProjectDataModelOracleBuilder builder = ProjectDataModelOracleBuilder.newProjectOracleBuilder();
        final ProjectDataModelOracleImpl oracle = new ProjectDataModelOracleImpl();
        final ClassFactBuilder cb = new ClassFactBuilderbuilder,
                                                          Product.class,
                                                          false,
                                                          TypeSource.JAVA_PROJECT );
        cb.buildoracle );
        assertEquals( 1,
                      oracle.getProjectModelFields().size() );
        assertContains"org.kie.workbench.common.services.datamodel.backend.server.testclasses.Product",
                        oracle.getProjectModelFields().keySet() );
        final Map<StringSet<Annotation>> fieldAnnotations = oracle.getProjectTypeFieldsAnnotations().get( "org.kie.workbench.common.services.datamodel.backend.server.testclasses.Product" );
        assertNotNullfieldAnnotations );
        assertEquals( 0,
                      fieldAnnotations.size() );
    }
    @Test
    public void testProjectDMOAnnotationAttributes() throws Exception {
        final ProjectDataModelOracleBuilder builder = ProjectDataModelOracleBuilder.newProjectOracleBuilder();
        final ProjectDataModelOracleImpl oracle = new ProjectDataModelOracleImpl();
        final ClassFactBuilder cb = new ClassFactBuilderbuilder,
                                                          SmurfHouse.class,
                                                          false,
                                                          TypeSource.JAVA_PROJECT );
        cb.buildoracle );
        assertEquals( 1,
                      oracle.getProjectModelFields().size() );
        assertContains"org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.SmurfHouse",
                        oracle.getProjectModelFields().keySet() );
        final Map<StringSet<Annotation>> fieldsAnnotations = oracle.getProjectTypeFieldsAnnotations().get( "org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.SmurfHouse" );
        assertNotNullfieldsAnnotations );
        assertEquals( 2,
                      fieldsAnnotations.size() );
        assertTruefieldsAnnotations.containsKey( "occupant" ) );
        final Set<Annotation> occupantAnnotations = fieldsAnnotations.get( "occupant" );
        assertNotNulloccupantAnnotations );
        assertEquals( 1,
                      occupantAnnotations.size() );
        final Annotation annotation = occupantAnnotations.iterator().next();
        assertEquals"org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.SmurfFieldDescriptor",
                      annotation.getQualifiedTypeName() );
        assertEquals"blue",
                      annotation.getAttributes().get( "colour" ) );
        assertEquals"M",
                      annotation.getAttributes().get( "gender" ) );
        assertEquals"Brains",
                      annotation.getAttributes().get( "description" ) );
        assertTruefieldsAnnotations.containsKey( "positionedOccupant" ) );
        final Set<Annotation> posOccupantAnnotations = fieldsAnnotations.get( "positionedOccupant" );
        assertNotNullposOccupantAnnotations );
        assertEquals( 1,
                      posOccupantAnnotations.size() );
        final Annotation annotation2 = posOccupantAnnotations.iterator().next();
        assertEquals"org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.SmurfFieldPositionDescriptor",
                      annotation2.getQualifiedTypeName() );
        assertEquals( Integer.toString( 1 ),
                      annotation2.getAttributes().get( "value" ) );
    }
New to GrepCode? Check out our FAQ X