Package org.jmock

Examples of org.jmock.Mockery


   
    new EntityBeanConverter(jdtFacade).addTableAnnotation(entityBean, entity);
  }
 
  public void testShouldAddTableAnnotation() throws Exception {
    Mockery context = new Mockery();
    final IJDTFacade jdtFacade = context.mock(IJDTFacade.class);

        AppModule appModule = new TestFixture().getAppModule("basicentity-ejb-jar.xml", "basicentity-openejb-jar.xml");
    Entity entity = appModule.getCmpMappings().getEntityMap().get("openejb.java.lang.Product");
    EntityBean entityBean = (EntityBean) appModule.getEjbModules().get(0).getEjbJar().getEnterpriseBean("ProductEJB");
   
    context.checking(new Expectations() {
      {
        Map<String,Object> properties = new HashMap<String, Object>();
        properties.put("name", "products");
        one(jdtFacade).addClassAnnotation("org.superbiz.ProductBean", Table.class, properties);
      }
View Full Code Here


   
    new EntityBeanConverter(jdtFacade).addTableAnnotation(entityBean, entity);
  }
 
  public void testShouldAddColumnAnnotation() throws Exception {
    Mockery context = new Mockery();
    final IJDTFacade jdtFacade = context.mock(IJDTFacade.class);

        AppModule appModule = new TestFixture().getAppModule("basicentity-ejb-jar.xml", "basicentity-openejb-jar.xml");
    Entity entity = appModule.getCmpMappings().getEntityMap().get("openejb.java.lang.Product");
    EntityBean entityBean = (EntityBean) appModule.getEjbModules().get(0).getEjbJar().getEnterpriseBean("ProductEJB");
   
    context.checking(new Expectations() {
      {
        Map<String, Object> nameColumnProperties = new HashMap<String, Object>();
        nameColumnProperties.put("name", "name");
        one(jdtFacade).addMethodAnnotation("org.superbiz.ProductBean", "getName", new String[0], Column.class, nameColumnProperties );
View Full Code Here

   
    new EntityBeanConverter(jdtFacade).addBasicAnnotations(entityBean, entity.getAttributes().getBasic());
  }

  public void testShouldAddIdAnnotation() throws Exception {
    Mockery context = new Mockery();
    final IJDTFacade jdtFacade = context.mock(IJDTFacade.class);

        String ejbJarFilename = "basicentity-ejb-jar.xml";
        String openejbJarFilename = "basicentity-openejb-jar.xml";

        AppModule appModule = new TestFixture().getAppModule(ejbJarFilename, openejbJarFilename);
    Entity entity = appModule.getCmpMappings().getEntityMap().get("openejb.java.lang.Product");
    EntityBean entityBean = (EntityBean) appModule.getEjbModules().get(0).getEjbJar().getEnterpriseBean("ProductEJB");
   
    context.checking(new Expectations() {
      {
        one(jdtFacade).addMethodAnnotation("org.superbiz.ProductBean", "getId", new String[0], Id.class, null);
        Map<String, Object> generatedvalueProps = new HashMap<String, Object>();
        generatedvalueProps.put("strategy", GenerationType.IDENTITY);
        one(jdtFacade).addMethodAnnotation("org.superbiz.ProductBean", "getId", new String[0], GeneratedValue.class, generatedvalueProps );
View Full Code Here

import org.jmock.Sequence;
import org.apache.openejb.config.AppModule;

public class EntityBeanPojoConverterTest extends TestCase {
    public void testShouldConvertEntityToPojo() throws Exception {
        Mockery context = new Mockery();
        final Sequence sequence = context.sequence("sequence");

        final IJDTFacade facade = context.mock(IJDTFacade.class);

        context.checking(new Expectations() {
            {
                one(facade).removeAbstractModifierFromClass("org.superbiz.ProductBean");
                inSequence(sequence);

                one(facade).removeInterface("org.superbiz.ProductBean", "javax.ejb.EntityBean");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getId", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.ProductBean", "id", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getId", new String[0], "return id;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setId", new String[]{"java.lang.Integer"}, "this.id = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getName", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.String"));

                one(facade).addField("org.superbiz.ProductBean", "name", "java.lang.String");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getName", new String[0], "return name;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setName", new String[]{"java.lang.String"}, "this.name = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getCode", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.String"));

                one(facade).addField("org.superbiz.ProductBean", "code", "java.lang.String");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getCode", new String[0], "return code;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setCode", new String[]{"java.lang.String"}, "this.code = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getDescription", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.String"));

                one(facade).addField("org.superbiz.ProductBean", "description", "java.lang.String");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getDescription", new String[0], "return description;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setDescription", new String[]{"java.lang.String"}, "this.description = ${0};");
                inSequence(sequence);
            }
        });

        AppModule module = new TestFixture().getAppModule("basicentity-ejb-jar.xml", null);
        new EntityBeanPojoConverter(facade).convert(module);

        context.assertIsSatisfied();
    }
View Full Code Here

        context.assertIsSatisfied();
    }

    public void testShouldConvertEntityWithOneToManyToPojo() throws Exception {
        Mockery context = new Mockery();
        final Sequence sequence = context.sequence("sequence");

        final IJDTFacade facade = context.mock(IJDTFacade.class);

        context.checking(new Expectations() {
            {
                one(facade).removeAbstractModifierFromClass("org.superbiz.OrderBean");
                inSequence(sequence);

                one(facade).removeInterface("org.superbiz.OrderBean", "javax.ejb.EntityBean");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderBean", "getId", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.OrderBean", "id", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderBean", "getId", new String[0], "return id;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderBean", "setId", new String[]{"java.lang.Integer"}, "this.id = ${0};");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromClass("org.superbiz.OrderLineBean");
                inSequence(sequence);

                one(facade).removeInterface("org.superbiz.OrderLineBean", "javax.ejb.EntityBean");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getId", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.OrderLineBean", "id", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getId", new String[0], "return id;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setId", new String[]{"java.lang.Integer"}, "this.id = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getQty", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.OrderLineBean", "qty", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getQty", new String[0], "return qty;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setQty", new String[]{"java.lang.Integer"}, "this.qty = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderBean", "getOrderLine", new String[0]);
                inSequence(sequence);
                will(returnValue("java.util.Collection"));

                one(facade).addField("org.superbiz.OrderBean", "orderLine", "java.util.Collection");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderBean", "getOrderLine", new String[0], "return orderLine;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderBean", "setOrderLine", new String[]{"java.util.Collection"}, "this.orderLine = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getOrder", new String[0]);
                inSequence(sequence);
                will(returnValue("org.superbiz.Order"));

                one(facade).addField("org.superbiz.OrderLineBean", "order", "org.superbiz.Order");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getOrder", new String[0], "return order;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setOrder", new String[]{"org.superbiz.Order"}, "this.order = ${0};");
                inSequence(sequence);
            }
        });

        AppModule module = new TestFixture().getAppModule("onetomany-ejb-jar.xml", null);
        new EntityBeanPojoConverter(facade).convert(module);

        context.assertIsSatisfied();
    }
View Full Code Here

        context.assertIsSatisfied();
    }

    public void testShouldConvertEntityWithOneToOneToPojo() throws Exception {
        Mockery context = new Mockery();
        final Sequence sequence = context.sequence("sequence");

        final IJDTFacade facade = context.mock(IJDTFacade.class);

        context.checking(new Expectations() {
            {
                one(facade).removeAbstractModifierFromClass("org.superbiz.ProductBean");
                inSequence(sequence);

                one(facade).removeInterface("org.superbiz.ProductBean", "javax.ejb.EntityBean");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getId", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.ProductBean", "id", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getId", new String[0], "return id;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setId", new String[]{"java.lang.Integer"}, "this.id = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getName", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.String"));

                one(facade).addField("org.superbiz.ProductBean", "name", "java.lang.String");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getName", new String[0], "return name;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setName", new String[]{"java.lang.String"}, "this.name = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getCode", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.String"));

                one(facade).addField("org.superbiz.ProductBean", "code", "java.lang.String");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getCode", new String[0], "return code;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setCode", new String[]{"java.lang.String"}, "this.code = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getDescription", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.String"));

                one(facade).addField("org.superbiz.ProductBean", "description", "java.lang.String");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getDescription", new String[0], "return description;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setDescription", new String[]{"java.lang.String"}, "this.description = ${0};");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromClass("org.superbiz.OrderLineBean");
                inSequence(sequence);

                one(facade).removeInterface("org.superbiz.OrderLineBean", "javax.ejb.EntityBean");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getId", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.OrderLineBean", "id", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getId", new String[0], "return id;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setId", new String[]{"java.lang.Integer"}, "this.id = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getQty", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.OrderLineBean", "qty", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getQty", new String[0], "return qty;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setQty", new String[]{"java.lang.Integer"}, "this.qty = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getProduct", new String[0]);
                inSequence(sequence);
                will(returnValue("org.superbiz.Product"));

                one(facade).addField("org.superbiz.OrderLineBean", "product", "org.superbiz.Product");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getProduct", new String[0], "return product;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setProduct", new String[]{"org.superbiz.Product"}, "this.product = ${0};");
                inSequence(sequence);
            }
        });

        AppModule module = new TestFixture().getAppModule("onetoone-ejb-jar.xml", null);
        new EntityBeanPojoConverter(facade).convert(module);

        context.assertIsSatisfied();
    }
