All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.greenpepper.interpreter.flow.dowith.RejectRow Maven / Gradle / Ivy

There is a newer version: 4.2.4
Show newest version
/*
 * Copyright (c) 2006 Pyxis Technologies inc.
 *
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA,
 * or see the FSF site: http://www.fsf.org.
 */

package com.greenpepper.interpreter.flow.dowith;

import java.util.List;

import com.greenpepper.Call;
import com.greenpepper.Example;
import com.greenpepper.Specification;
import com.greenpepper.annotation.Annotations;
import com.greenpepper.call.Annotate;
import com.greenpepper.call.ResultIs;
import com.greenpepper.expectation.ShouldBe;
import com.greenpepper.interpreter.flow.AbstractRow;

import static com.greenpepper.expectation.ShouldBe.FALSE;
import static com.greenpepper.expectation.ShouldBe.instanceOf;
import com.greenpepper.reflect.Fixture;
import com.greenpepper.util.CollectionUtil;
import com.greenpepper.util.ExampleUtil;

/**
 * 

RejectRow class.

* * @author oaouattara * @version $Id: $Id */ public class RejectRow extends AbstractRow { /** *

matches.

* * @param keyword a {@link java.lang.String} object. * @return a boolean. */ public static boolean matches( String keyword ) { return "reject".equalsIgnoreCase( keyword ); } /** *

Constructor for RejectRow.

* * @param fixture a {@link com.greenpepper.reflect.Fixture} object. */ public RejectRow( Fixture fixture ) { super( fixture ); } /** {@inheritDoc} */ public void interpret( Specification table ) { Example row = table.nextExample(); Example reject = row.firstChild(); Action action = Action.parse( actionCells(row) ); Example first = CollectionUtil.first(keywordCells(row)); try { Call call = action.checkAgainst( fixture ); call.expect( ShouldBe.either( FALSE ).or( instanceOf( Exception.class ) ) ); call.will( Annotate.right( reject ) ).when( ResultIs.right() ); call.will( Annotate.wrong( reject ) ).when( ResultIs.wrong() ); call.will( Annotate.exception(first) ).when( ResultIs.exception() ); call.will( tallyStatistics( table ) ); call.execute(); } catch (Exception e) { reportException( table ); if (first != null) { first.annotate( Annotations.exception( e ) ); } else { reject.annotate( Annotations.exception(e) ); } } } private List keywordCells(Example row) { return CollectionUtil.odd( row.firstChild() ); } /** {@inheritDoc} */ public List actionCells(Example row) { return ExampleUtil.asList(row.at(0,1)); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy