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

smartrics.rest.fitnesse.fixture.SlimRow Maven / Gradle / Ivy

Go to download

The RestFixture is a FitNesse (http://fitnesse.org) fixture that allows developers and/or product owners to write test fixtures for REST services with simplicity in mind. The idea is to write tests that are self documenting and easy to write and read, without the need to write Java code. The fixture allows test writers to express tests as actions (any of the allowed HTTP methods) to operate on resource URIs and express expectations on the content of the return code, headers and body. All without writing one single line of Java code. And it also works as a living/executable documentation of the API.

There is a newer version: 4.4
Show newest version
/*  Copyright 2011 Fabrizio Cannizzo
 *
 *  This file is part of RestFixture.
 *
 *  RestFixture (http://code.google.com/p/rest-fixture/) is free software:
 *  you can redistribute it and/or modify it under the terms of the
 *  GNU Lesser General Public License as published by the Free Software Foundation,
 *  either version 3 of the License, or (at your option) any later version.
 *
 *  RestFixture 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 Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with RestFixture.  If not, see .
 *
 *  If you want to contact the author please leave a comment here
 *  http://smartrics.blogspot.com/2008/08/get-fitnesse-with-some-rest.html
 */
package smartrics.rest.fitnesse.fixture;

import java.util.ArrayList;
import java.util.List;

import smartrics.rest.fitnesse.fixture.support.CellWrapper;
import smartrics.rest.fitnesse.fixture.support.RowWrapper;

/**
 * Wrapper class for a row when running with Slim.
 * 
 * @author smartrics
 * 
 */
public class SlimRow implements RowWrapper {

	private final List> row;

	/**
	 * @param rawRow a list of string representing the row cells as passed by Slim.
	 */
    public SlimRow(List rawRow) {
        this.row = new ArrayList>();
        for (String r : rawRow) {
            this.row.add(new SlimCell(r));
		}
	}

	public CellWrapper getCell(int c) {
        if (c < this.row.size()) {
            return this.row.get(c);
		}
		return null;
	}

    public int size() {
        if (row != null) {
            return row.size();
        }
        return 0;
    }

    /**
     * @return the row as list of strings.
     */
    public List asList() {
        List ret = new ArrayList();
        for (CellWrapper w : row) {
            ret.add(w.body());
        }
        return ret;
    }

    public CellWrapper removeCell(int c) {
        if (c < this.row.size()) {
            return this.row.remove(c);
        }
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy