@Test public void testFixedTokenWithNoMint() { FixedSupplyTokenDefinitionParticle tokenDefinitionParticle = mock(FixedSupplyTokenDefinitionParticle.class); RRI tokenRef = mock(RRI.class); when(tokenDefinitionParticle.getRRI()).thenReturn(tokenRef); when(tokenDefinitionParticle.getName()).thenReturn("Name"); when(tokenDefinitionParticle.getSymbol()).thenReturn("ISO"); when(tokenDefinitionParticle.getDescription()).thenReturn("Desc"); when(tokenDefinitionParticle.getSupply()).thenReturn(UInt256.ONE); when(tokenDefinitionParticle.getGranularity()).thenReturn(UInt256.ONE); TokenDefinitionsReducer tokenDefinitionsReducer = new TokenDefinitionsReducer(); TokenDefinitionsState state = tokenDefinitionsReducer.reduce( TokenDefinitionsState.init(), tokenDefinitionParticle); assertThat(state.getState().get(tokenRef)).isEqualTo( new TokenState("Name", "ISO", "Desc", "http: TokenUnitConversions.subunitsToUnits(1), TokenUnitConversions.subunitsToUnits(1), TokenSupplyType.FIXED) ); }
@Override public TokenDefinitionsState reduce(TokenDefinitionsState state, Particle p) { if (p instanceof MutableSupplyTokenDefinitionParticle) { return reduceInternal(state, (MutableSupplyTokenDefinitionParticle) p); } else if (p instanceof FixedSupplyTokenDefinitionParticle) { return reduceInternal(state, (FixedSupplyTokenDefinitionParticle) p); } else if (p instanceof UnallocatedTokensParticle) { UnallocatedTokensParticle u = (UnallocatedTokensParticle) p; return state.mergeUnallocated(u); } return state; }
TokenDefinitionsReducer implements ParticleReducer<TokenDefinitionsState> { @Override public TokenDefinitionsState reduce(TokenDefinitionsState state, Particle p) { if (p instanceof MutableSupplyTokenDefinitionParticle) { return reduceInternal(state, (MutableSupplyTokenDefinitionParticle) p); } else if (p instanceof FixedSupplyTokenDefinitionParticle) { return reduceInternal(state, (FixedSupplyTokenDefinitionParticle) p); } else if (p instanceof UnallocatedTokensParticle) { UnallocatedTokensParticle u = (UnallocatedTokensParticle) p; return state.mergeUnallocated(u); } return state; } }
TokenDefinitionsReducer implements ParticleReducer<TokenDefinitionsState> { @Override public TokenDefinitionsState reduce(TokenDefinitionsState state, Particle p) { if (p instanceof MutableSupplyTokenDefinitionParticle) { return reduceInternal(state, (MutableSupplyTokenDefinitionParticle) p); } else if (p instanceof FixedSupplyTokenDefinitionParticle) { return reduceInternal(state, (FixedSupplyTokenDefinitionParticle) p); } else if (p instanceof UnallocatedTokensParticle) { UnallocatedTokensParticle u = (UnallocatedTokensParticle) p; return state.mergeUnallocated(u); } return state; }  }
TokenDefinitionsReducer implements ParticleReducer<TokenDefinitionsState> { @Override public TokenDefinitionsState reduce(TokenDefinitionsState state, Particle p) { if (p instanceof MutableSupplyTokenDefinitionParticle) { return reduceInternal(state, (MutableSupplyTokenDefinitionParticle) p); } else if (p instanceof FixedSupplyTokenDefinitionParticle) { return reduceInternal(state, (FixedSupplyTokenDefinitionParticle) p); } else if (p instanceof UnallocatedTokensParticle) { UnallocatedTokensParticle u = (UnallocatedTokensParticle) p; return state.mergeUnallocated(u); } return state; }  @Override Class<TokenDefinitionsState> stateClass(); @Override TokenDefinitionsState initialState(); @Override TokenDefinitionsState reduce(TokenDefinitionsState state, Particle p); @Override TokenDefinitionsState combine(TokenDefinitionsState state0, TokenDefinitionsState state1); }
TokenDefinitionsReducer implements ParticleReducer<TokenDefinitionsState> { @Override public TokenDefinitionsState reduce(TokenDefinitionsState state, Particle p) { if (p instanceof MutableSupplyTokenDefinitionParticle) { return reduceInternal(state, (MutableSupplyTokenDefinitionParticle) p); } else if (p instanceof FixedSupplyTokenDefinitionParticle) { return reduceInternal(state, (FixedSupplyTokenDefinitionParticle) p); } else if (p instanceof UnallocatedTokensParticle) { UnallocatedTokensParticle u = (UnallocatedTokensParticle) p; return state.mergeUnallocated(u); } return state; }  @Override Class<TokenDefinitionsState> stateClass(); @Override TokenDefinitionsState initialState(); @Override TokenDefinitionsState reduce(TokenDefinitionsState state, Particle p); @Override TokenDefinitionsState combine(TokenDefinitionsState state0, TokenDefinitionsState state1);  }