Esempio n. 1
0
  public static EdmEntityType mockTargetEdmEntityType() {
    EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
    EdmMapping mapping = EasyMock.createMock(EdmMapping.class);

    List<String> propertyNames = new ArrayList<String>();
    propertyNames.add("price");
    try {
      EasyMock.expect(mapping.getInternalName()).andStubReturn("SalesOrderLineItem");
      EasyMock.replay(mapping);
      EasyMock.expect(entityType.getName()).andStubReturn("SalesOrderLineItem");
      EasyMock.expect(entityType.getMapping()).andStubReturn(mapping);
      EdmProperty property = mockEdmPropertyOfTarget();
      EasyMock.expect(entityType.getProperty("price")).andStubReturn(property);
      EasyMock.expect(entityType.getPropertyNames()).andStubReturn(propertyNames);

      List<EdmProperty> keyProperties = new ArrayList<EdmProperty>();
      keyProperties.add(property);
      EasyMock.expect(entityType.getKeyProperties()).andStubReturn(keyProperties);

    } catch (EdmException e) {
      fail(
          ODataJPATestConstants.EXCEPTION_MSG_PART_1
              + e.getMessage()
              + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
    }
    EasyMock.replay(entityType);
    return entityType;
  }
Esempio n. 2
0
 public static EdmEntityType mockSourceEdmEntityType() {
   EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
   EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
   List<String> navigationPropertyNames = new ArrayList<String>();
   List<String> propertyNames = new ArrayList<String>();
   propertyNames.add("id");
   propertyNames.add("description");
   navigationPropertyNames.add("SalesOrderLineItemDetails");
   try {
     EasyMock.expect(mapping.getInternalName()).andStubReturn("SalesOrderHeader");
     EasyMock.replay(mapping);
     EasyMock.expect(entityType.getName()).andStubReturn("SalesOrderHeader");
     EasyMock.expect(entityType.getMapping()).andStubReturn(mapping);
     EasyMock.expect(entityType.getNavigationPropertyNames())
         .andStubReturn(navigationPropertyNames);
     EasyMock.expect(entityType.getProperty("SalesOrderLineItemDetails"))
         .andStubReturn(mockNavigationProperty());
     EdmProperty property1 = mockEdmPropertyOfSource1();
     EasyMock.expect(entityType.getProperty("id")).andStubReturn(property1);
     EasyMock.expect(entityType.getProperty("description"))
         .andStubReturn(mockEdmPropertyOfSource2());
     EasyMock.expect(entityType.getPropertyNames()).andStubReturn(propertyNames);
     List<EdmProperty> keyProperties = new ArrayList<EdmProperty>();
     keyProperties.add(property1);
     EasyMock.expect(entityType.getKeyProperties()).andStubReturn(keyProperties);
   } catch (EdmException e) {
     fail(
         ODataJPATestConstants.EXCEPTION_MSG_PART_1
             + e.getMessage()
             + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
   }
   EasyMock.replay(entityType);
   return entityType;
 }
Esempio n. 3
0
 public static EdmNavigationProperty mockNavigationProperty() {
   EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
   EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
   EasyMock.expect(mapping.getInternalName()).andStubReturn("salesOrderLineItems");
   EasyMock.replay(mapping);
   try {
     EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.MANY);
     EasyMock.expect(navigationProperty.getMapping()).andStubReturn(mapping);
     EasyMock.expect(navigationProperty.getName()).andStubReturn("SalesOrderLineItemDetails");
     EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("SalesOrderHeader");
   } catch (EdmException e) {
     fail(
         ODataJPATestConstants.EXCEPTION_MSG_PART_1
             + e.getMessage()
             + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
   }
   EasyMock.replay(navigationProperty);
   return navigationProperty;
 }
Esempio n. 4
0
 private static EdmProperty mockEdmPropertyOfSource1() {
   EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
   EdmType type = EasyMock.createMock(EdmType.class);
   EasyMock.expect(type.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
   EasyMock.replay(type);
   EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
   EasyMock.expect(mapping.getInternalName()).andStubReturn("id");
   EasyMock.replay(mapping);
   try {
     EasyMock.expect(edmProperty.getName()).andStubReturn("id");
     EasyMock.expect(edmProperty.getType()).andStubReturn(type);
     EasyMock.expect(edmProperty.getMapping()).andStubReturn(mapping);
   } catch (EdmException e) {
     fail(
         ODataJPATestConstants.EXCEPTION_MSG_PART_1
             + e.getMessage()
             + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
   }
   EasyMock.replay(edmProperty);
   return edmProperty;
 }