View Full Code Here

        context.assertIsSatisfied();
    }

    public void testShouldConvertEntityWithManyToManyToPojo() throws Exception {
        Mockery context = new Mockery();
        final Sequence sequence = context.sequence("sequence");

        final IJDTFacade facade = context.mock(IJDTFacade.class);

        context.checking(new Expectations() {
            {
                one(facade).removeAbstractModifierFromClass("org.superbiz.ProductBean");
                inSequence(sequence);

                one(facade).removeInterface("org.superbiz.ProductBean", "javax.ejb.EntityBean");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getId", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.ProductBean", "id", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getId", new String[0], "return id;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setId", new String[]{"java.lang.Integer"}, "this.id = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getName", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.String"));

                one(facade).addField("org.superbiz.ProductBean", "name", "java.lang.String");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getName", new String[0], "return name;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setName", new String[]{"java.lang.String"}, "this.name = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getCode", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.String"));

                one(facade).addField("org.superbiz.ProductBean", "code", "java.lang.String");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getCode", new String[0], "return code;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setCode", new String[]{"java.lang.String"}, "this.code = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getDescription", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.String"));

                one(facade).addField("org.superbiz.ProductBean", "description", "java.lang.String");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getDescription", new String[0], "return description;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setDescription", new String[]{"java.lang.String"}, "this.description = ${0};");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromClass("org.superbiz.OrderLineBean");
                inSequence(sequence);

                one(facade).removeInterface("org.superbiz.OrderLineBean", "javax.ejb.EntityBean");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getId", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.OrderLineBean", "id", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getId", new String[0], "return id;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setId", new String[]{"java.lang.Integer"}, "this.id = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getQty", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.OrderLineBean", "qty", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getQty", new String[0], "return qty;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setQty", new String[]{"java.lang.Integer"}, "this.qty = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getProduct", new String[0]);
                inSequence(sequence);
                will(returnValue("java.util.Collection"));

                one(facade).addField("org.superbiz.OrderLineBean", "product", "java.util.Collection");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getProduct", new String[0], "return product;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setProduct", new String[]{"java.util.Collection"}, "this.product = ${0};");
                inSequence(sequence);
            }
        });

        AppModule module = new TestFixture().getAppModule("manytomany-ejb-jar.xml", null);
        new EntityBeanPojoConverter(facade).convert(module);

        context.assertIsSatisfied();
    }
