public virtual void test_zipWithIndex_empty()
        {
            Stream <string> @base             = Stream.of();
            IList <ObjIntPair <string> > test = Guavate.zipWithIndex(@base).collect(Collectors.toList());

            assertEquals(test, ImmutableList.of());
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHavePredefinedRoles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHavePredefinedRoles()
        {
            // Given
            StartServerWithConfiguredUser();

            // When
            string method = "POST";
            string path   = "db/data/transaction/commit";

            HTTP.RawPayload payload  = HTTP.RawPayload.quotedJson("{'statements':[{'statement':'CALL dbms.security.listRoles()'}]}");
            HTTP.Response   response = HTTP.withBasicAuth("neo4j", "secret").request(method, Server.baseUri().resolve(path).ToString(), payload);

            // Then
            assertThat(response.Status(), equalTo(200));
            ArrayNode errors = ( ArrayNode )response.Get("errors");

            assertThat("Should have no errors", errors.size(), equalTo(0));
            ArrayNode results = ( ArrayNode )response.Get("results");
            ArrayNode data    = ( ArrayNode )results.get(0).get("data");

            assertThat("Should have 5 predefined roles", data.size(), equalTo(5));
            Stream <string> values = data.findValues("row").Select(row => row.get(0).asText());

            assertThat("Expected specific roles", values.collect(Collectors.toList()), hasItems("admin", "architect", "publisher", "editor", "reader"));
        }
        //-------------------------------------------------------------------------
        public virtual void test_stream_Iterable()
        {
            IEnumerable <string> iterable = Arrays.asList("a", "b", "c");
            IList <string>       test     = Guavate.stream(iterable).collect(Collectors.toList());

            assertEquals(test, ImmutableList.of("a", "b", "c"));
        }
        //-------------------------------------------------------------------------
        public virtual void test_zipWithIndex()
        {
            Stream <string> @base             = Stream.of("a", "b", "c");
            IList <ObjIntPair <string> > test = Guavate.zipWithIndex(@base).collect(Collectors.toList());

            assertEquals(test, ImmutableList.of(ObjIntPair.of("a", 0), ObjIntPair.of("b", 1), ObjIntPair.of("c", 2)));
        }
        public virtual void test_zip_empty()
        {
            Stream <string>             base1 = Stream.of();
            Stream <int>                base2 = Stream.of();
            IList <Pair <string, int> > test  = Guavate.zip(base1, base2).collect(Collectors.toList());

            assertEquals(test, ImmutableList.of());
        }
        public virtual void test_zip_secondLonger()
        {
            Stream <string>             base1 = Stream.of("a", "b");
            Stream <int>                base2 = Stream.of(1, 2, 3);
            IList <Pair <string, int> > test  = Guavate.zip(base1, base2).collect(Collectors.toList());

            assertEquals(test, ImmutableList.of(Pair.of("a", 1), Pair.of("b", 2)));
        }
        public virtual void test_stream_Optional()
        {
            Optional <string> optional = "foo";
            IList <string>    test1    = Guavate.stream(optional).collect(Collectors.toList());

            assertEquals(test1, ImmutableList.of("foo"));

            Optional <string> empty = null;
            IList <string>    test2 = Guavate.stream(empty).collect(Collectors.toList());

            assertEquals(test2, ImmutableList.of());
        }
Esempio n. 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnSecurityContextRoles()
        public virtual void ShouldReturnSecurityContextRoles()
        {
            IList <UserResult> infoList = _procedures.showCurrentUser().collect(Collectors.toList());

            assertThat(infoList.Count, equalTo(1));

            UserResult row = infoList[0];

            assertThat(row.Username, equalTo("pearl"));
            assertThat(row.Roles, containsInAnyOrder("jammer"));
            assertThat(row.Flags, empty());
        }
Esempio n. 9
0
        public virtual Optional <CoreClusterMember> RandomCoreMember(bool mustBeStarted)
        {
            Stream <CoreClusterMember> members = CoreMembers().stream();

            if (mustBeStarted)
            {
                members = members.filter(m => !m.Shutdown);
            }

            IList <CoreClusterMember> eligible = members.collect(Collectors.toList());

            return(Random(eligible));
        }
        public virtual void stream()
        {
            LegalEntityCurveGroup test        = LegalEntityCurveGroup.of(NAME1, REPO_CURVES, ISSUER_CURVES);
            IList <Curve>         expectedAll = ImmutableList.builder <Curve>().add(REPO_CURVE).add(ISSUER_CURVE1).add(ISSUER_CURVE2).add(ISSUER_CURVE3).build();

            test.ToList().containsAll(expectedAll);
            IList <Curve> expectedRepo = ImmutableList.builder <Curve>().add(REPO_CURVE).build();

            test.repoCurveStream().collect(Collectors.toList()).containsAll(expectedRepo);
            IList <Curve> expectedIssuer = ImmutableList.builder <Curve>().add(ISSUER_CURVE1).add(ISSUER_CURVE2).add(ISSUER_CURVE3).build();

            test.issuerCurveStream().collect(Collectors.toList()).containsAll(expectedIssuer);
        }
Esempio n. 11
0
        public ProcedureConfig(Config config)
        {
            this._defaultValue = config.GetValue(PROC_ALLOWED_SETTING_DEFAULT_NAME).map(object.toString).orElse("");

            string allowedRoles = config.GetValue(PROC_ALLOWED_SETTING_ROLES).map(object.toString).orElse("");

            this._matchers = Stream.of(allowedRoles.Split(SETTING_DELIMITER, true)).map(procToRoleSpec => procToRoleSpec.Split(MAPPING_DELIMITER)).filter(spec => spec.length > 1).map(spec =>
            {
                string[] roles = stream(spec[1].Split(ROLES_DELIMITER)).map(string.Trim).toArray(string[] ::new);
                return(new ProcMatcher(spec[0].Trim(), roles));
            }).collect(Collectors.toList());

            this._accessPatterns          = ParseMatchers(GraphDatabaseSettings.procedure_unrestricted.name(), config, PROCEDURE_DELIMITER, ProcedureConfig.compilePattern);
            this._whiteList               = ParseMatchers(GraphDatabaseSettings.procedure_whitelist.name(), config, PROCEDURE_DELIMITER, ProcedureConfig.compilePattern);
            this._defaultTemporalTimeZone = config.Get(GraphDatabaseSettings.db_temporal_timezone);
        }
Esempio n. 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void removingQueryInTheMiddleKeepsOrder()
        public virtual void RemovingQueryInTheMiddleKeepsOrder()
        {
            // Given
            ExecutingQuery query1 = CreateExecutingQuery(1, "query1");
            ExecutingQuery query2 = CreateExecutingQuery(2, "query2");
            ExecutingQuery query3 = CreateExecutingQuery(3, "query3");
            ExecutingQuery query4 = CreateExecutingQuery(4, "query4");
            ExecutingQuery query5 = CreateExecutingQuery(5, "query5");

            ExecutingQueryList list = ExecutingQueryList.EMPTY.push(query1).push(query2).push(query3).push(query4).push(query5);

            // When
            IList <ExecutingQuery> result = list.Remove(query3).queries().collect(Collectors.toList());

            // Then
            assertThat(result, equalTo(asList(query5, query4, query2, query1)));
        }
Esempio n. 13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void verifyIndexContents(org.neo4j.graphdb.GraphDatabaseService db, String index, String queryString, long[] entityIds, boolean queryNodes) throws Exception
        private void VerifyIndexContents(GraphDatabaseService db, string index, string queryString, long[] entityIds, bool queryNodes)
        {
            IList <long> expected  = Arrays.stream(entityIds).boxed().collect(Collectors.toList());
            string       queryCall = queryNodes ? QUERY_NODES : QUERY_RELS;

            using (Result result = Db.execute(format(queryCall, index, queryString)))
            {
                ISet <long> results = new HashSet <long>();
                while (result.MoveNext())
                {
                    results.Add((( Entity )result.Current.get(queryNodes ? NODE : RELATIONSHIP)).Id);
                }
                string errorMessage = errorMessage(results, expected) + " (" + db + ", leader is " + _cluster.awaitLeader() + ") query = " + queryString;
                assertEquals(errorMessage, expected.Count, results.Count);
                int i = 0;
                while (results.Count > 0)
                {
                    assertTrue(errorMessage, results.remove(expected[i++]));
                }
            }
        }
Esempio n. 14
0
            protected internal override void describeMismatchSafely(Exception item, Description mismatchDescription)
            {
                IList <string> suppressedExceptionStrings = Stream.of(item.Suppressed).map(ExceptionMatchers.exceptionWithMessageToString).collect(Collectors.toList());

                mismatchDescription.appendText("exception ").appendValue(item).appendText(" with suppressed ").appendValueList("[", ", ", "]", suppressedExceptionStrings).appendText(" does not contain ").appendValue(ExceptionWithMessageToString(_expectedSuppressed));
            }
Esempio n. 15
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void prepareIndex(GBPTree<KEY,VALUE> index, java.util.TreeSet<long> dataInIndex, java.util.Queue<long> toRemove, java.util.Queue<long> toAdd, java.util.Random random) throws java.io.IOException
            internal virtual void PrepareIndex(GBPTree <KEY, VALUE> index, SortedSet <long> dataInIndex, LinkedList <long> toRemove, LinkedList <long> toAdd, Random random)
            {
                IList <long> fullRange       = LongStream.range(MinRange, MaxRange).boxed().collect(Collectors.toList());
                IList <long> rangeOutOfOrder = ShuffleToNewList(fullRange, random);

                using (Writer <KEY, VALUE> writer = index.Writer())
                {
                    foreach (long?key in rangeOutOfOrder)
                    {
                        bool addForRemoval = random.NextDouble() > WritePercentage;
                        if (addForRemoval)
                        {
                            writer.Put(key(key), outerInstance.value(key.Value));
                            dataInIndex.Add(key);
                            toRemove.AddLast(key);
                        }
                        else
                        {
                            toAdd.AddLast(key);
                        }
                    }
                }
            }
Esempio n. 16
0
        /// <summary>
        /// Computes cash flow equivalent of swap.
        /// <para>
        /// The swap should be a fix-for-Ibor swap without compounding, and its swap legs
        /// should not involve {@code PaymentEvent}.
        /// </para>
        /// <para>
        /// The return type is {@code ResolvedSwapLeg} in which individual payments are
        /// represented in terms of {@code NotionalExchange}.
        ///
        /// </para>
        /// </summary>
        /// <param name="swap">  the swap product </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <returns> the cash flow equivalent </returns>
        public static ResolvedSwapLeg cashFlowEquivalentSwap(ResolvedSwap swap, RatesProvider ratesProvider)
        {
            validateSwap(swap);
            ResolvedSwapLeg cfFixed = cashFlowEquivalentFixedLeg(swap.getLegs(SwapLegType.FIXED).get(0), ratesProvider);
            ResolvedSwapLeg cfIbor  = cashFlowEquivalentIborLeg(swap.getLegs(SwapLegType.IBOR).get(0), ratesProvider);
            ResolvedSwapLeg leg     = ResolvedSwapLeg.builder().paymentEvents(Stream.concat(cfFixed.PaymentEvents.stream(), cfIbor.PaymentEvents.stream()).collect(Collectors.toList())).payReceive(PayReceive.RECEIVE).type(SwapLegType.OTHER).build();

            return(leg);
        }
Esempio n. 17
0
        protected internal override void Decode(ChannelHandlerContext ctx, ByteBuf @in, IList <object> @out)
        {
            int messageCode = @in.readInt();

            switch (messageCode)
            {
            case InitialMagicMessage.MESSAGE_CODE:
            {
                string magic = StringMarshal.unmarshal(@in);
                @out.Add(new InitialMagicMessage(magic));
                return;
            }

            case 1:
            {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                ApplicationProtocolRequest applicationProtocolRequest = DecodeProtocolRequest(ApplicationProtocolRequest::new, @in, ByteBuf.readInt);
                @out.Add(applicationProtocolRequest);
                return;
            }

            case 2:
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                ModifierProtocolRequest modifierProtocolRequest = DecodeProtocolRequest(ModifierProtocolRequest::new, @in, StringMarshal.unmarshal);
                @out.Add(modifierProtocolRequest);
                return;

            case 3:
            {
                string protocolName = StringMarshal.unmarshal(@in);
                int    version      = @in.readInt();
                int    numberOfModifierProtocols = @in.readInt();
                IList <Pair <string, string> > modifierProtocols = Stream.generate(() => Pair.of(StringMarshal.unmarshal(@in), StringMarshal.unmarshal(@in))).limit(numberOfModifierProtocols).collect(Collectors.toList());
                @out.Add(new SwitchOverRequest(protocolName, version, modifierProtocols));
                return;
            }

            default:
                // TODO
                return;
            }
        }
Esempio n. 18
0
        internal static ICollection <MemberId> RandomMembers(int size)
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            return(IntStream.range(0, size).mapToObj(i => System.Guid.randomUUID()).map(MemberId::new).collect(Collectors.toList()));
        }
