Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReplicateTokenRequestForNewToken() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReplicateTokenRequestForNewToken()
        {
            // given
            StorageEngine storageEngine = MockedStorageEngine();

            when(_storageEngineSupplier.get()).thenReturn(storageEngine);

            IdGeneratorFactory idGeneratorFactory = mock(typeof(IdGeneratorFactory));
            IdGenerator        idGenerator        = mock(typeof(IdGenerator));

            when(idGenerator.NextId()).thenReturn(1L);

            when(idGeneratorFactory.Get(any(typeof(IdType)))).thenReturn(idGenerator);

            TokenRegistry         registry         = new TokenRegistry("Label");
            int                   generatedTokenId = 1;
            ReplicatedTokenHolder tokenHolder      = new ReplicatedLabelTokenHolder(registry, (content, trackResult) =>
            {
                CompletableFuture <object> completeFuture = new CompletableFuture <object>();
                completeFuture.complete(generatedTokenId);
                return(completeFuture);
            }, idGeneratorFactory, _storageEngineSupplier);

            // when
            int?tokenId = tokenHolder.GetOrCreateId("name1");

            // then
            assertThat(tokenId, equalTo(generatedTokenId));
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStoreInitialTokens()
        public virtual void ShouldStoreInitialTokens()
        {
            // given
            TokenRegistry         registry    = new TokenRegistry("Label");
            ReplicatedTokenHolder tokenHolder = new ReplicatedLabelTokenHolder(registry, null, null, _storageEngineSupplier);

            // when
            tokenHolder.InitialTokens = asList(new NamedToken("name1", 1), new NamedToken("name2", 2));

            // then
            assertThat(tokenHolder.AllTokens, hasItems(new NamedToken("name1", 1), new NamedToken("name2", 2)));
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnExistingTokenId()
        public virtual void ShouldReturnExistingTokenId()
        {
            // given
            TokenRegistry         registry    = new TokenRegistry("Label");
            ReplicatedTokenHolder tokenHolder = new ReplicatedLabelTokenHolder(registry, null, null, _storageEngineSupplier);

            tokenHolder.InitialTokens = asList(new NamedToken("name1", 1), new NamedToken("name2", 2));

            // when
            int?tokenId = tokenHolder.GetOrCreateId("name1");

            // then
            assertThat(tokenId, equalTo(1));
        }