// Path: tanaguru-survey-impl/src/test/java/org/opens/tanaguru/survey/test/util/DecoratorFactory.java
// public final class DecoratorFactory {
// 
//     public static UserDataServiceDecorator getUserDataServiceDecorator() {
//         UserDataServiceDecoratorImpl udsd =
//                 new UserDataServiceDecoratorImpl(new UserDataServiceMock());
//         udsd.setEntityDao(new UserDAOMock());
//         return udsd;
//     }
// 
//     public static ContractDataServiceDecorator getContractDataServiceDecorator() {
//         ContractDataServiceDecoratorImpl cdsd =
//                 new ContractDataServiceDecoratorImpl(new ContractDataServiceMock());
//         cdsd.setEntityDao(new ContractDAOMock());
//         return cdsd;
//     }
//     
// }
// 
// Path: tanaguru-survey-impl/src/test/java/org/opens/tanaguru/survey/test/util/EntityFactory.java
// public final class EntityFactory {
// 
//     /**
//      *
//      * @param id
//      * @param email
//      * @param name
//      * @param firstName
//      * @param isActivated
//      * @return
//      */
//     public static User createUser (
//             Long id,
//             String email,
//             String name,
//             String firstName,
//             boolean isActivated)  {
//         User user = new UserImpl();
//         user.setId(id);
//         user.setEmail1(email);
//         user.setName(name);
//         user.setFirstName(firstName);
//         user.setAccountActivation(isActivated);
//         return user;
//     }
// 
//     /**
//      *
//      * @param url
//      * @param label
//      * @param user
//      * @param product
//      * @return
//      */
//     public static Contract createContract (String url, String label, User user, Product product)  {
//         Contract contract = new ContractImpl();
//         contract.setLabel(label);
//         contract.setUrl(url);
//         contract.setUser(user);
//         contract.setProduct(product);
//         return contract;
//     }
// 
//     /**
//      * 
//      * @param code
//      * @param label
//      * @return
//      */
//     public static Product createProduct (String code, String label)  {
//         Product contract = new ProductImpl();
//         contract.setLabel(label);
//         contract.setCode(code);
//         return contract;
//     }
// 
//     public static Collection<Contract> getContractCollection() {
//         Contract contract1 = new ContractImpl();
//         contract1.setUrl("http://www.mock-url1.org/");
//         Contract contract2 = new ContractImpl();
//         contract2.setUrl("http://www.mock-url2.org/");
//         Contract contract3 = new ContractImpl();
//         contract3.setUrl(null);
//         Contract contract4 = new ContractImpl();
//         contract4.setUrl("");
//         Collection<Contract> contractSet = new HashSet<Contract>();
//         contractSet.add(contract1);
//         contractSet.add(contract2);
//         contractSet.add(contract3);
//         contractSet.add(contract4);
//         return contractSet;
//     }
//     
// }
// 
// Path: tanaguru-survey-api/src/main/java/org/opens/tanaguru/survey/view/data/ContractResult.java
// public interface ContractResult {
// 
//     /**
//      *
//      * @return
//      */
//     String getLabel();
// 
//     /**
//      *
//      * @param label
//      */
//     void setLabel(String label);
// 
//     /**
//      * 
//      * @return
//      */
//     String getUrl();
//     
//     /**
//      *
//      * @param url
//      */
//     void setUrl(String url);
// 
//     /**
//      *
//      * @return
//      */
//     int getMark();
// 
//     /**
//      * 
//      * @param mark
//      */
//     void setMark(int mark);
// 
//     /**
//      *
//      * @return
//      */
//     Long getWebResourceId();
// 
//     /**
//      * 
//      * @param webResourceId
//      */
//     void setWebResourceId(Long webResourceId);
// 
// }


import java.util.Collection;
import junit.framework.TestCase;
import org.opens.tanaguru.survey.test.util.DecoratorFactory;
import org.opens.tanaguru.survey.test.util.EntityFactory;
import org.opens.tanaguru.survey.view.data.ContractResult;
import org.opens.tgol.entity.contract.Contract;
import org.opens.tgol.entity.product.Product;
import org.opens.tgol.entity.user.User;
/*
 * Tanaguru - Automated webpage assessment
 * Copyright (C) 2008-2011  Open-S Company
 *
 * This file is part of Tanaguru.
 *
 * Tanaguru is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contact us by mail: open-s AT open-s DOT com
 */
package org.opens.tanaguru.entity.decorator.tgol.contract;


/**
 *
 * @author jkowalczyk
 */
public class ContractDataServiceDecoratorImplTest extends TestCase {
    
    public ContractDataServiceDecoratorImplTest(String testName) {
        super(testName);
    }

    public void testGetNumberOfContractsFromPrefix() {
        ContractDataServiceDecorator udsd = DecoratorFactory.getContractDataServiceDecorator();
        assertEquals(4, udsd.getNumberOfContractsFromPrefix("mock-label-dao"));
        assertEquals(0, udsd.getNumberOfContractsFromPrefix("mock-label-data-service"));
    }