Esempio n. 19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Parameterized.Parameters(name = "{0}") public static java.util.Collection<Parameters> data()
        public static ICollection <Parameters> Data()
        {
            Stream <Optional <Protocol_ModifierProtocol> > noModifierProtocols         = Stream.of(null);
            Stream <Optional <Protocol_ModifierProtocol> > individualModifierProtocols = Stream.of(Protocol_ModifierProtocols.values()).map(Optional.of);

            return(Stream.concat(noModifierProtocols, individualModifierProtocols).flatMap(protocol => Stream.of(Raft1WithCompressionModifier(protocol), Raft2WithCompressionModifiers(protocol))).collect(Collectors.toList()));
        }
Esempio n. 20
0
        private IList <Endpoint> RouteEndpoints(string dbName)
        {
            CoreTopology            filtered = _topologyService.allCoreServers().filterTopologyByDb(dbName);
            Stream <CoreServerInfo> filteredCoreMemberInfo = filtered.Members().Values.stream();

            return(filteredCoreMemberInfo.map(extractBoltAddress()).map(Endpoint.route).collect(Collectors.toList()));
        }
Esempio n. 21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") private void flatten(com.opengamma.strata.market.explain.ExplainMap explainMap, boolean parentVisible, java.util.Map<com.opengamma.strata.market.explain.ExplainKey<?>, Object> parentRow, java.util.Map<com.opengamma.strata.market.explain.ExplainKey<?>, Object> currentRow, int level, java.util.List<com.opengamma.strata.market.explain.ExplainMap> accumulator)
        private void flatten <T1, T2>(ExplainMap explainMap, bool parentVisible, IDictionary <T1> parentRow, IDictionary <T2> currentRow, int level, IList <ExplainMap> accumulator)
        {
            bool hasParentFlow = currentRow.ContainsKey(ExplainKey.FORECAST_VALUE);
            bool isFlow        = explainMap.get(ExplainKey.PAYMENT_DATE).Present;
            bool visible       = parentVisible || isFlow;

//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            ISet <ExplainKey <IList <ExplainMap> > > nestedListKeys = explainMap.Map.Keys.Where(k => explainMap.get(k).get().GetType().IsAssignableFrom(typeof(System.Collections.IList))).Select(k => (ExplainKey <IList <ExplainMap> >)k).collect(toImmutableSet());

            // Populate the base data
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (java.util.Map.Entry<com.opengamma.strata.market.explain.ExplainKey<?>, Object> entry : explainMap.getMap().entrySet())
            foreach (KeyValuePair <ExplainKey <object>, object> entry in explainMap.Map.entrySet())
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.market.explain.ExplainKey<?> key = entry.getKey();
                ExplainKey <object> key = entry.Key;

                if (nestedListKeys.Contains(key))
                {
                    continue;
                }
                if (key.Equals(ExplainKey.FORECAST_VALUE))
                {
                    if (hasParentFlow)
                    {
                        // Collapsed rows, so flow must be the same as we already have
                        continue;
                    }
                    else if (isFlow)
                    {
                        // This is first child flow row, so flow is equal to, and replaces, calculated amount
                        currentRow.Remove(INTERIM_AMOUNT_KEY);
                    }
                }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.market.explain.ExplainKey<?> mappedKey = mapKey(key, isFlow);
                ExplainKey <object> mappedKey = mapKey(key, isFlow);
                object mappedValue            = mapValue(mappedKey, entry.Value, level);
                if (isFlow)
                {
                    currentRow[mappedKey] = mappedValue;
                }
                else
                {
                    if (!currentRow.ContainsKey(mappedKey))
                    {
                        currentRow.Add(mappedKey, mappedValue);
                    }
                }
            }

            // Repeat the inherited entries from the parent row if this row hasn't overridden them
            INHERITED_KEYS.Where(parentRow.containsKey).ForEach(inheritedKey => currentRow.putIfAbsent(inheritedKey, parentRow[inheritedKey]));

            if (nestedListKeys.Count > 0)
            {
                IList <ExplainMap> nestedListEntries = nestedListKeys.stream().flatMap(k => explainMap.get(k).get().stream()).sorted(this.compareNestedEntries).collect(Collectors.toList());

                if (nestedListEntries.Count == 1)
                {
                    // Soak it up into this row
                    flatten(nestedListEntries[0], visible, currentRow, currentRow, level, accumulator);
                }
                else
                {
                    // Add child rows
                    foreach (ExplainMap nestedListEntry in nestedListEntries)
                    {
                        flatten(nestedListEntry, visible, currentRow, Maps.newHashMap(), level + 1, accumulator);
                    }
                    // Add parent row after child rows (parent flows are a result of the children)
                    if (visible)
                    {
                        accumulator.Add(ExplainMap.of(currentRow));
                    }
                }
            }
            else
            {
                if (visible)
                {
                    accumulator.Add(ExplainMap.of(currentRow));
                }
            }
        }
