Package org.pentaho.platform.repository

Examples of org.pentaho.platform.repository.SimpleRuntimeRepository


    // The simple runtime is used by the standalone distribution.
    // This provides some simple tests to exercise the code...
    startTest();
    StandaloneSession session =
        new StandaloneSession( Messages.getInstance().getString( "BaseTest.DEBUG_JUNIT_SESSION" ) ); //$NON-NLS-1$
    IRuntimeRepository srr = new SimpleRuntimeRepository();
    srr.setSession( session );
    IRuntimeElement ele1 = srr.loadElementById( "instanceid", null ); //$NON-NLS-1$
    IRuntimeElement ele2 = srr.newRuntimeElement( "parent", "parentType", true ); //$NON-NLS-1$ //$NON-NLS-2$
    IRuntimeElement ele3 = srr.newRuntimeElement( "parentid", "parentType", "solutionId", true ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    SimpleRuntimeElement sre = (SimpleRuntimeElement) srr.loadElementById( "instanceid", null ); //$NON-NLS-1$
    List list = sre.getMessages();
    if ( list != null ) {
      for ( int i = 0; i < list.size(); i++ ) {
        System.out.println( "Message " + ( i + 1 ) + list.get( i ) ); //$NON-NLS-1$
      }

      sre.setParentId( "parentid1" ); //$NON-NLS-1$
      sre.setParentType( "parentidType1" ); //$NON-NLS-1$
      sre.setSolutionId( "solutionId1" ); //$NON-NLS-1$
      sre.setReadOnly( true );
      boolean isReadOnly = sre.getReadOnly();
      String parentId = sre.getParentId();
      String parentIdType = sre.getParentType();
      String solutionId = sre.getSolutionId();
      assertEquals( isReadOnly, true );
      assertEquals( parentId, "parentid1" ); //$NON-NLS-1$
      assertEquals( parentIdType, "parentidType1" ); //$NON-NLS-1$
      assertEquals( solutionId, "solutionId1" ); //$NON-NLS-1$
    }
    int revision = sre.getRevision();
    System.out.println( "Revision Value is" + revision ); //$NON-NLS-1$
    sre.setStringProperty( "parentId", "value" ); //$NON-NLS-1$ //$NON-NLS-2$
    BigDecimal tstBD = new BigDecimal( "2.4" ); //$NON-NLS-1$
    ele2.setBigDecimalProperty( "junkBD", tstBD ); //$NON-NLS-1$
    BigDecimal bd = ele2.getBigDecimalProperty( "junkBD" ); //$NON-NLS-1$
    assertEquals( bd, tstBD );
    Date tstDT = new Date();
    ele3.setDateProperty( "junkDT", tstDT ); //$NON-NLS-1$
    Date dt = ele3.getDateProperty( "junkDT" ); //$NON-NLS-1$
    assertEquals( tstDT, dt );
    List l = new ArrayList();
    l.add( "one" ); //$NON-NLS-1$
    l.add( "two" ); //$NON-NLS-1$
    ele1.setListProperty( "SOMELIST", l ); //$NON-NLS-1$
    assertEquals( ele1.getListProperty( "SOMELIST" ), l ); //$NON-NLS-1$
    Long aLong = new Long( 5 );
    ele2.setLongProperty( "SOMELONG", aLong ); //$NON-NLS-1$
    assertEquals( ele2.getLongProperty( "SOMELONG", null ), aLong ); //$NON-NLS-1$
    assertEquals( ele2.getLongProperty( "SOMELONG", 5 ), 5 ); //$NON-NLS-1$
    Map mapProperty = new HashMap();
    mapProperty.put( "mapKey", "mapValue" ); //$NON-NLS-1$ //$NON-NLS-2$
    ele3.setMapProperty( "SOMEMAP", mapProperty ); //$NON-NLS-1$
    assertEquals( ele3.getMapProperty( "SOMEMAP" ), mapProperty ); //$NON-NLS-1$
    ele1.setStringProperty( "SOMESTRING", "SomeStringValue" ); //$NON-NLS-1$ //$NON-NLS-2$
    assertEquals( ele1.getStringProperty( "SOMESTRING" ), "SomeStringValue" ); //$NON-NLS-1$ //$NON-NLS-2$
    assertEquals( ele2.getStringProperty( "DOESNTEXIST", "SomeDefault" ), "SomeDefault" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    assertNull( ele1.getStringProperty( "DOESNTEXIST" ) ); //$NON-NLS-1$   
    assertNull( ele1.getBigDecimalProperty( "DOESNTEXIST" ) ); //$NON-NLS-1$
    assertNull( ele2.getDateProperty( "DOESNTEXIST" ) ); //$NON-NLS-1$
    assertNull( ele3.getListProperty( "DOESNTEXIST" ) ); //$NON-NLS-1$
    assertEquals( ele2.getLongProperty( "DOESNTEXIST", 2 ), 2 ); //$NON-NLS-1$
    assertEquals( ele2.getLongProperty( "DOESNTEXIST", new Long( 2 ) ), new Long( 2 ) ); //$NON-NLS-1$
    assertEquals( ele1.getBigDecimalProperty( "DOESNTEXIST", new BigDecimal( "0.23" ) ), new BigDecimal( "0.23" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Date tmpDate = new Date();
    assertEquals( ele1.getDateProperty( "DOESNTEXIST", tmpDate ), tmpDate ); //$NON-NLS-1$
    Set parmNames = ele1.getParameterNames();
    assertNotNull( parmNames );

    assertFalse( srr.usesHibernate() );

    assertEquals( ele2.getParameterType( "SOMELONG" ), "java.lang.Long" ); //$NON-NLS-1$ //$NON-NLS-2$
    assertEquals( ele2.getParentType(), "parentType" ); //$NON-NLS-1$
    assertEquals( ele3.getParentId(), "parentid" ); //$NON-NLS-1$
    assertEquals( ele1.getInstanceId(), "instanceid" ); //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of org.pentaho.platform.repository.SimpleRuntimeRepository

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.