View Full Code Here

        context.assertIsSatisfied();
    }

    public void testShouldConvertEntityWithManyToOneToPojo() throws Exception {
        Mockery context = new Mockery();
        final Sequence sequence = context.sequence("sequence");

        final IJDTFacade facade = context.mock(IJDTFacade.class);

        context.checking(new Expectations() {
            {
                one(facade).removeAbstractModifierFromClass("org.superbiz.ProductBean");
                inSequence(sequence);

                one(facade).removeInterface("org.superbiz.ProductBean", "javax.ejb.EntityBean");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getId", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.ProductBean", "id", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getId", new String[0], "return id;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setId", new String[]{"java.lang.Integer"}, "this.id = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getName", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.String"));

                one(facade).addField("org.superbiz.ProductBean", "name", "java.lang.String");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getName", new String[0], "return name;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setName", new String[]{"java.lang.String"}, "this.name = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getCode", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.String"));

                one(facade).addField("org.superbiz.ProductBean", "code", "java.lang.String");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getCode", new String[0], "return code;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setCode", new String[]{"java.lang.String"}, "this.code = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getDescription", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.String"));

                one(facade).addField("org.superbiz.ProductBean", "description", "java.lang.String");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getDescription", new String[0], "return description;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setDescription", new String[]{"java.lang.String"}, "this.description = ${0};");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromClass("org.superbiz.OrderLineBean");
                inSequence(sequence);

                one(facade).removeInterface("org.superbiz.OrderLineBean", "javax.ejb.EntityBean");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getId", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.OrderLineBean", "id", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getId", new String[0], "return id;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setId", new String[]{"java.lang.Integer"}, "this.id = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getQty", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.OrderLineBean", "qty", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getQty", new String[0], "return qty;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setQty", new String[]{"java.lang.Integer"}, "this.qty = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getProduct", new String[0]);
                inSequence(sequence);
                will(returnValue("java.util.Collection"));

                one(facade).addField("org.superbiz.OrderLineBean", "product", "java.util.Collection");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getProduct", new String[0], "return product;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setProduct", new String[]{"java.util.Collection"}, "this.product = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.ProductBean", "getOrderLine", new String[0]);
                inSequence(sequence);
                will(returnValue("org.superbiz.OrderLine"));

                one(facade).addField("org.superbiz.ProductBean", "orderLine", "org.superbiz.OrderLine");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "getOrderLine", new String[0], "return orderLine;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.ProductBean", "setOrderLine", new String[]{"org.superbiz.OrderLine"}, "this.orderLine = ${0};");
                inSequence(sequence);
            }
        });

        AppModule module = new TestFixture().getAppModule("manytoone-ejb-jar.xml", null);
        new EntityBeanPojoConverter(facade).convert(module);

        context.assertIsSatisfied();
    }