Esempio n. 22
0
            internal virtual IDictionary <int, string> DistributeHostsBetweenDatabases(int nHosts, IList <string> databases)
            {
                //Max number of hosts per database is (nHosts / nDatabases) or (nHosts / nDatabases) + 1
                int nDatabases  = databases.Count;
                int maxCapacity = (nHosts % nDatabases == 0) ? (nHosts / nDatabases) : (nHosts / nDatabases) + 1;

                IList <string> repeated = databases.stream().flatMap(db => IntStream.range(0, maxCapacity).mapToObj(ignored => db)).collect(Collectors.toList());

                IDictionary <int, string> mapping = new Dictionary <int, string>(nHosts);

                for (int hostId = 0; hostId < nHosts; hostId++)
                {
                    mapping[hostId] = repeated[hostId];
                }
                return(mapping);
            }
Esempio n. 23
0
        /// <summary>
        /// The par spread quotes are converted to points upfronts or quoted spreads.
        /// <para>
        /// The relevant discount curve and recovery rate curve must be stored in {@code ratesProvider}.
        /// The credit curve is internally calibrated to par spread values.
        /// </para>
        /// <para>
        /// {@code trades} must be sorted in ascending order in maturity and coherent to {@code quotes}.
        /// </para>
        /// <para>
        /// The resultant quote is specified by {@code targetConvention}.
        ///
        /// </para>
        /// </summary>
        /// <param name="trades">  the trades </param>
        /// <param name="quotes">  the quotes </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="targetConvention">  the target convention </param>
        /// <param name="refData">  the reference data </param>
        /// <returns> the quotes </returns>
        public virtual IList <CdsQuote> quotesFromParSpread(IList <ResolvedCdsTrade> trades, IList <CdsQuote> quotes, CreditRatesProvider ratesProvider, CdsQuoteConvention targetConvention, ReferenceData refData)
        {
            ArgChecker.noNulls(trades, "trades");
            ArgChecker.noNulls(quotes, "quotes");
            ArgChecker.notNull(ratesProvider, "ratesProvider");
            ArgChecker.notNull(targetConvention, "targetConvention");
            ArgChecker.notNull(refData, "refData");

            int nNodes = trades.Count;

            ArgChecker.isTrue(quotes.Count == nNodes, "trades and quotes must be the same size");
            quotes.ForEach(q => ArgChecker.isTrue(q.QuoteConvention.Equals(CdsQuoteConvention.PAR_SPREAD), "quote must be par spread"));
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            IEnumerator <StandardId> legalEntities = trades.Select(t => t.Product.LegalEntityId).collect(Collectors.toSet()).GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            StandardId legalEntityId = legalEntities.next();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            ArgChecker.isFalse(legalEntities.hasNext(), "legal entity must be common to trades");
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            IEnumerator <Currency> currencies = trades.Select(t => t.Product.Currency).collect(Collectors.toSet()).GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            Currency currency = currencies.next();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            ArgChecker.isFalse(currencies.hasNext(), "currency must be common to trades");

            LocalDate             valuationDate    = ratesProvider.ValuationDate;
            CreditDiscountFactors discountFactors  = ratesProvider.discountFactors(currency);
            RecoveryRates         recoveryRates    = ratesProvider.recoveryRates(legalEntityId);
            NodalCurve            creditCurve      = calibrator.calibrate(trades, DoubleArray.of(nNodes, q => quotes[q].QuotedValue), DoubleArray.filled(nNodes), CurveName.of("temp"), valuationDate, discountFactors, recoveryRates, refData);
            CreditRatesProvider   ratesProviderNew = ratesProvider.toImmutableCreditRatesProvider().toBuilder().creditCurves(ImmutableMap.of(Pair.of(legalEntityId, currency), LegalEntitySurvivalProbabilities.of(legalEntityId, IsdaCreditDiscountFactors.of(currency, valuationDate, creditCurve)))).build();

            System.Func <ResolvedCdsTrade, CdsQuote> quoteValueFunction = createQuoteValueFunction(ratesProviderNew, targetConvention, refData);
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            ImmutableList <CdsQuote> result = trades.Select(c => quoteValueFunction(c)).collect(Collectors.collectingAndThen(Collectors.toList(), ImmutableList.copyOf));

            return(result);
        }
