Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createContextWithFactoryWrapper()
        internal virtual void CreateContextWithFactoryWrapper()
        {
            System.Func <IdGeneratorFactory, IdGeneratorFactory> factoryWrapper = mock(typeof(System.Func));
            IdGeneratorFactory idGeneratorFactory = mock(typeof(IdGeneratorFactory));

            when(factoryWrapper(any())).thenReturn(idGeneratorFactory);

            IdContextFactory contextFactory = IdContextFactoryBuilder.Of(_fs, _jobScheduler).withFactoryWrapper(factoryWrapper).build();

            DatabaseIdContext idContext = contextFactory.CreateIdContext("database");

            assertSame(idGeneratorFactory, idContext.IdGeneratorFactory);
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createCommunityBufferedContextByDefault()
        internal virtual void CreateCommunityBufferedContextByDefault()
        {
            IdContextFactory  idContextFactory = IdContextFactoryBuilder.Of(_fs, _jobScheduler).build();
            DatabaseIdContext idContext        = idContextFactory.CreateIdContext("database");

            IdGeneratorFactory idGeneratorFactory = idContext.IdGeneratorFactory;

            assertThat(idContext.IdController, instanceOf(typeof(BufferedIdController)));
            assertThat(idGeneratorFactory, instanceOf(typeof(BufferingIdGeneratorFactory)));

            (( BufferingIdGeneratorFactory )idGeneratorFactory).initialize(() => mock(typeof(KernelTransactionsSnapshot)));
            idGeneratorFactory.Open(_testDirectory.file("a"), IdType.NODE, () => 0, 100).Dispose();
            idGeneratorFactory.Open(_testDirectory.file("b"), IdType.PROPERTY, () => 0, 100).Dispose();

            BufferingIdGeneratorFactory bufferedFactory = ( BufferingIdGeneratorFactory )idGeneratorFactory;

            assertThat(bufferedFactory.Get(IdType.NODE), instanceOf(typeof(IdGeneratorImpl)));
            assertThat(bufferedFactory.Get(IdType.PROPERTY), not(instanceOf(typeof(IdGeneratorImpl))));
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createContextWithCustomIdGeneratorFactoryWhenProvided()
        internal virtual void CreateContextWithCustomIdGeneratorFactoryWhenProvided()
        {
            IdGeneratorFactory idGeneratorFactory = mock(typeof(IdGeneratorFactory));
            IdContextFactory   contextFactory     = IdContextFactoryBuilder.Of(_fs, _jobScheduler).withIdGenerationFactoryProvider(any => idGeneratorFactory).build();
            DatabaseIdContext  idContext          = contextFactory.CreateIdContext("database");

            IdGeneratorFactory bufferedGeneratorFactory = idContext.IdGeneratorFactory;

            assertThat(idContext.IdController, instanceOf(typeof(BufferedIdController)));
            assertThat(bufferedGeneratorFactory, instanceOf(typeof(BufferingIdGeneratorFactory)));

            (( BufferingIdGeneratorFactory )bufferedGeneratorFactory).initialize(() => mock(typeof(KernelTransactionsSnapshot)));
            File   file   = _testDirectory.file("a");
            IdType idType = IdType.NODE;

            System.Func <long> highIdSupplier = () => 0;
            int maxId = 100;

            idGeneratorFactory.Open(file, idType, highIdSupplier, maxId);

            verify(idGeneratorFactory).open(file, idType, highIdSupplier, maxId);
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createContextWithProvidedReusabilityCheck()
        internal virtual void CreateContextWithProvidedReusabilityCheck()
        {
            IdReuseEligibility reuseEligibility         = mock(typeof(IdReuseEligibility));
            IdContextFactory   contextFactory           = IdContextFactoryBuilder.Of(_fs, _jobScheduler).withIdReuseEligibility(reuseEligibility).build();
            DatabaseIdContext  idContext                = contextFactory.CreateIdContext("database");
            IdGeneratorFactory bufferedGeneratorFactory = idContext.IdGeneratorFactory;

            assertThat(bufferedGeneratorFactory, instanceOf(typeof(BufferingIdGeneratorFactory)));
            BufferingIdGeneratorFactory bufferedFactory = ( BufferingIdGeneratorFactory )bufferedGeneratorFactory;

            KernelTransactionsSnapshot snapshot = mock(typeof(KernelTransactionsSnapshot));

            when(snapshot.AllClosed()).thenReturn(true);

            bufferedFactory.Initialize(() => snapshot);
            using (IdGenerator idGenerator = bufferedFactory.Open(_testDirectory.file("a"), IdType.PROPERTY, () => 100, 100))
            {
                idGenerator.FreeId(15);

                bufferedFactory.Maintenance();
                verify(reuseEligibility).isEligible(snapshot);
            }
        }