Util implements AccessControlConstants { @NotNull static String generateAceName(@NotNull ACE ace, int index) { String hint = (ace.isAllow()) ? "allow" : "deny"; if (index == 0) { return hint; } else { return hint + index; } } private  Util();   }
@Test public void testGenerateName() throws AccessControlException { ACE ace = new TestAce(true); String name = Util.generateAceName(ace, 0); assertTrue(name.startsWith(ALLOW)); assertEquals(ALLOW, name); assertEquals(name, Util.generateAceName(ace, 0)); name = Util.generateAceName(ace, 1); assertTrue(name.startsWith(ALLOW)); assertEquals(ALLOW + 1, name); assertEquals(name, Util.generateAceName(ace, 1)); }
@Test public void testGenerateName2() throws AccessControlException { ACE ace = new TestAce(false); String name = Util.generateAceName(ace, 0); assertTrue(name.startsWith(DENY)); assertEquals(DENY, name); assertEquals(name, Util.generateAceName(ace, 0)); name = Util.generateAceName(ace, 2); assertTrue(name.startsWith(DENY)); assertEquals(DENY + 2, name); assertEquals(name, Util.generateAceName(ace, 2)); }
@Test public void testGenerateNameDifferentAllow() throws Exception { ACE allow = new TestAce(false); ACE deny = new TestAce(true); assertNotEquals(Util.generateAceName(allow, 0), Util.generateAceName(deny, 0)); assertNotEquals(Util.generateAceName(allow, 1), Util.generateAceName(deny, 1)); assertNotEquals(Util.generateAceName(allow, 20), Util.generateAceName(deny, 20)); assertNotEquals(Util.generateAceName(allow, 0), Util.generateAceName(deny, 1)); assertNotEquals(Util.generateAceName(allow, 1), Util.generateAceName(deny, 20)); }