ImportBehavior { public static String nameFromValue(int importBehavior) { switch (importBehavior) { case ImportBehavior.IGNORE: return NAME_IGNORE; case ImportBehavior.ABORT: return NAME_ABORT; case ImportBehavior.BESTEFFORT: return NAME_BESTEFFORT; default: throw new IllegalArgumentException("Invalid import behavior: " + importBehavior); } } 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 testNameFromValue() { assertEquals(ImportBehavior.NAME_ABORT, ImportBehavior.nameFromValue(ImportBehavior.ABORT)); assertEquals(ImportBehavior.NAME_IGNORE, ImportBehavior.nameFromValue(ImportBehavior.IGNORE)); assertEquals(ImportBehavior.NAME_BESTEFFORT, ImportBehavior.nameFromValue(ImportBehavior.BESTEFFORT)); }
@Test(expected = IllegalArgumentException.class) public void testNameFromInvalidValue() { ImportBehavior.nameFromValue(Integer.MAX_VALUE); }