Package org.apache.olingo.odata2.api.edm

Examples of org.apache.olingo.odata2.api.edm.EdmAssociation


  @Test
  public void testAssociationSetCache() throws EdmException {
    EdmEntitySet sourceEntitySet = mock(EdmEntitySet.class);
    when(sourceEntitySet.getName()).thenReturn("foo");

    EdmAssociation edmAssociation = mock(EdmAssociation.class);
    when(edmAssociation.getNamespace()).thenReturn("AssocNs");
    when(edmAssociation.getName()).thenReturn("AssocName");

    EdmNavigationProperty edmNavigationProperty = mock(EdmNavigationProperty.class);
    when(edmNavigationProperty.getRelationship()).thenReturn(edmAssociation);
    when(edmNavigationProperty.getFromRole()).thenReturn("fromRole");
View Full Code Here


    }
  }

  private EdmNavigationProperty createNavigationProperty(final String z) throws EdmException {
    EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
    EdmAssociation association = EasyMock.createMock(EdmAssociation.class);
    EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class);
    EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("roleA" + z);
    EasyMock.expect(navigationProperty.getToRole()).andStubReturn("roleB" + z);
    EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
    EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
    EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.ONE);
    EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
    EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
    EasyMock.expect(edmMapping.getInternalName()).andStubReturn("sItem" + z);
    EasyMock.expect(edmEntityType.getMapping()).andStubReturn(edmMapping);
    EasyMock.expect(edmEntityType.getName()).andStubReturn("soItem" + z);
    EasyMock.expect(associationEnd.getEntityType()).andStubReturn(edmEntityType);
    EasyMock.expect(association.getEnd("roleA" + z)).andStubReturn(associationEnd);
    EasyMock.expect(navigationProperty.getRelationship()).andStubReturn(association);
    EdmMapping edmMapping1 = EasyMock.createMock(EdmMapping.class);
    EasyMock.expect(edmMapping1.getInternalName()).andStubReturn("s_Item" + z);
    EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping1);
    EasyMock.replay(edmMapping, edmMapping1, edmEntityType, associationEnd, association, navigationProperty);
View Full Code Here

    FullQualifiedName fqName = new FullQualifiedName(finalNamespace, name);
    if (edmAssociations.containsKey(fqName)) {
      return edmAssociations.get(fqName);
    }

    EdmAssociation edmAssociation = null;

    try {
      edmAssociation = createAssociation(fqName);
      if (edmAssociation != null) {
        edmAssociations.put(fqName, edmAssociation);
View Full Code Here

    assertEquals("fooFromParent", edmEntityContainer.getEntitySet("fooFromParent").getName());

    EdmEntitySet sourceEntitySet = mock(EdmEntitySet.class);
    when(sourceEntitySet.getName()).thenReturn("foo");

    EdmAssociation edmAssociation = mock(EdmAssociation.class);
    when(edmAssociation.getNamespace()).thenReturn("AssocNs");
    when(edmAssociation.getName()).thenReturn("AssocName");

    EdmNavigationProperty edmNavigationProperty = mock(EdmNavigationProperty.class);
    when(edmNavigationProperty.getRelationship()).thenReturn(edmAssociation);
    when(edmNavigationProperty.getFromRole()).thenReturn("wrongRole");
View Full Code Here

  @Test
  public void testAssociationSetCache() throws EdmException {
    EdmEntitySet sourceEntitySet = mock(EdmEntitySet.class);
    when(sourceEntitySet.getName()).thenReturn("foo");

    EdmAssociation edmAssociation = mock(EdmAssociation.class);
    when(edmAssociation.getNamespace()).thenReturn("AssocNs");
    when(edmAssociation.getName()).thenReturn("AssocName");

    EdmNavigationProperty edmNavigationProperty = mock(EdmNavigationProperty.class);
    when(edmNavigationProperty.getRelationship()).thenReturn(edmAssociation);
    when(edmNavigationProperty.getFromRole()).thenReturn("fromRole");
View Full Code Here

    EasyMock.replay(associationEnd);
    return associationEnd;
  }

  public static EdmAssociation mockEdmAssociation(final String navigationPropertyName) throws EdmException {
    EdmAssociation edmAssociation = EasyMock.createMock(EdmAssociation.class);
    EasyMock.expect(edmAssociation.getEnd("TO")).andReturn(mockEdmAssociatioEnd(navigationPropertyName, "TO"));
    EasyMock.expect(edmAssociation.getEnd("FROM")).andReturn(mockEdmAssociatioEnd(navigationPropertyName, "FROM"));
    EasyMock.replay(edmAssociation);
    return edmAssociation;
  }
View Full Code Here

    this.edmEntityContainer = edmEntityContainer;
  }

  @Override
  public EdmAssociation getAssociation() throws EdmException {
    EdmAssociation association =
        edm.getAssociation(associationSet.getAssociation().getNamespace(), associationSet.getAssociation().getName());
    if (association == null) {
      throw new EdmException(EdmException.COMMON);
    }
    return association;
View Full Code Here

    assertEquals("ComplexType1", complexTypeWithAlias.getName());
    EdmComplexType complexType = edm.getComplexType("ComplexType1Ns", "ComplexType1");
    assertEquals("ComplexType1", complexType.getName());
    assertEquals(complexType, complexTypeWithAlias);

    EdmAssociation associationWithAlias = edm.getAssociation("at1", "Association1");
    assertEquals("Association1", associationWithAlias.getName());
    EdmAssociation association = edm.getAssociation("Association1Ns", "Association1");
    assertEquals("Association1", association.getName());
    assertEquals(association, associationWithAlias);
  }
View Full Code Here

    assertEquals(complexType, complexTypeWithAlias);
  }

  @Test
  public void testAssociation() throws EdmException {
    EdmAssociation association = edm.getAssociation("Association1Ns", "Association1");
    assertEquals("Association1", association.getName());

    EdmAssociation associationWithAlias = edm.getAssociation("at1", "Association1");
    assertEquals("Association1", associationWithAlias.getName());

    assertEquals(association, associationWithAlias);
  }
View Full Code Here

  }

  @Override
  public EdmAssociationSet getAssociationSet(final EdmEntitySet sourceEntitySet,
      final EdmNavigationProperty navigationProperty) throws EdmException {
    EdmAssociation edmAssociation = navigationProperty.getRelationship();
    String association = edmAssociation.getNamespace() + "." + edmAssociation.getName();
    String entitySetName = sourceEntitySet.getName();
    String entitySetFromRole = navigationProperty.getFromRole();

    String key = entitySetName + ">>" + association + ">>" + entitySetFromRole;

    EdmAssociationSet edmAssociationSet = edmAssociationSets.get(key);
    if (edmAssociationSet != null) {
      return edmAssociationSet;
    }

    AssociationSet associationSet;
    FullQualifiedName associationFQName =
        new FullQualifiedName(edmAssociation.getNamespace(), edmAssociation.getName());
    try {
      associationSet =
          edm.edmProvider.getAssociationSet(entityContainer.getName(), associationFQName, entitySetName,
              entitySetFromRole);
    } catch (ODataException e) {
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.edm.EdmAssociation

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.