/*
 * The Gemma project
 * 
 * Copyright (c) 2006 University of British Columbia
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package ubic.gemma.model.expression.bioAssayData;

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

import ubic.gemma.model.common.quantitationtype.QuantitationType;
import ubic.gemma.model.expression.arrayDesign.ArrayDesign;
import ubic.gemma.model.expression.bioAssay.BioAssay;
import ubic.gemma.model.expression.designElement.DesignElement;
import ubic.gemma.model.expression.experiment.ExpressionExperiment;
import ubic.gemma.testing.BaseTransactionalSpringContextTest;

/**
 * @author pavlidis
 * @version $Id$
 */
public class BioAssayDimensionDaoImplTest extends BaseTransactionalSpringContextTest {

    private static final int NUMTESTCOMPOSITESEQUENCES = 15;

    private static final int NUMTESTBIOASSAYS = 5;

    protected DesignElementDataVectorDao designElementDataVectorDao;

    protected BioAssayDimensionDao bioAssayDimensionDao;

    BioAssayDimension bad;

    @Override
    protected void onSetUpInTransaction() throws Exception {
        super.onSetUpInTransaction();

        List<BioAssay> bas = new ArrayList<BioAssay>();
        ExpressionExperiment ee = this.getTestPersistentExpressionExperiment();
        bad = ( BioAssayDimension ) bioAssayDimensionDao.create( BioAssayDimension.Factory.newInstance() );

        for ( int i = 0; i < NUMTESTBIOASSAYS; i++ ) {
            BioAssay ba = this.getTestPersistentBioAssay();
            ba.getBioAssayDimensions().add( bad );
            bas.add( ba );
        }

        bad.setDimensionBioAssays( bas );
        bioAssayDimensionDao.update( bad );

        ArrayDesign ad = this.getTestPersistentArrayDesign( NUMTESTCOMPOSITESEQUENCES );
        QuantitationType qt = this.getTestPersistentQuantitationType();

        for ( DesignElement de : ad.getCompositeSequences() ) {
            assert de.getId() != null;
            DesignElementDataVector dedv = DesignElementDataVector.Factory.newInstance();
            dedv.setDesignElement( de );
            dedv.setExpressionExperiment( ee );
            dedv.setQuantitationType( qt );
            dedv.setBioAssayDimension( bad );
            dedv.setData( new byte[] {} );
            dedv = ( DesignElementDataVector ) designElementDataVectorDao.create( dedv );
        }

    }

    public void testFindBioAssayDimension() {
        fail( "Not yet implemented" );
    }

    public void testFindOrCreateBioAssayDimension() {
        fail( "Not yet implemented" );
    }

    /**
     * Test for HQL query.
     */
    public void testFindDesignElementDataVectorsLong() {
        assertTrue( bad.getId() != null );
        Collection result = bioAssayDimensionDao.findDesignElementDataVectors( bad.getId() );
        assertEquals( NUMTESTCOMPOSITESEQUENCES, result.size() );
    }

    public void setBioAssayDimensionDao( BioAssayDimensionDao bioAssayDimensionDao ) {
        this.bioAssayDimensionDao = bioAssayDimensionDao;
    }

    public void setDesignElementDataVectorDao( DesignElementDataVectorDao designElementDataVectorDao ) {
        this.designElementDataVectorDao = designElementDataVectorDao;
    }

}

@@ -2879,32 +2879,34 @@
       %7D%0A%0A    %7D%0A%0A
+//
     public void 
@@ -2927,32 +2927,34 @@
 ayDimension() %7B%0A
+//
         fail( %22N
@@ -2972,31 +2972,37 @@
 emented%22 );%0A
+//
     %7D%0A
-%0A
+//%0A//
     public v
@@ -3039,24 +3039,26 @@
 mension() %7B%0A
+//
         fail
@@ -3080,24 +3080,26 @@
 emented%22 );%0A
+//
     %7D%0A%0A    /

comment out unimplemented tests