    public void testGetTopNContractsFromListUser() {
        ContractDataServiceDecorator udsd = DecoratorFactory.getContractDataServiceDecorator();
        Collection<ContractResult> contractResultCollection = udsd.getTopNContractsFromListUser("user1@tanaguru.org", 2);
        assertEquals(2, contractResultCollection.size());
        int i=1;
// Path: tanaguru-survey-impl/src/test/java/org/opens/tanaguru/survey/test/util/DecoratorFactory.java
// public final class DecoratorFactory {
// 
//     public static UserDataServiceDecorator getUserDataServiceDecorator() {
//         UserDataServiceDecoratorImpl udsd =
//                 new UserDataServiceDecoratorImpl(new UserDataServiceMock());
//         udsd.setEntityDao(new UserDAOMock());
//         return udsd;
//     }
// 
//     public static ContractDataServiceDecorator getContractDataServiceDecorator() {
//         ContractDataServiceDecoratorImpl cdsd =
//                 new ContractDataServiceDecoratorImpl(new ContractDataServiceMock());
//         cdsd.setEntityDao(new ContractDAOMock());
//         return cdsd;
//     }
//     
// }
// 
// Path: tanaguru-survey-impl/src/test/java/org/opens/tanaguru/survey/test/util/EntityFactory.java
// public final class EntityFactory {
// 
//     /**
//      *
//      * @param id
//      * @param email
//      * @param name
//      * @param firstName
//      * @param isActivated
//      * @return
//      */
//     public static User createUser (
//             Long id,
//             String email,
//             String name,
//             String firstName,
//             boolean isActivated)  {
//         User user = new UserImpl();
//         user.setId(id);
//         user.setEmail1(email);
//         user.setName(name);
//         user.setFirstName(firstName);
//         user.setAccountActivation(isActivated);
//         return user;
//     }
// 
//     /**
//      *
//      * @param url
//      * @param label
//      * @param user
//      * @param product
//      * @return
//      */
//     public static Contract createContract (String url, String label, User user, Product product)  {
//         Contract contract = new ContractImpl();
//         contract.setLabel(label);
//         contract.setUrl(url);
//         contract.setUser(user);
//         contract.setProduct(product);
//         return contract;
//     }
// 
//     /**
//      * 
//      * @param code
//      * @param label
//      * @return
//      */
//     public static Product createProduct (String code, String label)  {
//         Product contract = new ProductImpl();
//         contract.setLabel(label);
//         contract.setCode(code);
//         return contract;
//     }
// 
//     public static Collection<Contract> getContractCollection() {
//         Contract contract1 = new ContractImpl();
//         contract1.setUrl("http://www.mock-url1.org/");
//         Contract contract2 = new ContractImpl();
//         contract2.setUrl("http://www.mock-url2.org/");
//         Contract contract3 = new ContractImpl();
//         contract3.setUrl(null);
//         Contract contract4 = new ContractImpl();
//         contract4.setUrl("");
//         Collection<Contract> contractSet = new HashSet<Contract>();
//         contractSet.add(contract1);
//         contractSet.add(contract2);
//         contractSet.add(contract3);
//         contractSet.add(contract4);
//         return contractSet;
//     }
//     
// }
// 
// Path: tanaguru-survey-api/src/main/java/org/opens/tanaguru/survey/view/data/ContractResult.java
// public interface ContractResult {
// 
//     /**
//      *
//      * @return
//      */
//     String getLabel();
// 
//     /**
//      *
//      * @param label
//      */
//     void setLabel(String label);
// 
//     /**
//      * 
//      * @return
//      */
//     String getUrl();
//     
//     /**
//      *
//      * @param url
//      */
//     void setUrl(String url);
// 
//     /**
//      *
//      * @return
//      */
//     int getMark();
// 
//     /**
//      * 
//      * @param mark
//      */
//     void setMark(int mark);
// 
//     /**
//      *
//      * @return
//      */
//     Long getWebResourceId();
// 
//     /**
//      * 
//      * @param webResourceId
//      */
//     void setWebResourceId(Long webResourceId);
// 
// }


// Path: tanaguru-survey-impl/src/test/java/org/opens/tanaguru/entity/decorator/tgol/contract/ContractDataServiceDecoratorImplTest.java
import java.util.Collection;
import junit.framework.TestCase;
import org.opens.tanaguru.survey.test.util.DecoratorFactory;
import org.opens.tanaguru.survey.test.util.EntityFactory;
import org.opens.tanaguru.survey.view.data.ContractResult;
import org.opens.tgol.entity.contract.Contract;
import org.opens.tgol.entity.product.Product;
import org.opens.tgol.entity.user.User;

/*
 * Tanaguru - Automated webpage assessment
 * Copyright (C) 2008-2011  Open-S Company
 *
 * This file is part of Tanaguru.
 *
 * Tanaguru is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contact us by mail: open-s AT open-s DOT com
 */
package org.opens.tanaguru.entity.decorator.tgol.contract;


/**
 *
 * @author jkowalczyk
 */
public class ContractDataServiceDecoratorImplTest extends TestCase {
    
    public ContractDataServiceDecoratorImplTest(String testName) {
        super(testName);
    }

    public void testGetNumberOfContractsFromPrefix() {
        ContractDataServiceDecorator udsd = DecoratorFactory.getContractDataServiceDecorator();
        assertEquals(4, udsd.getNumberOfContractsFromPrefix("mock-label-dao"));
        assertEquals(0, udsd.getNumberOfContractsFromPrefix("mock-label-data-service"));
    }

    public void testGetTopNContractsFromListUser() {
        ContractDataServiceDecorator udsd = DecoratorFactory.getContractDataServiceDecorator();
        Collection<ContractResult> contractResultCollection = udsd.getTopNContractsFromListUser("user1@tanaguru.org", 2);
        assertEquals(2, contractResultCollection.size());
        int i=1;
        for (ContractResult cr : contractResultCollection) {