Esempio n. 24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Parameterized.Parameters(name = "blocking={0} protocol={1}") public static Iterable<Object[]> params()
        public static IEnumerable <object[]> Params()
        {
            return(ClientRepositories().stream().flatMap(r => Stream.of(new object[] { true, r }, new object[] { false, r })).collect(Collectors.toList()));
        }
Esempio n. 25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Parameterized.Parameters(name = "{0}") public static Iterable<Object[]> parameters()
        public static IEnumerable <object[]> Parameters()
        {
            IList <object[]> inputs = Stream.generate(PrimitiveArraysUnionTest.randomInput).limit(300).collect(Collectors.toList());
            IList <object[]> manuallyDefinedValues = Arrays.asList(Lhs(1, 2, 3).rhs(1, 2, 3).expectLhs(), Lhs(1, 2, 3).rhs(1).expectLhs(), Lhs(1, 2, 3).rhs(2).expectLhs(), Lhs(1, 2, 3).rhs(3).expectLhs(), Lhs(1).rhs(1, 2, 3).expectRhs(), Lhs(2).rhs(1, 2, 3).expectRhs(), Lhs(3).rhs(1, 2, 3).expectRhs(), Lhs(1, 2, 3).rhs(4, 5, 6).expect(1, 2, 3, 4, 5, 6), Lhs(1, 3, 5).rhs(2, 4, 6).expect(1, 2, 3, 4, 5, 6), Lhs(1, 2, 3, 5).rhs(2, 4, 6).expect(1, 2, 3, 4, 5, 6), Lhs(2, 3, 4, 7, 8, 9, 12, 16, 19).rhs(4, 6, 9, 11, 12, 15).expect(2, 3, 4, 6, 7, 8, 9, 11, 12, 15, 16, 19), Lhs(10, 13).rhs(13, 18).expect(10, 13, 18), Lhs(13, 18).rhs(10, 13).expect(10, 13, 18));

            ((IList <object[]>)inputs).AddRange(manuallyDefinedValues);
            return(inputs);
        }
