Package pt.webdetails.cpf.persistence

Examples of pt.webdetails.cpf.persistence.ISimplePersistence.load()


    ISimplePersistence sp;
    try {
      sp = getSimplePersistence();
      Filter filter = new Filter();
      filter.where( "name" ).equalTo( viewName ).and().where( "user" ).equalTo( user );
      List<View> views = sp.load( View.class, filter );

      return ( views != null && views.size() > 0 ) ? views.get( 0 ) : null;
    } catch ( Exception e ) {
      logger.error( "Error while getting view.", e );
      return null;
View Full Code Here


    JSONArray arr = new JSONArray();
    try {
      sp = getSimplePersistence();
      Filter filter = new Filter();
      filter.where( "user" ).equalTo( user );
      List<View> views = sp.load( View.class, filter );
      for ( View v : views ) {
        arr.put( v.toJSON() );
      }
    } catch ( Exception e ) {
      logger.warn( "Exception while writing result to json array", e );
View Full Code Here

  //Should return null when ISimplePersistence.load fails
  @Test
  public void testGetViewFailOnLoad() {
    ISimplePersistence isp = Mockito.mock( ISimplePersistence.class );
    Mockito.when( isp.load( Mockito.eq( View.class ), Mockito.any( Filter.class ) ) )
            .thenThrow( new OCommandExecutionException( "Exception" ) );
    ViewsEngineForTest vet = new ViewsEngineForTest( Mockito.mock( IPersistenceEngine.class ), isp );
    Assert.assertNull( vet.getView( "x" , vet.getSession().getName() ));
  }
View Full Code Here

  //Should return error object when ISimplePersistence.load fails
  @Test
  public void testListViewsFailOnLoad() throws JSONException {
    ISimplePersistence isp = Mockito.mock( ISimplePersistence.class );
    Mockito.when( isp.load( Mockito.eq( View.class ), Mockito.any( Filter.class ) ) )
            .thenThrow( new OCommandExecutionException( "Exception" ) );
    ViewsEngineForTest vet = new ViewsEngineForTest( Mockito.mock( IPersistenceEngine.class ), isp );
    JSONObject result = vet.listViews( vet.getSession().getName() );
    Assert.assertNull( result );
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.