Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the tests working in intellij with junit #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions src/characterization/ChromosomeBand.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package characterization;

public class ChromosomeBand {
public static enum Type {
public enum BandType {
BLACK, WHITE, GREY, CENTROMERE
};
}

private final Type type;
private final BandType type;
private final int length;

public ChromosomeBand(Type type, int length) {
if (type == this.type.CENTROMERE && length == 0) {
public ChromosomeBand(BandType type, int length) {
if (type == BandType.CENTROMERE && length == 0) {
throw new IllegalArgumentException("Length of a centromere band cannot be non-zero.");
}

this.type = type;
this.length = length;
}

public Type type() {
public BandType type() {
return type;
}

Expand Down
14 changes: 7 additions & 7 deletions src/idiogram/IdiogramMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.regex.Pattern;

import characterization.ChromosomeBand;
import characterization.ChromosomeBand.Type;
import characterization.ChromosomeBand.BandType;

/**
* Wrapper for a Java HashMap that maps an idiogram to a chromosome number.
Expand Down Expand Up @@ -60,7 +60,7 @@ private void idiogramSheetParser(File file) {

String token = null;
int chromosomeNumber = 0;
ChromosomeBand.Type bandType;
ChromosomeBand.BandType bandType;
int bandLength = 0;
ChromosomeBand band = null;
int resolution = 0;
Expand All @@ -85,22 +85,22 @@ private void idiogramSheetParser(File file) {
// End debug

if (token.toLowerCase().equals("white")) {
bandType = Type.WHITE;
bandType = BandType.WHITE;
bandLength = lineReader.nextInt();
band = new ChromosomeBand(bandType, bandLength);
newIdiogram.add(band);
} else if (token.toLowerCase().equals("black")) {
bandType = Type.BLACK;
bandType = BandType.BLACK;
bandLength = lineReader.nextInt();
band = new ChromosomeBand(bandType, bandLength);
newIdiogram.add(band);
} else if (token.toLowerCase().equals("grey")) {
bandType = Type.GREY;
bandType = BandType.GREY;
bandLength = lineReader.nextInt();
band = new ChromosomeBand(bandType, bandLength);
newIdiogram.add(band);
} else if (token.toLowerCase().equals("centromere")) {
bandType = Type.CENTROMERE;
bandType = BandType.CENTROMERE;
bandLength = lineReader.nextInt();
band = new ChromosomeBand(bandType, bandLength);
newIdiogram.add(band);
Expand All @@ -123,7 +123,7 @@ private void idiogramSheetParser(File file) {
* Gets the chromosome number that the requested idiogram maps to. If the idiogram requested is
* not in the list of keys then null is returned.
*
* @param i
* @param index
* Requested idiogram
* @return Chromosome number mapped to or null if the requested idiogram doesn't exist.
*/
Expand Down
136 changes: 68 additions & 68 deletions src/testing/TestShape.java
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
package testing;
import runner.ImageQueue;
import chromosome.ChromosomeCluster;
import chromosome.GeneticSlideImage;
import extraction.Extractor;
public class TestShape {
private static GeneticSlideImage image = null;
private static ChromosomeCluster cluster = null;
/**
* @param args
*/
public static void main(String[] args) {
String filename;
ImageQueue images = new ImageQueue();
// put new images in the queue and return the next image from the folder
// args
filename = images.getNextFile(args[0]);
// create a slideImage from the filename
GeneticSlideImage image = new GeneticSlideImage(filename);
Extractor extractor = new Extractor();
if (filename != null) {
// extract the background from the image
int shapeNum = extractor.removeBackground(image);
// extract the clusters from the image
shapeNum = extractor.findClusters(image);
// pass on the list of clusters
ChromosomeCluster testCluster = extractor.getClusterList().get(0);
// print out the first cluster in the list
extractor.getClusterList().get(0).clusterOut();
}
}
/**
* Returns the chromosome cluster object from an image.
*
* @param filename
* File containing cluster
* @return The chromosome cluster object
*/
public static ChromosomeCluster getCluster(String filename) {
image = new GeneticSlideImage(filename);
Extractor extractor = new Extractor();
ChromosomeCluster testCluster = null;
if (filename != null) {
// extract the background from the image
int shapeNum = extractor.removeBackground(image);
// extract the clusters from the image
shapeNum = extractor.findClusters(image);
// pass on the list of clusters
testCluster = extractor.getClusterList().get(0);
// print out the first cluster in the list
extractor.getClusterList().get(0).clusterOut();
}
return testCluster;
}
public static GeneticSlideImage getGeneticSlideImage() {
return image;
}
public static ChromosomeCluster getCluster() {
return cluster;
}
}
package testing;

import runner.ImageQueue;
import chromosome.ChromosomeCluster;
import chromosome.GeneticSlideImage;
import extraction.Extractor;

public class TestShape {
private static GeneticSlideImage image = null;
private static ChromosomeCluster cluster = null;

/**
* @param args
*/
public static void main(String[] args) {
String filename;
ImageQueue images = new ImageQueue();
// put new images in the queue and return the next image from the folder
// args
filename = images.getNextFile(args[0]);
// create a slideImage from the filename
GeneticSlideImage image = new GeneticSlideImage(filename);
Extractor extractor = new Extractor();
if (filename != null) {
// extract the background from the image
int shapeNum = extractor.removeBackground(image);
// extract the clusters from the image
shapeNum = extractor.findClusters(image);
// pass on the list of clusters
ChromosomeCluster testCluster = extractor.getClusterList().get(0);
// print out the first cluster in the list
extractor.getClusterList().get(0).clusterOut();
}
}

/**
* Returns the chromosome cluster object from an image.
*
* @param filename
* File containing cluster
* @return The chromosome cluster object
*/
public static ChromosomeCluster getCluster(String filename) {
image = new GeneticSlideImage(filename);
Extractor extractor = new Extractor();
ChromosomeCluster testCluster = null;
if (filename != null) {
// extract the background from the image
int shapeNum = extractor.removeBackground(image);
// extract the clusters from the image
shapeNum = extractor.findClusters(image);
// pass on the list of clusters
testCluster = extractor.getClusterList().get(0);
// print out the first cluster in the list
extractor.getClusterList().get(0).clusterOut();
}
return testCluster;
}

public static GeneticSlideImage getGeneticSlideImage() {
return image;
}

public static ChromosomeCluster getCluster() {
return cluster;
}

}
19 changes: 9 additions & 10 deletions test/basic_objects/AroundPixelTest.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package basic_objects;

import java.util.LinkedList;
import org.junit.Test;

import basic_objects.AroundPixel;
import junit.framework.TestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class AroundPixelTest extends TestCase {
protected void setUp() throws Exception {
super.setUp();

}
public class AroundPixelTest {

@Test
public void testGetPositionsBetweenNeg() {
LinkedList<Integer> posList = AroundPixel.getPositionsBetweenNeg(0, 4);
assertEquals(posList.size(), 3);
Expand All @@ -24,7 +23,7 @@ public void testGetPositionsBetweenNeg() {
assertFalse(posList.contains(0));

}

@Test
public void testGetPositionsBetweenPlus() {
LinkedList<Integer> posList = AroundPixel.getPositionsBetweenPlus(0, 4);
assertEquals(posList.size(), 3);
Expand All @@ -38,7 +37,7 @@ public void testGetPositionsBetweenPlus() {
assertFalse(posList.contains(0));

}

@Test
public void testGetOppisitPos() {
assertEquals(4, AroundPixel.getOppisitePos(0));
assertEquals(5, AroundPixel.getOppisitePos(1));
Expand All @@ -50,7 +49,7 @@ public void testGetOppisitPos() {
assertEquals(3, AroundPixel.getOppisitePos(7));

}

@Test
public void testHandleLoop() {
assertEquals(7, AroundPixel.handleLoop(-1));
assertEquals(6, AroundPixel.handleLoop(-2));
Expand Down
29 changes: 9 additions & 20 deletions test/basic_objects/IdiogramMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,33 @@
package basic_objects;

import java.io.File;

import characterization.ChromosomeBand;
import idiogram.IdiogramMap;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.fail;

/**
* @author Robert
*
*/
public class IdiogramMapTest extends TestCase {
public class IdiogramMapTest {

private IdiogramMap map;

/**
* @param name
*/
public IdiogramMapTest(String name) {
super(name);
map = new IdiogramMap(new File(".\\ChromosomeIdiogramSheet.csv"));
}

/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
}
@Before
public void setUp() throws Exception {
map = new IdiogramMap(new File(".\\ChromosomeIdiogramSheet.csv"));

/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
protected void tearDown() throws Exception {
super.tearDown();
}

/**
* Test method for {@link idiogram.IdiogramMap#get(Idiogram)}.
*/
@Test
public void testGet() {
// Chromosome chromosome = new Chromosome(10);
// chromosome.add(new ChromosomeBand(ChromosomeBand.Type.WHITE, 21));
Expand Down
17 changes: 7 additions & 10 deletions test/basic_objects/PointListTest.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package basic_objects;

import java.awt.Point;
import org.junit.Test;

import basic_objects.PointList;

import junit.framework.TestCase;

public class PointListTest extends TestCase {

protected void setUp() throws Exception {
super.setUp();
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class PointListTest{
@Test
public void testSetList() {
PointList tempList = new PointList(new Point(10, 2), 2);
tempList.addPoint(new Point(3, 2), 2);
Expand All @@ -27,7 +24,7 @@ public void testSetList() {
assertFalse(pointList.getList().contains(new Point(6, 10)));

}

@Test
public void testAddPoint() {
PointList tempList = new PointList(new Point(10, 2), 2);
assertTrue(tempList.addPoint(new Point(3, 2), 2));
Expand Down
Loading