Esempio n. 26
0
        /// <summary>
        /// Perform index migrations </summary>
        /// <exception cref="ExplicitIndexMigrationException"> in case of exception during index migration </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void upgradeIndexes() throws ExplicitIndexMigrationException
        public virtual void UpgradeIndexes()
        {
            try
            {
                if (!Files.exists(_indexRootPath))
                {
                    return;
                }
                _monitor.starting(( int )Files.walk(_indexRootPath).count());
                using (Stream <Path> pathStream = Files.walk(_indexRootPath), IndexUpgraderWrapper lucene4Upgrader = CreateIndexUpgrader(Lucene4JarPaths), IndexUpgraderWrapper lucene5Upgrader = CreateIndexUpgrader(Lucene5JarPaths))
                {
                    IList <Path> indexPaths = pathStream.filter(IndexPathFilter).collect(Collectors.toList());
                    foreach (Path indexPath in indexPaths)
                    {
                        try
                        {
                            lucene4Upgrader.UpgradeIndex(indexPath);
                            lucene5Upgrader.UpgradeIndex(indexPath);
                            _monitor.migrated(indexPath.toFile().Name);
                        }
                        catch (Exception e)
                        {
                            throw new ExplicitIndexMigrationException(indexPath.FileName.ToString(), "Migration of explicit index at path:" + indexPath + " failed.", e);
                        }
                    }
                }
            }
            catch (ExplicitIndexMigrationException ime)
            {
                throw ime;
            }
            catch (Exception e)
            {
                throw new Exception("Lucene explicit indexes migration failed.", e);
            }
        }
