예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLoadConfiguredPolicies() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLoadConfiguredPolicies()
        {
            // given
            string pluginName = "server_policies";

            object[][] input = new object[][]
            {
                new object[] { "asia_west", "groups(asia_west) -> min(2);" + "groups(asia) -> min(2);", filter().groups("asia_west").min(2).newRule().groups("asia").min(2).newRule().all().build() },
                new object[] { "asia_east", "groups(asia_east) -> min(2);" + "groups(asia) -> min(2);", filter().groups("asia_east").min(2).newRule().groups("asia").min(2).newRule().all().build() },
                new object[] { "asia_only", "groups(asia);" + "halt();", filter().groups("asia").build() }
            };

            Config config = Config.defaults();

            foreach (object[] row in input)
            {
                string policyName = ( string )row[0];
                string filterSpec = ( string )row[1];
                config.Augment(ConfigNameFor(pluginName, policyName), filterSpec);
            }

            // when
            Policies policies = FilteringPolicyLoader.Load(config, pluginName, mock(typeof(Log)));

            // then
            foreach (object[] row in input)
            {
                string policyName   = ( string )row[0];
                Policy loadedPolicy = policies.SelectFor(PolicyNameContext(policyName));
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") Policy expectedPolicy = new FilteringPolicy((org.neo4j.causalclustering.routing.load_balancing.filters.Filter<ServerInfo>) row[2]);
                Policy expectedPolicy = new FilteringPolicy((Filter <ServerInfo>)row[2]);
                assertEquals(expectedPolicy, loadedPolicy);
            }
        }
예제 #2
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || this.GetType() != o.GetType())
            {
                return(false);
            }
            FilteringPolicy that = ( FilteringPolicy )o;

            return(Objects.Equals(_filter, that._filter));
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowOverridingDefaultPolicy() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAllowOverridingDefaultPolicy()
        {
            Policies policies = new Policies(_log);

            string defaultPolicyName = Policies.DEFAULT_POLICY_NAME;
            Policy defaultPolicy     = new FilteringPolicy(new AnyGroupFilter("groupA", "groupB"));

            // when
            policies.AddPolicy(defaultPolicyName, defaultPolicy);
            Policy selectedPolicy = policies.SelectFor(emptyMap());

            // then
            assertEquals(defaultPolicy, selectedPolicy);
            assertNotEquals(Policies.DefaultPolicyConflict, selectedPolicy);
        }