/*
 * 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.experiment;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import ubic.gemma.model.common.description.ExternalDatabaseService;
import ubic.gemma.persistence.PersisterHelper;
import ubic.gemma.testing.BaseSpringContextTest;
import ubic.gemma.testing.TestPersistentObjectHelper;

/**
 * @author kelsey
 * @version $Id$
 */
public class ExpressionExperimentDeleteTest extends BaseSpringContextTest {

    private PersisterHelper persisterHelper;
    private ExternalDatabaseService externalDatabaseService;
    private ExpressionExperimentService svc;

    public void testExpressionExperimentDelete() {

        SessionFactory sessf = ( SessionFactory ) this.getBean( "sessionFactory" );
        Session sess = sessf.openSession();
        sess.beginTransaction();

        TestPersistentObjectHelper helper = new TestPersistentObjectHelper();
        helper.setPersisterHelper( this.persisterHelper );
        helper.setExternalDatabaseService( externalDatabaseService );

        ExpressionExperiment ee = helper.getTestExpressionExperimentWithAllDependencies();

        assertNotNull( svc.findById( ee.getId() ) );
        svc.delete( ee );
        assertEquals( svc.findById( ee.getId() ), null );

        // designElementDataVectors.size(); // lazy-load...
        sess.getTransaction().commit();
        sess.evict( ee );
        sess.close();

    }

    /**
     * @param externalDatabaseService the externalDatabaseService to set
     */
    public void setExternalDatabaseService( ExternalDatabaseService externalDatabaseService ) {
        this.externalDatabaseService = externalDatabaseService;
    }

    /**
     * @param persisterHelper the persisterHelper to set
     */
    public void setPersisterHelper( PersisterHelper persisterHelper ) {
        this.persisterHelper = persisterHelper;
    }

    /**
     * @param expressionExperimentService
     */
    public void setExpressionExperimentService( ExpressionExperimentService expressionExperimentService ) {
        this.svc = expressionExperimentService;
    }
}

@@ -692,16 +692,86 @@
 iment;%0A%0A
+import org.compass.spring.device.hibernate.SpringHibernate3GpsDevice;%0A
 import o
@@ -1321,16 +1321,246 @@
 e svc;%0A%0A
+    @Override%0A    protected void onSetUp() throws Exception %7B%0A        super.onSetUp();%0A        SpringHibernate3GpsDevice indexer = ( SpringHibernate3GpsDevice ) this.getBean( %22hibernateGpsDevice%22 );%0A        indexer.stop();%0A    %7D%0A%0A
     publ

test passes if we turn off compass indexing