Esempio n. 27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIncludeProtocolsInSelectionWithVersionsLimitedByThoseExisting()
        public virtual void ShouldIncludeProtocolsInSelectionWithVersionsLimitedByThoseExisting()
        {
            // given
            int?[]      expectedRaftVersions   = TestProtocols_TestApplicationProtocols.allVersionsOf(RAFT);
            IList <int> configuredRaftVersions = Stream.concat(Stream.of(expectedRaftVersions), Stream.of(int.MaxValue)).collect(Collectors.toList());

            // when
            ProtocolSelection <int, Org.Neo4j.causalclustering.protocol.Protocol_ApplicationProtocol> protocolSelection = _applicationProtocolRepository.getAll(RAFT, configuredRaftVersions);

            // then
            assertThat(protocolSelection.Versions(), Matchers.containsInAnyOrder(expectedRaftVersions));
        }
Esempio n. 28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void randomCoreDoesNotReturnSameCoreTwice()
        public virtual void RandomCoreDoesNotReturnSameCoreTwice()
        {
            // given counter always core member
            TypicallyConnectToRandomReadReplicaStrategy connectionStrategy = new TypicallyConnectToRandomReadReplicaStrategy(1);

            // and
            MemberId        firstOther      = new MemberId(new System.Guid(12, 34));
            MemberId        secondOther     = new MemberId(new System.Guid(56, 78));
            TopologyService topologyService = fakeTopologyService(fakeCoreTopology(Myself, firstOther, secondOther), fakeReadReplicaTopology(memberIDs(2)));

            connectionStrategy.Inject(topologyService, Config.defaults(), NullLogProvider.Instance, Myself);

            // when we collect enough results to feel confident of random values
            IList <MemberId> found = IntStream.range(0, 20).mapToObj(i => connectionStrategy.UpstreamDatabase()).filter(Optional.isPresent).map(Optional.get).collect(Collectors.toList());

            // then
            assertFalse(found.Contains(Myself));
            assertTrue(found.Contains(firstOther));
            assertTrue(found.Contains(secondOther));
        }
Esempio n. 29
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: private java.util.List<com.opengamma.strata.market.explain.ExplainKey<?>> getKeys(java.util.List<com.opengamma.strata.market.explain.ExplainMap> explainMap)
        private IList <ExplainKey <object> > getKeys(IList <ExplainMap> explainMap)
        {
            return(explainMap.stream().flatMap(m => m.Map.Keys.stream()).distinct().sorted((k1, k2) => COLUMN_ORDER.IndexOf(k1) - COLUMN_ORDER.IndexOf(k2)).collect(Collectors.toList()));
        }
Esempio n. 30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("OptionalUsedAsFieldOrParameterType") private static Parameters raft2WithCompressionModifiers(java.util.Optional<org.neo4j.causalclustering.protocol.Protocol_ModifierProtocol> protocol)
        private static Parameters Raft2WithCompressionModifiers(Optional <Protocol_ModifierProtocol> protocol)
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            IList <string> versions = Streams.ofOptional(protocol).map(Protocol::implementation).collect(Collectors.toList());

            return(new Parameters("Raft 2, modifiers: " + protocol, new ApplicationSupportedProtocols(RAFT, singletonList(RAFT_2.implementation())), singletonList(new ModifierSupportedProtocols(COMPRESSION, versions))));
        }