From 5540c5ba268ff1cc3c91128b5f8071e79e21209a Mon Sep 17 00:00:00 2001 From: Robert Sehr Date: Tue, 8 Jul 2014 09:18:27 +0200 Subject: [PATCH] added junit tests for enums --- .../sub/goobi/helper/enums/PropertyType.java | 17 ++---- .../goobi/helper/enums/PropertyTypeTest.java | 42 +++++++++++++ .../goobi/helper/enums/StepEditTypeTest.java | 27 +++++++++ .../goobi/helper/enums/StepStatusTest.java | 59 +++++++++++++++++++ .../de/sub/goobi/helper/enums/TestAll.java | 3 +- 5 files changed, 136 insertions(+), 12 deletions(-) create mode 100644 Goobi/test/src/de/sub/goobi/helper/enums/PropertyTypeTest.java create mode 100644 Goobi/test/src/de/sub/goobi/helper/enums/StepEditTypeTest.java create mode 100644 Goobi/test/src/de/sub/goobi/helper/enums/StepStatusTest.java diff --git a/Goobi/src/de/sub/goobi/helper/enums/PropertyType.java b/Goobi/src/de/sub/goobi/helper/enums/PropertyType.java index 1fe2d3b33..a297ff44c 100644 --- a/Goobi/src/de/sub/goobi/helper/enums/PropertyType.java +++ b/Goobi/src/de/sub/goobi/helper/enums/PropertyType.java @@ -88,11 +88,6 @@ public String getName() { return this.name.toLowerCase(); } - @SuppressWarnings("unused") - //here for jsf compatibility - private void setName(String name) { - } - @Override public java.lang.String toString() { return this.name(); @@ -111,12 +106,12 @@ public Boolean getShowInDisplay() { return showInDisplay; } - /** - * @param id the id to set - */ - public void setId(int id) { - this.id = id; - } +// /** +// * @param id the id to set +// */ +// public void setId(int id) { +// this.id = id; +// } /** * @return the id diff --git a/Goobi/test/src/de/sub/goobi/helper/enums/PropertyTypeTest.java b/Goobi/test/src/de/sub/goobi/helper/enums/PropertyTypeTest.java new file mode 100644 index 000000000..a67e1b015 --- /dev/null +++ b/Goobi/test/src/de/sub/goobi/helper/enums/PropertyTypeTest.java @@ -0,0 +1,42 @@ +package de.sub.goobi.helper.enums; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class PropertyTypeTest { + + @Test + public void testGetPropertyTypeByName() { + assertEquals(PropertyType.unknown, PropertyType.getByName("unknown")); + assertEquals(PropertyType.String, PropertyType.getByName("something")); + + } + + @Test + public void testGetPropertyTypeShowInDisplay() { + assertTrue(PropertyType.String.getShowInDisplay()); + assertFalse(PropertyType.unknown.getShowInDisplay()); + } + + @Test + public void testGetPropertyTypeGetId() { + assertEquals(0, PropertyType.unknown.getId()); + assertEquals(1, PropertyType.general.getId()); + } + + + @Test + public void testGetPropertyTypeById() { + assertEquals(PropertyType.unknown, PropertyType.getById(0)); + assertEquals(PropertyType.general, PropertyType.getById(1)); + + assertEquals(PropertyType.String, PropertyType.getById(666)); + } + + @Test + public void testGetPropertyTypeToString() { + assertEquals(PropertyType.unknown.getName(), PropertyType.unknown.toString()); + } + +} diff --git a/Goobi/test/src/de/sub/goobi/helper/enums/StepEditTypeTest.java b/Goobi/test/src/de/sub/goobi/helper/enums/StepEditTypeTest.java new file mode 100644 index 000000000..8c866b719 --- /dev/null +++ b/Goobi/test/src/de/sub/goobi/helper/enums/StepEditTypeTest.java @@ -0,0 +1,27 @@ +package de.sub.goobi.helper.enums; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import de.sub.goobi.helper.Helper; + +public class StepEditTypeTest { + + @Test + public void testStepEditTypeGetValue() { + assertTrue(StepEditType.UNNOWKN.getValue() == 0); + } + + @Test + public void testStepEditTypeGetTitle() { + assertEquals(Helper.getTranslation("unbekannt"), StepEditType.UNNOWKN.getTitle()); + } + + + @Test + public void testStepEditTypeGetTypeFromValue() { + assertEquals(StepEditType.MANUAL_SINGLE, StepEditType.getTypeFromValue(1)); + assertEquals(StepEditType.UNNOWKN, StepEditType.getTypeFromValue(666)); + } +} diff --git a/Goobi/test/src/de/sub/goobi/helper/enums/StepStatusTest.java b/Goobi/test/src/de/sub/goobi/helper/enums/StepStatusTest.java new file mode 100644 index 000000000..f8975fa56 --- /dev/null +++ b/Goobi/test/src/de/sub/goobi/helper/enums/StepStatusTest.java @@ -0,0 +1,59 @@ +package de.sub.goobi.helper.enums; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import de.sub.goobi.helper.Helper; + +public class StepStatusTest { + + @Test + public void testStepStatusGetValue() { + assertTrue(StepStatus.LOCKED.getValue() == 0); + } + + @Test + public void testStepStatusGetTitle() { + assertEquals(Helper.getTranslation("statusGesperrt"), StepStatus.LOCKED.getTitle()); + assertEquals(Helper.getTranslation("statusOffen"), StepStatus.OPEN.getTitle()); + assertEquals(Helper.getTranslation("statusInBearbeitung"), StepStatus.INWORK.getTitle()); + assertEquals(Helper.getTranslation("statusAbgeschlossen"), StepStatus.DONE.getTitle()); + } + + + @Test + public void testStepStatusGetSmallImagePath() { + assertEquals("images/status/red_10.gif", StepStatus.LOCKED.getSmallImagePath()); + assertEquals("images/status/orange_10.gif", StepStatus.OPEN.getSmallImagePath()); + assertEquals("images/status/yellow_10.gif", StepStatus.INWORK.getSmallImagePath()); + assertEquals("images/status/green_10.gif", StepStatus.DONE.getSmallImagePath()); + } + + @Test + public void testStepStatusGetBigImagePath() { + assertEquals("images/status/red_15a.gif", StepStatus.LOCKED.getBigImagePath()); + assertEquals("images/status/orange_15a.gif", StepStatus.OPEN.getBigImagePath()); + assertEquals("images/status/yellow_15a.gif", StepStatus.INWORK.getBigImagePath()); + assertEquals("images/status/green_15a.gif", StepStatus.DONE.getBigImagePath()); + } + + + @Test + public void testStepStatusGetStatusFromValue() { + assertEquals(StepStatus.LOCKED, StepStatus.getStatusFromValue(0)); + assertEquals(StepStatus.OPEN, StepStatus.getStatusFromValue(1)); + assertEquals(StepStatus.INWORK, StepStatus.getStatusFromValue(2)); + assertEquals(StepStatus.DONE, StepStatus.getStatusFromValue(3)); + assertEquals(StepStatus.LOCKED, StepStatus.getStatusFromValue(666)); + } + + @Test + public void testStepStatusGetSearchString() { + assertEquals("steplocked", StepStatus.LOCKED.getSearchString()); + assertEquals("stepopen", StepStatus.OPEN.getSearchString()); + assertEquals("stepinwork", StepStatus.INWORK.getSearchString()); + assertEquals("stepdone", StepStatus.DONE.getSearchString()); + + } +} diff --git a/Goobi/test/src/de/sub/goobi/helper/enums/TestAll.java b/Goobi/test/src/de/sub/goobi/helper/enums/TestAll.java index f9124e9a4..c6f936df7 100644 --- a/Goobi/test/src/de/sub/goobi/helper/enums/TestAll.java +++ b/Goobi/test/src/de/sub/goobi/helper/enums/TestAll.java @@ -1,4 +1,5 @@ package de.sub.goobi.helper.enums; + /** * This file is part of the Goobi Application - a Workflow tool for the support of mass digitization. * @@ -22,6 +23,6 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses({ HistoryEventTypeTest.class }) +@SuiteClasses({ HistoryEventTypeTest.class, PropertyTypeTest.class, StepEditTypeTest.class, StepStatusTest.class }) public class TestAll { }