Ejemplo 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;
  }
Ejemplo 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;
 }