no.abmu.lise.domain.HsqlMemHibernate3VanillaTest.java Source code

Java tutorial

Introduction

Here is the source code for no.abmu.lise.domain.HsqlMemHibernate3VanillaTest.java

Source

/*$Id: HsqlMemHibernate3VanillaTest.java 13872 2009-05-29 05:50:58Z jens $*/
/*
 ****************************************************************************
 *                                                                          *
 *                   (c) Copyright 2008 ABM-utvikling                       *
 *                                                                          *
 * 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 2 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. http://www.gnu.org/licenses/gpl.html    *
 *                                                                          *
 ****************************************************************************
 */

package no.abmu.lise.domain;

import java.util.Currency;

import no.abmu.lise.domain.fixtures.OrgRegDbHibernate3TestFixture;
import no.abmu.organisationregister.domain.OrganisationUnit;
import no.abmu.test.domainmodels.hibernate3.AbstractCommonHibernate3Tester;
import no.abmu.test.domainmodels.hibernate3.VanillaTester;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.SessionFactory;

/**
 * HsqlMemHibernate3VanillaTest.
 * 
 * @author Jens Vindvad, Jens.Vindvad@abm-utvikling.no
 * @author Erlend verby; erlend.overby@hypatia.no
 * @author $Author: jens $
 * @version $Rev: 13872 $
 * @date $Date: 2009-05-29 07:50:58 +0200 (Fri, 29 May 2009) $
 * @copyright ABM-Utvikling
 */
public class HsqlMemHibernate3VanillaTest extends AbstractCommonHibernate3Tester {

    @SuppressWarnings("unused")
    private static final Log logger = (Log) LogFactory.getLog(HsqlMemHibernate3VanillaTest.class);

    protected void setUp() throws Exception {
        SessionFactory sessionFactory = OrgRegDbHibernate3TestFixture.createSessionFactory();
        setSessionFactory(sessionFactory);
        super.setUp();
    }

    public void testConsortium() throws Exception {
        Consortium consortium = new Consortium();
        VanillaTester.populatePersistLoadAndTesObject(session, consortium);
    }

    public void testLiseComment() throws Exception {
        LiseComment liseComment = new LiseComment();
        VanillaTester.populatePersistLoadAndTesObject(session, liseComment);
    }

    public void testPaymentToSupplier() throws Exception {
        Consortium consortium = new Consortium();
        PaymentToSupplier paymentToSupplier = new PaymentToSupplier();

        VanillaTester.populateObject(consortium);
        VanillaTester.persistObject(session, consortium);

        paymentToSupplier.setConsortium(consortium);
        VanillaTester.populatePersistLoadAndTesObject(session, paymentToSupplier);
    }

    public void testPaymentToSupplierByAddingToConsortium() throws Exception {
        Consortium consortium = new Consortium();
        PaymentToSupplier paymentToSupplier = new PaymentToSupplier();

        VanillaTester.populateObject(consortium);
        VanillaTester.populateObject(paymentToSupplier);

        consortium.addPaymentToSupplier(paymentToSupplier);

        VanillaTester.persistObject(session, consortium);
        VanillaTester.loadAndTestObject(session, paymentToSupplier);
    }

    public void testProduct() throws Exception {
        Consortium consortium = new Consortium();
        Product product = new Product();

        VanillaTester.populateObject(consortium);
        VanillaTester.populateObject(product);

        consortium.addProduct(product);

        VanillaTester.persistObject(session, consortium);
        VanillaTester.loadAndTestObject(session, product);
    }

    public void testLiseCommentForConsortium() throws Exception {
        Consortium consortium = new Consortium();
        LiseComment liseComment = new LiseComment();

        VanillaTester.populateObject(consortium);
        VanillaTester.populateObject(liseComment);

        consortium.addLiseComment(liseComment);

        VanillaTester.persistObject(session, consortium);
        VanillaTester.loadAndTestObject(session, liseComment);
    }

    public void testProductCustomerRelation() throws Exception {
        Consortium consortium = new Consortium();
        OrganisationUnit customer = new OrganisationUnit();
        Product product = new Product();

        VanillaTester.populateAndPersistObject(session, customer);
        VanillaTester.populateObject(consortium);
        VanillaTester.populateObject(product);
        consortium.addProduct(product);
        VanillaTester.persistObject(session, consortium);

        ProductCustomerRelation productCustomerRelation = new ProductCustomerRelation(product, customer);

        VanillaTester.populatePersistLoadAndTesObject(session, productCustomerRelation);
    }

    public void testInvoiceToCustomer() throws Exception {

        Consortium consortium = new Consortium();
        OrganisationUnit customer = new OrganisationUnit();
        Product product = new Product();

        VanillaTester.populateAndPersistObject(session, customer);
        VanillaTester.populateObject(consortium);
        VanillaTester.populateObject(product);
        consortium.addProduct(product);
        VanillaTester.persistObject(session, consortium);

        ProductCustomerRelation productCustomerRelation = new ProductCustomerRelation(product, customer);
        VanillaTester.populateAndPersistObject(session, productCustomerRelation);

        InvoiceToCustomer invoiceToCustomer = new InvoiceToCustomer();
        invoiceToCustomer.setCustomerInvoiceType(CustomerInvoiceType.SUBSCRIPTION_INVOICE);
        invoiceToCustomer.setProductCustomerRelation(productCustomerRelation);
        invoiceToCustomer.setCurrency(Currency.getInstance("USD"));

        VanillaTester.populatePersistLoadAndTesObject(session, invoiceToCustomer);
    }

    public void testInvoiceToCustomerByAddingToProductCustomerRelation() throws Exception {

        Consortium consortium = new Consortium();
        OrganisationUnit customer = new OrganisationUnit();
        Product product = new Product();

        VanillaTester.populateAndPersistObject(session, customer);
        VanillaTester.populateObject(consortium);
        VanillaTester.populateObject(product);
        consortium.addProduct(product);
        VanillaTester.persistObject(session, consortium);

        InvoiceToCustomer invoiceToCustomer = new InvoiceToCustomer();
        invoiceToCustomer.setCustomerInvoiceType(CustomerInvoiceType.SPECIAL_INVOICE);
        invoiceToCustomer.setCurrency(Currency.getInstance("NOK"));
        VanillaTester.populateObject(invoiceToCustomer);

        ProductCustomerRelation productCustomerRelation = new ProductCustomerRelation(product, customer);
        productCustomerRelation.addInvoicesToCustomer(invoiceToCustomer);

        VanillaTester.populatePersistLoadAndTesObject(session, productCustomerRelation);
    }

}