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

import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import ubic.gemma.model.common.description.DatabaseEntry;
import ubic.gemma.testing.BaseSpringContextTest;

/**
 * @author pavlidis
 * @version $Id$
 */
public class BioMaterialDaoImplTest extends BaseSpringContextTest {

    private String searchkeyName;
    private String searchkeyAcc;

    @Autowired
    BioMaterialDao bioMaterialDao;

    @Before
    public void setup() {
        BioMaterial testbm = this.getTestPersistentBioMaterial();
        searchkeyName = testbm.getName();
        searchkeyAcc = testbm.getExternalAccession().getAccession();

        // create a couple more.
        this.getTestPersistentBioMaterial();
        this.getTestPersistentBioMaterial();
    }

    /**
     * Test method for
     * {@link ubic.gemma.model.expression.biomaterial.BioMaterialDaoImpl#find(ubic.gemma.model.expression.biomaterial.BioMaterial)}
     * .
     */
    @Test
    public final void testFindBioMaterial() {
        BioMaterial bm = BioMaterial.Factory.newInstance();
        bm.setName( searchkeyName );
        bm.setExternalAccession( DatabaseEntry.Factory.newInstance() );
        bm.getExternalAccession().setAccession( searchkeyAcc );
        BioMaterial found = this.bioMaterialDao.find( bm );
        assertTrue( found != null );
    }

    @Test
    public final void testFindBioMaterialByAccessionOnly() {
        BioMaterial bm = BioMaterial.Factory.newInstance();
        bm.setExternalAccession( DatabaseEntry.Factory.newInstance() );
        bm.getExternalAccession().setAccession( searchkeyAcc );
        BioMaterial found = this.bioMaterialDao.find( bm );
        assertTrue( found != null );
    }

    @Test
    public final void testFindBioMaterialByNameOnly() {
        BioMaterial bm = BioMaterial.Factory.newInstance();
        bm.setName( searchkeyName );
        BioMaterial found = this.bioMaterialDao.find( bm );
        assertTrue( found != null );
    }

}

@@ -1223,24 +1223,62 @@
 d setup() %7B%0A
+        log.info( %22Starting setup%22 );%0A
         BioM
@@ -1323,32 +1323,32 @@
 tBioMaterial();%0A
-
         searchke
@@ -1562,24 +1562,60 @@
 Material();%0A
+        log.info( %22Ending setup%22 );%0A
     %7D%0A%0A    /
@@ -1841,24 +1841,61 @@
 aterial() %7B%0A
+        log.info( %22Starting test%22 );%0A
         BioM
@@ -2282,32 +2282,69 @@
 cessionOnly() %7B%0A
+        log.info( %22Starting test%22 );%0A
         BioMater
@@ -2629,32 +2629,32 @@
    %7D%0A%0A    @Test%0A
-
     public final
@@ -2685,32 +2685,69 @@
 lByNameOnly() %7B%0A
+        log.info( %22Starting test%22 );%0A
         BioMater

debug logging for stalled tests