rule.getPermissions(); control.andReturn(Arrays.asList(new Permission[] { Permission.VOICEMAIL
rule.getPermissionNames(); control.andReturn(Arrays.asList(new String[] { Permission.VOICEMAIL.getName()
    public void testGenerateMultipleGateways() throws Exception {        Gateway[] gateways = new Gateway[GATEWAYS_LEN];        StringBuilder prefixBuilder = new StringBuilder();        for (int i = 0; i < gateways.length; i++) {            gateways[i] = new Gateway();            gateways[i].setUniqueId();            gateways[i].setAddress("10.1.2." + i);            gateways[i].setPrefix(prefixBuilder.toString());            prefixBuilder.append("2");        }        IMocksControl control = EasyMock.createControl();        IDialingRule rule = control.createMock(IDialingRule.class);        rule.getGateways();        control.andReturn(Arrays.asList(gateways));        rule.getName();        control.andReturn("testrule").times(gateways.length);        rule.getDescription();        control.andReturn(null).times(gateways.length);        for (int i = 0; i < gateways.length; i++) {            rule.getTransformedPatterns(gateways[i]);            String prefix = gateways[i].getPrefix();            control.andReturn(new String[] {                prefix + "555", prefix + "666", prefix + "777"            });        }        rule.getPermissions();        control.andReturn(Arrays.asList(new Permission[] {            Permission.VOICEMAIL        }));        control.replay();        AuthRules authRules = new AuthRules();        authRules.begin();        authRules.generate(rule);        authRules.end();        Document document = authRules.getDocument();        String domDoc = XmlUnitHelper.asString(document);        String hostMatchFormat = "/mappings/hostMatch[%d]/";        prefixBuilder = new StringBuilder();        for (int i = 0; i < gateways.length; i++) {            String hostMatch = String.format(hostMatchFormat, i + 1);            assertXpathEvaluatesTo(gateways[i].getAddress(), hostMatch + "hostPattern", domDoc);            String prefix = prefixBuilder.toString();            assertXpathEvaluatesTo(prefix + "555", hostMatch + "userMatch/userPattern", domDoc);            assertXpathEvaluatesTo(prefix + "666", hostMatch + "userMatch/userPattern[2]", domDoc);            assertXpathEvaluatesTo(prefix + "777", hostMatch + "userMatch/userPattern[3]", domDoc);            assertXpathEvaluatesTo("Voicemail", hostMatch                    + "/userMatch/permissionMatch/permission", domDoc);            prefixBuilder.append("2");        }        String lastHostMatch = "/mappings/hostMatch[6]/";        // "no access" match at the end of the file - just checks if paths are that        // testGenerateNoAccessRule tests if values are correct        for (int i = 0; i < gateways.length; i++) {            assertXpathExists(lastHostMatch + "hostPattern[" + (i + 1) + "]", domDoc);        }        assertXpathEvaluatesTo(".", lastHostMatch + "userMatch/userPattern", domDoc);        assertXpathEvaluatesTo("NoAccess",                lastHostMatch + "userMatch/permissionMatch/permission", domDoc);        control.verify();    }