ImportBehavior { public static int valueFromString(String behaviorString) { if (NAME_IGNORE.equalsIgnoreCase(behaviorString)) { return IGNORE; } else if (NAME_BESTEFFORT.equalsIgnoreCase(behaviorString)) { return BESTEFFORT; } else if (NAME_ABORT.equalsIgnoreCase(behaviorString)) { return ABORT; } else { log.error("Invalid behavior {} -> Using default: ABORT.", behaviorString); return ABORT; } } private  ImportBehavior(); static int valueFromString(String behaviorString); static String nameFromValue(int importBehavior); static final int IGNORE; static final int BESTEFFORT; static final int ABORT; static final String NAME_IGNORE; static final String NAME_BESTEFFORT; static final String NAME_ABORT; }
@Test public void testValueFromString() { assertEquals(ImportBehavior.ABORT, ImportBehavior.valueFromString(ImportBehavior.NAME_ABORT)); assertEquals(ImportBehavior.IGNORE, ImportBehavior.valueFromString(ImportBehavior.NAME_IGNORE)); assertEquals(ImportBehavior.BESTEFFORT, ImportBehavior.valueFromString(ImportBehavior.NAME_BESTEFFORT)); assertEquals(ImportBehavior.ABORT, ImportBehavior.valueFromString("invalid")); }