Package com.fiveht.tick.api

Source Code of com.fiveht.tick.api.ProjectsServiceTest

/*
* Copyright (C) 2012 FiveHT Media Ltd.
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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, see <http://www.gnu.org/licenses/>.
*/
package com.fiveht.tick.api;

import com.csam.stubs.bdd.Spec;
import com.csam.stubs.bdd.Test;
import com.csam.stubs.bdd.When;
import com.csam.stubs.bdd.runner.JUnit4SpecRunner;
import java.util.ArrayList;
import java.util.Properties;
import org.junit.runner.RunWith;
//import static org.junit.Assert.*;

/**
* In order to run tests, you must create a properties file in the user.home
* directory named ".tickjavadesktop.tests.properties" which must contain the
* following:
* <p>
* <code>
* company=SomeCompany
* emailAddress=someone@somewhere.org
* password=changem
* </code>
*
* @author Nathan Crause
*/
@RunWith(JUnit4SpecRunner.class)
public class ProjectsServiceTest extends Spec {
   
    private Properties p;

    @Override
    public void before() throws Throwable {
//        System.out.println(System.getProperties());
//        for (Map.Entry entry : System.getProperties().entrySet()) {
//            System.out.println(entry.getKey() + "=" + entry.getValue());
//        }
        p = Utils.getProperties();
    }
   
    @Override public void prepare() {
        describe(ProjectsService.class,
                new When("requesting") {{
                    it("should return the correct path", new Test() {
                        @Override public void run() throws Throwable {
                            ProjectsService svc = stub(ProjectsService.class,
                                    p.getProperty("company"),
                                    p.getProperty("emailAddress"),
                                    p.getProperty("password"));

                            expectThat(svc.getPath()).equalTo("projects");
                        }
                    });

                    it("should return an ArrayList of projects", new Test() {
                        @Override public void run() throws Throwable {
                            ProjectsService svc = stub(ProjectsService.class,
                                    p.getProperty("company"),
                                    p.getProperty("emailAddress"),
                                    p.getProperty("password"));

                            Object result = svc.request();
                            expectThat(result).instanceOf(ArrayList.class);
                            expectThat(result).is().not().empty();
                            expectThat(((ArrayList) result).get(0)).instanceOf(Project.class);
                        }
                    });
                }}
        );
    }
}
TOP

Related Classes of com.fiveht.tick.api.ProjectsServiceTest

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.