Package org.apache.olingo.odata2.jpa.processor.core

Examples of org.apache.olingo.odata2.jpa.processor.core.ODataJPAContextImpl


   * This Unit is supposed to test the building of Entity Provider Properties for query with $expand
   */
  @Test
  public void testGetEntityProviderPropertiesQuery() {
    GetEntitySetUriInfo getEntitySetUriInfo = mockEntitySetUriInfoForExpand();
    ODataJPAContext oDataJPAContext = getODataJPAContext();
    // Building the edm entity
    List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
    Map<String, Object> edmEntity = new HashMap<String, Object>();
    edmEntity.put("ID", 1);
    edmEntityList.add(edmEntity);
View Full Code Here


  @Test
  public void testGetEntityProviderPropertiesRead() {

    // Getting the EntityUriInfo
    GetEntityUriInfo getEntityUriInfo = mockEntityUriInfoForExpand();
    ODataJPAContext oDataJPAContext = getODataJPAContext();
    Class<?> clazz = ODataJPAResponseBuilderDefault.class;
    Object[] actualParameters = { oDataJPAContext, getEntityUriInfo };
    Class<?>[] formalParameters = { ODataJPAContext.class, GetEntityUriInfo.class };
    EntityProviderWriteProperties providerProperties = null;
    try {
View Full Code Here

    }
    assertNotNull(objODataResponse);
  }

  private ODataJPAContext getODataJPAContext() {
    ODataJPAContext objODataJPAContext = EasyMock.createMock(ODataJPAContext.class);
    EasyMock.expect(objODataJPAContext.getODataContext()).andStubReturn(getLocalODataContext());
    EasyMock.expect(objODataJPAContext.getPageSize()).andReturn(10);
    EasyMock.expect(objODataJPAContext.getPaging()).andReturn(mockJPAPaging()).anyTimes();
    EasyMock.replay(objODataJPAContext);
    return objODataJPAContext;
  }
View Full Code Here

  @Test
  public void testBuildJPAEdmComplexPropertyView() {
    JPAEdmComplexPropertyView complexPropertyView = EasyMock.createMock(JPAEdmComplexPropertyView.class);
    ComplexProperty complexProperty = new ComplexProperty();
    EasyMock.expect(complexPropertyView.getEdmComplexProperty()).andStubReturn(complexProperty);
    ODataJPAContextImpl oDataJPAContext = new ODataJPAContextImpl();
    JPAEdmMappingModelService mappingModelService = new JPAEdmMappingModelService(oDataJPAContext);
    EasyMock.expect(complexPropertyView.getJPAEdmMappingModelAccess()).andStubReturn(mappingModelService);

    // Mocking EDMProperty
    JPAEdmPropertyView propertyView = EasyMock.createMock(JPAEdmPropertyView.class);
View Full Code Here

  @Test
  public void testBuildJPAEdmComplexPropertyViewWithNoDefaultNaming() {
    JPAEdmComplexPropertyView complexPropertyView = EasyMock.createMock(JPAEdmComplexPropertyView.class);
    ComplexProperty complexProperty = new ComplexProperty();
    EasyMock.expect(complexPropertyView.getEdmComplexProperty()).andStubReturn(complexProperty);
    ODataJPAContextImpl oDataJPAContext = new ODataJPAContextImpl();
    JPAEdmMappingModelService mappingModelService = new JPAEdmMappingModelService(oDataJPAContext);
    EasyMock.expect(complexPropertyView.getJPAEdmMappingModelAccess()).andStubReturn(mappingModelService);

    // Mocking EDMProperty
    JPAEdmPropertyView propertyView = EasyMock.createMock(JPAEdmPropertyView.class);
View Full Code Here

      return new ODataJPAEdmProvider(oDataJPAContext);
    }

    @Override
    public ODataJPAContext createODataJPAContext() {
      return new ODataJPAContextImpl();
    }
View Full Code Here

  @Test
  public void testJPAAccessFactory() {
    ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl();
    JPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getJPAAccessFactory();
    ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl();
    Class<?> clazz = oDataJPAContextImpl.getClass();
    try {
      Field field = clazz.getDeclaredField("em");
      field.setAccessible(true);
      field.set(oDataJPAContextImpl, new JPAProcessorImplTest().getLocalEntityManager());
    } catch (SecurityException e) {
      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
    } catch (NoSuchFieldException e) {
      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
    } catch (IllegalArgumentException e) {
      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
    } catch (IllegalAccessException e) {
      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
    }
    EntityManagerFactory emf = new EntityManagerFactory() {

      @Override
      public boolean isOpen() {
        return false;
      }

      @Override
      public Map<String, Object> getProperties() {
        return null;
      }

      @Override
      public PersistenceUnitUtil getPersistenceUnitUtil() {
        return null;
      }

      @Override
      public Metamodel getMetamodel() {
        return null;
      }

      @Override
      public CriteriaBuilder getCriteriaBuilder() {
        return null;
      }

      @Override
      public Cache getCache() {
        return null;
      }

      @SuppressWarnings("rawtypes")
      @Override
      public EntityManager createEntityManager(final Map arg0) {
        return null;
      }

      @Override
      public EntityManager createEntityManager() {
        return null;
      }

      @Override
      public void close() {}
    };
    oDataJPAContextImpl.setEntityManagerFactory(emf);
    oDataJPAContextImpl.setPersistenceUnitName("pUnit");

    assertNotNull(jpaAccessFactory.getJPAProcessor(oDataJPAContextImpl));
    assertNotNull(jpaAccessFactory.getJPAEdmModelView(oDataJPAContextImpl));

  }
View Full Code Here

  @Test
  public void testOdataJpaAccessFactory() {

    ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl();
    ODataJPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getODataJPAAccessFactory();
    ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl();

    EntityManagerFactory emf = new EntityManagerFactory() {

      @Override
      public boolean isOpen() {
        // TODO Auto-generated method stub
        return false;
      }

      @Override
      public Map<String, Object> getProperties() {
        // TODO Auto-generated method stub
        return null;
      }

      @Override
      public PersistenceUnitUtil getPersistenceUnitUtil() {
        // TODO Auto-generated method stub
        return null;
      }

      @Override
      public Metamodel getMetamodel() {
        // TODO Auto-generated method stub
        return null;
      }

      @Override
      public CriteriaBuilder getCriteriaBuilder() {
        // TODO Auto-generated method stub
        return null;
      }

      @Override
      public Cache getCache() {
        // TODO Auto-generated method stub
        return null;
      }

      @SuppressWarnings("rawtypes")
      @Override
      public EntityManager createEntityManager(final Map arg0) {
        // TODO Auto-generated method stub
        return null;
      }

      @Override
      public EntityManager createEntityManager() {
        // TODO Auto-generated method stub
        return null;
      }

      @Override
      public void close() {
        // TODO Auto-generated method stub

      }
    };
    oDataJPAContextImpl.setEntityManagerFactory(emf);
    oDataJPAContextImpl.setPersistenceUnitName("pUnit");

    assertNotNull(jpaAccessFactory.getODataJPAMessageService(new Locale("en")));
    assertNotNull(jpaAccessFactory.createODataJPAContext());
    assertNotNull(jpaAccessFactory.createJPAEdmProvider(oDataJPAContextImpl));
    assertNotNull(jpaAccessFactory.createODataProcessor(oDataJPAContextImpl));
View Full Code Here

  @Test
  public void testBuildJPAEdmComplexPropertyView() {
    JPAEdmComplexPropertyView complexPropertyView = EasyMock.createMock(JPAEdmComplexPropertyView.class);
    ComplexProperty complexProperty = new ComplexProperty();
    EasyMock.expect(complexPropertyView.getEdmComplexProperty()).andStubReturn(complexProperty);
    ODataJPAContextImpl oDataJPAContext = new ODataJPAContextImpl();
    JPAEdmMappingModelService mappingModelService = new JPAEdmMappingModelService(oDataJPAContext);
    EasyMock.expect(complexPropertyView.getJPAEdmMappingModelAccess()).andStubReturn(mappingModelService);

    // Mocking EDMProperty
    JPAEdmPropertyView propertyView = EasyMock.createMock(JPAEdmPropertyView.class);
View Full Code Here

  @Test
  public void testBuildJPAEdmComplexPropertyViewWithNoDefaultNaming() {
    JPAEdmComplexPropertyView complexPropertyView = EasyMock.createMock(JPAEdmComplexPropertyView.class);
    ComplexProperty complexProperty = new ComplexProperty();
    EasyMock.expect(complexPropertyView.getEdmComplexProperty()).andStubReturn(complexProperty);
    ODataJPAContextImpl oDataJPAContext = new ODataJPAContextImpl();
    JPAEdmMappingModelService mappingModelService = new JPAEdmMappingModelService(oDataJPAContext);
    EasyMock.expect(complexPropertyView.getJPAEdmMappingModelAccess()).andStubReturn(mappingModelService);

    // Mocking EDMProperty
    JPAEdmPropertyView propertyView = EasyMock.createMock(JPAEdmPropertyView.class);
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.jpa.processor.core.ODataJPAContextImpl

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.