Skip to content

Commit

Permalink
added junit tests for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
rsehr committed Jul 8, 2014
1 parent b83140c commit 5540c5b
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 12 deletions.
17 changes: 6 additions & 11 deletions Goobi/src/de/sub/goobi/helper/enums/PropertyType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down
42 changes: 42 additions & 0 deletions Goobi/test/src/de/sub/goobi/helper/enums/PropertyTypeTest.java
Original file line number Diff line number Diff line change
@@ -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());
}

}
27 changes: 27 additions & 0 deletions Goobi/test/src/de/sub/goobi/helper/enums/StepEditTypeTest.java
Original file line number Diff line number Diff line change
@@ -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));
}
}
59 changes: 59 additions & 0 deletions Goobi/test/src/de/sub/goobi/helper/enums/StepStatusTest.java
Original file line number Diff line number Diff line change
@@ -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());

}
}
3 changes: 2 additions & 1 deletion Goobi/test/src/de/sub/goobi/helper/enums/TestAll.java
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -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 {
}

0 comments on commit 5540c5b

Please sign in to comment.