Skip to content
Snippets Groups Projects
Commit f1b825ab authored by Piotr Gawron's avatar Piotr Gawron
Browse files

unit tests for InfoFrame

parent 98e7d4e9
No related branches found
No related tags found
1 merge request!704Unit tests for CellDesigner plugin module
......@@ -7,6 +7,7 @@ import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Box;
import javax.swing.BoxLayout;
......@@ -22,7 +23,7 @@ import org.apache.log4j.Logger;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
/**
* This class represent a frame that visualise MIRIAM data and notes for a
* This class represent a frame that visualize MIRIAM data and notes for a
* species. Only one instance of JFrame is stored in the class (only one window
* of this type can be created).
*
......@@ -65,7 +66,7 @@ public final class InfoFrame {
* Default class logger.
*/
@SuppressWarnings("unused")
private final Logger logger = Logger.getLogger(InfoFrame.class.getName());
private final Logger logger = Logger.getLogger(InfoFrame.class);
/**
* Instance of the JFrame representation of windows.
......@@ -86,7 +87,7 @@ public final class InfoFrame {
/**
* List of selected aliases.
*/
private ArrayList<PluginSpeciesAlias> species = new ArrayList<PluginSpeciesAlias>();
private List<PluginSpeciesAlias> species = new ArrayList<>();
/**
* Default constructor.
......@@ -145,7 +146,7 @@ public final class InfoFrame {
* @param species
* - species to be shown in the form
*/
public void setSpecies(ArrayList<PluginSpeciesAlias> species) {
public void setSpecies(List<PluginSpeciesAlias> species) {
this.species = species;
updateSpecies();
}
......@@ -270,4 +271,8 @@ public final class InfoFrame {
frame.setAlwaysOnTop(always);
}
public List<PluginSpeciesAlias> getSpecies() {
return species;
}
}
......@@ -5,9 +5,11 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import lcsb.mapviewer.cdplugin.copypaste.AllCopyPasteTests;
import lcsb.mapviewer.cdplugin.info.AllInfoTests;
@RunWith(Suite.class)
@SuiteClasses({ AllCopyPasteTests.class })
@SuiteClasses({ AllCopyPasteTests.class,
AllInfoTests.class })
public class AllCdPluginTests {
}
......@@ -75,7 +75,7 @@ public class CdPluginFunctions {
return list;
}
private PluginSpeciesAlias createSpeciesAlias(String id) {
protected PluginSpeciesAlias createSpeciesAlias(String id) {
PluginSpecies species = Mockito.mock(PluginSpecies.class);
Mockito.when(species.getId()).thenReturn(id);
Mockito.when(species.getAnnotationString()).thenReturn(rdfString);
......
package lcsb.mapviewer.cdplugin.info;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ InfoFrameTest.class })
public class AllInfoTests {
}
package lcsb.mapviewer.cdplugin.info;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.JScrollPane;
import org.apache.log4j.Logger;
import org.junit.Test;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
import lcsb.mapviewer.cdplugin.CdPluginFunctions;
public class InfoFrameTest extends CdPluginFunctions{
Logger logger = Logger.getLogger(InfoFrameTest .class);
@Test
public void testSetEmptySpeciesList() {
InfoFrame frame = InfoFrame.getInstance();
List<PluginSpeciesAlias> list = new ArrayList<>();
frame.setSpecies(list);
assertEquals(list, frame.getSpecies());
}
@Test
public void testSetNotEmptySpeciesList() {
InfoFrame frame = InfoFrame.getInstance();
frame.setSpecies(Arrays.asList(super.createSpeciesAlias("id"), super.createSpeciesAlias("id2")));
assertEquals(2, frame.getSpecies().size());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment