Examples of Expectation


Examples of com.volantis.testtools.mock.Expectation

    // Javadoc inherited.
    public void debug(Report report) {
        before(report);
        int size = expectations.size();
        for (int i = 0; i < size; i += 1) {
            Expectation expectation = (Expectation) expectations.get(i);
            ((AbstractExpectation) expectation).debug(report);
        }
        after(report);
    }
View Full Code Here

Examples of fitnesse.reporting.history.TestExecutionReport.Expectation

    assertEquals("instruction1", ir1.instruction);
    assertEquals("slimResult1", ir1.slimResult);
    List<Expectation> expectations1 = ir1.getExpectations();
    assertEquals(2, expectations1.size());
    Expectation e11 = expectations1.get(0);
    Expectation e12 = expectations1.get(1);
    assertEquals("s1", e11.status);
    assertEquals("id1", e11.instructionId);
    assertEquals("c1", e11.col);
    assertEquals("r1", e11.row);
    assertEquals("t1", e11.type);
View Full Code Here

Examples of fitnesse.testsystems.Expectation

  public void testAssertionVerified(Assertion assertion, TestResult testResult) {
    if (testResult == null) {
      return;
    }
    Instruction instruction = assertion.getInstruction();
    Expectation expectation = assertion.getExpectation();
    TestExecutionReport.InstructionResult instructionResult = new TestExecutionReport.InstructionResult();
    instructionResults.add(instructionResult);

    String id = instruction.getId();

    instructionResult.instruction = instruction.toString();
    instructionResult.slimResult = testResult.toString();
    try {
      TestExecutionReport.Expectation expectationResult = new TestExecutionReport.Expectation();
      instructionResult.addExpectation(expectationResult);
      expectationResult.instructionId = id;
      expectationResult.type = expectation.getClass().getSimpleName();
      expectationResult.actual = testResult.getActual();
      expectationResult.expected = testResult.getExpected();
      expectationResult.evaluationMessage = testResult.getMessage();
      if (testResult.getExecutionResult() != null) {
        expectationResult.status = testResult.getExecutionResult().toString();
View Full Code Here

Examples of org.drools.guvnor.client.modeldriven.testing.Expectation

        executionTrace.rulesFired = listener.getRulesFiredSummary();


      } else if (fx instanceof Expectation) {
                doPopulate(toPopulate);
          Expectation assertion = (Expectation) fx;
          if (assertion instanceof VerifyFact) {
            verify((VerifyFact) assertion);
          } else if (assertion instanceof VerifyRuleFired) {
            verify((VerifyRuleFired) assertion,
                (listener.firingCounts != null) ? listener.firingCounts : new HashMap<String, Integer>());
View Full Code Here

Examples of org.drools.ide.common.client.modeldriven.testing.Expectation

                executionTrace.setNumberOfRulesFired(listener.totalFires);
                executionTrace.setRulesFired(listener.getRulesFiredSummary());

            } else if (fixture instanceof Expectation) {
                doPopulate(toPopulate);
                Expectation assertion = (Expectation) fixture;
                if (assertion instanceof VerifyFact) {
                    verify((VerifyFact) assertion);
                } else if (assertion instanceof VerifyRuleFired) {
                    verify((VerifyRuleFired) assertion,
                            (listener.firingCounts != null) ? listener.firingCounts : new HashMap<String, Integer>());
View Full Code Here

Examples of org.hibernate.jdbc.Expectation

        try {
          int i = 0;
 
          Iterator entries = collection.entries( this );
          int offset = 1;
          Expectation expectation = Expectations.NONE;
          while ( entries.hasNext() ) {
 
            Object entry = entries.next();
            if ( collection.needsUpdating( entry, i, elementType ) ) {  // will still be issued when it used to be null
              if ( st == null ) {
                String sql = getSQLDeleteRowString();
                if ( isDeleteCallable() ) {
                  expectation = Expectations.appropriateExpectation( getDeleteCheckStyle() );
                  useBatch = expectation.canBeBatched();
                  st = useBatch
                      ? session.getBatcher().prepareBatchCallableStatement( sql )
                            : session.getBatcher().prepareCallableStatement( sql );
                  offset += expectation.prepare( st );
                }
                else {
                  st = session.getBatcher().prepareBatchStatement( getSQLDeleteRowString() );
                }
              }
              int loc = writeKey( st, id, offset, session );
              writeElementToWhere( st, collection.getSnapshotElement(entry, i), loc, session );
              if ( useBatch ) {
                session.getBatcher().addToBatch( expectation );
              }
              else {
                expectation.verifyOutcome( st.executeUpdate(), st, -1 );
              }
              count++;
            }
            i++;
          }
        }
        catch ( SQLException sqle ) {
          if ( useBatch ) {
            session.getBatcher().abortBatch( sqle );
          }
          throw sqle;
        }
        finally {
          if ( !useBatch ) {
            session.getBatcher().closeStatement( st );
          }
        }
      }
     
      if ( isRowInsertEnabled() ) {
        Expectation expectation = Expectations.appropriateExpectation( getInsertCheckStyle() );
        boolean callable = isInsertCallable();
        boolean useBatch = expectation.canBeBatched();
        String sql = getSQLInsertRowString();
        PreparedStatement st = null;
        // now update all changed or added rows fks
        try {
          int i = 0;
          Iterator entries = collection.entries( this );
          while ( entries.hasNext() ) {
            Object entry = entries.next();
            int offset = 1;
            if ( collection.needsUpdating( entry, i, elementType ) ) {
              if ( useBatch ) {
                if ( st == null ) {
                  if ( callable ) {
                    st = session.getBatcher().prepareBatchCallableStatement( sql );
                  }
                  else {
                    st = session.getBatcher().prepareBatchStatement( sql );
                  }
                }
              }
              else {
                if ( callable ) {
                  st = session.getBatcher().prepareCallableStatement( sql );
                }
                else {
                  st = session.getBatcher().prepareStatement( sql );
                }
              }

              offset += expectation.prepare( st );

              int loc = writeKey( st, id, offset, session );
              if ( hasIndex && !indexContainsFormula ) {
                loc = writeIndexToWhere( st, collection.getIndex( entry, i, this ), loc, session );
              }

              writeElementToWhere( st, collection.getElement( entry ), loc, session );

              if ( useBatch ) {
                session.getBatcher().addToBatch( expectation );
              }
              else {
                expectation.verifyOutcome( st.executeUpdate(), st, -1 );
              }
              count++;
            }
            i++;
          }
View Full Code Here

Examples of org.hibernate.jdbc.Expectation

   
    if ( ArrayHelper.isAllFalse(elementColumnIsSettable) ) return 0;

    try {
      PreparedStatement st = null;
      Expectation expectation = Expectations.appropriateExpectation( getUpdateCheckStyle() );
      boolean callable = isUpdateCallable();
      boolean useBatch = expectation.canBeBatched();
      Iterator entries = collection.entries( this );
      String sql = getSQLUpdateRowString();
      int i = 0;
      int count = 0;
      while ( entries.hasNext() ) {
        Object entry = entries.next();
        if ( collection.needsUpdating( entry, i, elementType ) ) {
          int offset = 1;

          if ( useBatch ) {
            if ( st == null ) {
              if ( callable ) {
                st = session.getBatcher().prepareBatchCallableStatement( sql );
              }
              else {
                st = session.getBatcher().prepareBatchStatement( sql );
              }
            }
          }
          else {
            if ( callable ) {
              st = session.getBatcher().prepareCallableStatement( sql );
            }
            else {
              st = session.getBatcher().prepareStatement( sql );
            }
          }

          try {
            offset+= expectation.prepare( st );
            int loc = writeElement( st, collection.getElement( entry ), offset, session );
            if ( hasIdentifier ) {
              writeIdentifier( st, collection.getIdentifier( entry, i ), loc, session );
            }
            else {
              loc = writeKey( st, id, loc, session );
              if ( hasIndex && !indexContainsFormula ) {
                writeIndexToWhere( st, collection.getIndex( entry, i, this ), loc, session );
              }
              else {
                writeElementToWhere( st, collection.getSnapshotElement( entry, i ), loc, session );
              }
            }

            if ( useBatch ) {
              session.getBatcher().addToBatch( expectation );
            }
            else {
              expectation.verifyOutcome( st.executeUpdate(), st, -1 );
            }
          }
          catch ( SQLException sqle ) {
            if ( useBatch ) {
              session.getBatcher().abortBatch( sqle );
View Full Code Here

Examples of org.hibernate.jdbc.Expectation

      if ( j == 0 && isVersioned() ) {
        log.trace( "Version: " + Versioning.getVersion( fields, this ) );
      }
    }

    Expectation expectation = Expectations.appropriateExpectation( insertResultCheckStyles[j] );
    boolean callable = isInsertCallable( j );
    // we can't batch joined inserts, *especially* not if it is an identity insert;
    // nor can we batch statements where the expectation is based on an output param
    final boolean useBatch = j == 0 && expectation.canBeBatched();
    try {

      // Render the SQL query
      final PreparedStatement insert;
      if ( useBatch ) {
        if ( callable ) {
          insert = session.getBatcher().prepareBatchCallableStatement( sql );
        }
        else {
          insert = session.getBatcher().prepareBatchStatement( sql );
        }
      }
      else {
        if ( callable ) {
          insert = session.getBatcher().prepareCallableStatement( sql );
        }
        else {
          insert = session.getBatcher().prepareStatement( sql );
        }
      }

      try {
        int index = 1;
        index += expectation.prepare( insert );

        // Write the values of fields onto the prepared statement - we MUST use the state at the time the
        // insert was issued (cos of foreign key constraints). Not necessarily the object's current state

        dehydrate( id, fields, null, notNull, propertyColumnInsertable, j, insert, session, index );

        if ( useBatch ) {
          // TODO : shouldnt inserts be Expectations.NONE?
          session.getBatcher().addToBatch( expectation );
        }
        else {
          expectation.verifyOutcome( insert.executeUpdate(), insert, -1 );
        }

      }
      catch ( SQLException sqle ) {
        if ( useBatch ) {
View Full Code Here

Examples of org.hibernate.jdbc.Expectation

          final Object object,
          final String sql,
          final SessionImplementor session) throws HibernateException {

    final boolean useVersion = j == 0 && isVersioned();
    final Expectation expectation = Expectations.appropriateExpectation( updateResultCheckStyles[j] );
    final boolean callable = isUpdateCallable( j );
    final boolean useBatch = j == 0 && expectation.canBeBatched() && isBatchable(); //note: updates to joined tables can't be batched...

    if ( log.isTraceEnabled() ) {
      log.trace( "Updating entity: " + MessageHelper.infoString( this, id, getFactory() ) );
      if ( useVersion ) {
        log.trace( "Existing version: " + oldVersion + " -> New version: " + fields[getVersionProperty()] );
      }
    }

    try {

      int index = 1; // starting index
      final PreparedStatement update;
      if ( useBatch ) {
        if ( callable ) {
          update = session.getBatcher().prepareBatchCallableStatement( sql );
        }
        else {
          update = session.getBatcher().prepareBatchStatement( sql );
        }
      }
      else {
        if ( callable ) {
          update = session.getBatcher().prepareCallableStatement( sql );
        }
        else {
          update = session.getBatcher().prepareStatement( sql );
        }
      }

      try {

        index+= expectation.prepare( update );

        //Now write the values of fields onto the prepared statement
        index = dehydrate( id, fields, rowId, includeProperty, propertyColumnUpdateable, j, update, session, index );

        // Write any appropriate versioning conditional parameters
View Full Code Here

Examples of org.hibernate.jdbc.Expectation

      return;
    }

    final boolean useVersion = j == 0 && isVersioned();
    final boolean callable = isDeleteCallable( j );
    final Expectation expectation = Expectations.appropriateExpectation( deleteResultCheckStyles[j] );
    final boolean useBatch = j == 0 && isBatchable() && expectation.canBeBatched();

    if ( log.isTraceEnabled() ) {
      log.trace( "Deleting entity: " + MessageHelper.infoString( this, id, getFactory() ) );
      if ( useVersion ) {
        log.trace( "Version: " + version );
      }
    }

    if ( isTableCascadeDeleteEnabled( j ) ) {
      if ( log.isTraceEnabled() ) {
        log.trace( "delete handled by foreign key constraint: " + getTableName( j ) );
      }
      return; //EARLY EXIT!
    }

    try {

      //Render the SQL query
      PreparedStatement delete;
      int index = 1;
      if ( useBatch ) {
        if ( callable ) {
          delete = session.getBatcher().prepareBatchCallableStatement( sql );
        }
        else {
          delete = session.getBatcher().prepareBatchStatement( sql );
        }
      }
      else {
        if ( callable ) {
          delete = session.getBatcher().prepareCallableStatement( sql );
        }
        else {
          delete = session.getBatcher().prepareStatement( sql );
        }
      }

      try {

        index += expectation.prepare( delete );

        // Do the key. The key is immutable so we can use the _current_ object state - not necessarily
        // the state at the time the delete was issued
        getIdentifierType().nullSafeSet( delete, id, index, session );
        index += getIdentifierColumnSpan();
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.