//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowExceptionOnInvalidConfig() public virtual void ShouldThrowExceptionOnInvalidConfig() { string[] invalidConfigs = new string[] { "", ";", "(", ")", "()", ",", "\"", "\'", "groups", "min", "unknown", "unknown()", "unknown(something)", "min()", "min(2,5)", "groups()", "all(2)", "min(five)", "groups(group1_%)", "groups(group2_%)", "groups(group 2)", "%groups(group2)", "ta%gs(group2)", "ta-gs(group2)", "groups(group1),groups(group2)", "groups(group1);;groups(group2)", "groups(group1)+groups(group2)", "halt();groups(group)", "halt();halt()", "groups(group1);halt();groups(group2)", "groups(group1);groups(group2);halt();groups(group3)", "groups(group1) -> halt()", "halt() -> groups(group1)", "groups(group1) -> groups(group2) -> halt()", "groups(group1) -> halt() -> groups(group2)", "groups(group)->all()", "all()->all()", "groups(A)->all()->groups(B)" }; // when foreach (string invalidConfig in invalidConfigs) { try { Filter <ServerInfo> parsedFilter = FilterConfigParser.Parse(invalidConfig); fail(format("Config should have been invalid: '%s' but generated: %s", invalidConfig, parsedFilter)); } catch (InvalidFilterSpecification) { // expected } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static Policies load(org.neo4j.kernel.configuration.Config config, String pluginName, org.neo4j.logging.Log log) throws InvalidFilterSpecification internal static Policies Load(Config config, string pluginName, Log log) { Policies policies = new Policies(log); string prefix = PolicyPrefix(pluginName); IDictionary <string, string> rawConfig = config.Raw; //JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter: ISet <string> configKeys = rawConfig.Keys.Where(e => e.StartsWith(prefix)).collect(Collectors.toSet()); foreach (string configKey in configKeys) { string policyName = configKey.Substring(prefix.Length); string filterSpec = rawConfig[configKey]; Filter <ServerInfo> filter = FilterConfigParser.Parse(filterSpec); policies.AddPolicy(policyName, new FilteringPolicy(filter)); } return(policies); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldParseValidConfigs() public virtual void ShouldParseValidConfigs() { object[][] validConfigs = new object[][] { new object[] { "min(2);", filter().min(2).newRule().all().build() }, new object[] { "groups(5);", filter().groups("5").newRule().all().build() }, new object[] { "all()", filter().all().build() }, new object[] { "all() -> groups(5);", filter().groups("5").newRule().all().build() }, new object[] { "all() -> groups(5);all()", filter().groups("5").newRule().all().build() }, new object[] { "all() -> groups(A); all() -> groups(B); halt()", filter().groups("A").newRule().groups("B").build() }, new object[] { "groups(groupA);", filter().groups("groupA").newRule().all().build() }, new object[] { "groups(groupA,groupB); halt()", filter().groups("groupA", "groupB").build() }, new object[] { "groups ( groupA , groupB ); halt()", filter().groups("groupA", "groupB").build() }, new object[] { "groups(group1)->groups(group2); halt()", filter().groups("group1").groups("group2").build() }, new object[] { "groups(group1)->groups(group2); halt();", filter().groups("group1").groups("group2").build() }, new object[] { "groups(group-1)->groups(group-2); halt();", filter().groups("group-1").groups("group-2").build() }, new object[] { "groups(group1)->groups(group2)->min(4); groups(group3,group4)->min(2); halt();", filter().groups("group1").groups("group2").min(4).newRule().groups("group3", "group4").min(2).build() }, new object[] { "groups(group1,group2,group3,group4)->min(2); groups(group3,group4);", filter().groups("group1", "group2", "group3", "group4").min(2).newRule().groups("group3", "group4").newRule().all().build() } }; // when foreach (object[] validConfig in validConfigs) { string config = ( string )validConfig[0]; Filter expectedFilter = ( Filter )validConfig[1]; try { Filter <ServerInfo> parsedFilter = FilterConfigParser.Parse(config); assertEquals(format("Config '%s' should generate expected filter", config), expectedFilter, parsedFilter); } catch (InvalidFilterSpecification) { fail(format("Config should have been valid: '%s'", config)); } } }