View Full Code Here

        context.assertIsSatisfied();
    }

    public void testShouldConvertEntityWithBadRelationshipToPojo() throws Exception {
        Mockery context = new Mockery();
        final Sequence sequence = context.sequence("sequence");

        final IJDTFacade facade = context.mock(IJDTFacade.class);

        context.checking(new Expectations() {
            {
                one(facade).removeAbstractModifierFromClass("org.superbiz.OrderBean");
                inSequence(sequence);

                one(facade).removeInterface("org.superbiz.OrderBean", "javax.ejb.EntityBean");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderBean", "getId", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.OrderBean", "id", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderBean", "getId", new String[0], "return id;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderBean", "setId", new String[]{"java.lang.Integer"}, "this.id = ${0};");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromClass("org.superbiz.OrderLineBean");
                inSequence(sequence);

                one(facade).removeInterface("org.superbiz.OrderLineBean", "javax.ejb.EntityBean");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getId", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.OrderLineBean", "id", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getId", new String[0], "return id;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setId", new String[]{"java.lang.Integer"}, "this.id = ${0};");
                inSequence(sequence);

                one(facade).getMethodReturnType("org.superbiz.OrderLineBean", "getQty", new String[0]);
                inSequence(sequence);
                will(returnValue("java.lang.Integer"));

                one(facade).addField("org.superbiz.OrderLineBean", "qty", "java.lang.Integer");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "getQty", new String[0], "return qty;");
                inSequence(sequence);

                one(facade).removeAbstractModifierFromMethod("org.superbiz.OrderLineBean", "setQty", new String[]{"java.lang.Integer"}, "this.qty = ${0};");
                inSequence(sequence);
            }
        });

        AppModule module = new TestFixture().getAppModule("emptyrelationship-ejb-jar.xml", null);
        new EntityBeanPojoConverter(facade).convert(module);

        context.assertIsSatisfied();

    }
View Full Code Here

import java.util.HashMap;
import java.util.Map;

public class SessionBeanRemoteAnnotationAdderTest extends TestCase {
    public void testShouldAddRemoteAndRemoteHomeAnnotations() throws Exception {
        Mockery context = new Mockery();
        final IJDTFacade facade = context.mock(IJDTFacade.class);


        context.checking(new Expectations() {
            {
                one(facade).addClassAnnotation("org.superbiz.Store", Remote.class, null);

                Map<String, Object> remoteHomeProps = new HashMap<String, Object>();
                remoteHomeProps.put("value", "org.superbiz.StoreHome");
            }
        });

        AppModule module = new TestFixture().getAppModule("single-session-bean.xml", null);
        new SessionBeanRemoteAnnotationAdder(facade).convert(module);

        context.assertIsSatisfied();
    }
View Full Code Here

TOP

Related Classes of org.jmock.Mockery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.