Package uk.ac.bbsrc.tgac.miso.core.test

Source Code of uk.ac.bbsrc.tgac.miso.core.test.NamingTests

/*
* Copyright (c) 2012. The Genome Analysis Centre, Norwich, UK
* MISO project contacts: Robert Davey, Mario Caccamo @ TGAC
* *********************************************************************
*
* This file is part of MISO.
*
* MISO 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 3 of the License, or
* (at your option) any later version.
*
* MISO 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.
*
* You should have received a copy of the GNU General Public License
* along with MISO.  If not, see <http://www.gnu.org/licenses/>.
*
* *********************************************************************
*/

package uk.ac.bbsrc.tgac.miso.core.test;

import junit.framework.Assert;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.ac.bbsrc.tgac.miso.core.data.Barcodable;
import uk.ac.bbsrc.tgac.miso.core.data.Library;
import uk.ac.bbsrc.tgac.miso.core.data.Sample;
import uk.ac.bbsrc.tgac.miso.core.data.Status;
import uk.ac.bbsrc.tgac.miso.core.data.impl.StatusImpl;
import uk.ac.bbsrc.tgac.miso.core.data.impl.illumina.IlluminaRun;
import uk.ac.bbsrc.tgac.miso.core.data.type.HealthType;
import uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType;
import uk.ac.bbsrc.tgac.miso.core.event.AlerterService;
import uk.ac.bbsrc.tgac.miso.core.event.ResponderService;
import uk.ac.bbsrc.tgac.miso.core.exception.MisoNamingException;
import uk.ac.bbsrc.tgac.miso.core.factory.DataObjectFactory;
import uk.ac.bbsrc.tgac.miso.core.factory.TgacDataObjectFactory;
import uk.ac.bbsrc.tgac.miso.core.service.naming.DefaultEntityNamingScheme;
import uk.ac.bbsrc.tgac.miso.core.service.naming.DefaultLibraryNamingScheme;
import uk.ac.bbsrc.tgac.miso.core.service.naming.DefaultSampleNamingScheme;
import uk.ac.bbsrc.tgac.miso.core.service.naming.MisoNamingScheme;

import java.util.HashSet;
import java.util.Set;

/**
* uk.ac.bbsrc.tgac.miso.core.test
* <p/>
* Info
*
* @author Rob Davey
* @date 26/09/11
* @since 0.1.2
*/
public class NamingTests {
  protected static final Logger log = LoggerFactory.getLogger(NamingTests.class);
  private DataObjectFactory dataObjectFactory;
  private MisoNamingScheme<Sample> sampleNamingScheme;
  private MisoNamingScheme<Library> libraryNamingScheme;

  @Before
  public void setUp() {
    dataObjectFactory = new TgacDataObjectFactory();
    sampleNamingScheme = new DefaultSampleNamingScheme();
    libraryNamingScheme = new DefaultLibraryNamingScheme();
  }

  @Test
  public void testSampleNaming() throws MisoNamingException {
    //DefaultEntityNamingScheme<Sample> entityNameValidationScheme = new DefaultEntityNamingScheme(Sample.class);
    Sample s = dataObjectFactory.getSample();
    s.setId(1L);
    String name = sampleNamingScheme.generateNameFor("name", s);
    s.setName(name);
    Assert.assertTrue(sampleNamingScheme.validateField("name", s.getName()));

    s.setAlias("RD_S1_Foo.bar");
    Assert.assertTrue(sampleNamingScheme.validateField("alias", s.getAlias()));

    log.info("Sample naming scheme valid");
  }

  @Test
  public void testLibraryNaming() throws MisoNamingException {
    //DefaultEntityNamingScheme<Library> entityNameValidationScheme = new DefaultEntityNamingScheme(Library.class);
    Library l = dataObjectFactory.getLibrary();
    l.setId(1L);
    String name = libraryNamingScheme.generateNameFor("name", l);
    l.setName(name);
    Assert.assertTrue(libraryNamingScheme.validateField("name", l.getName()));

    l.setAlias("RD_L1-1_Foo.bar");
    Assert.assertTrue(libraryNamingScheme.validateField("alias", l.getAlias()));

    log.info("Library naming scheme valid");
  }

  @After
  public void tearDown() {
    dataObjectFactory = null;
    sampleNamingScheme = null;
    libraryNamingScheme = null;
  }
}
TOP

Related Classes of uk.ac.bbsrc.tgac.miso.core.test.NamingTests

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.