Price implements ByteTransformable { public LegacyAsset multiply(LegacyAsset asset) { if (asset == null) { throw new InvalidParameterException("The asset can't be null"); } else if (asset.getSymbol().equals(this.getBase().getSymbol())) { if (this.getBase().getAmount() == 0) { throw new InvalidParameterException("Can't multiply as the price base is 0."); } return new LegacyAsset((long) ((asset.getAmount() * this.getQuote().getAmount()) / this.getBase().getAmount()), this.getQuote().getSymbol()); } else if (asset.getSymbol().equals(this.getQuote().getSymbol())) { if (this.getQuote().getAmount() == 0) { throw new InvalidParameterException("Can't multiply as the price quote is 0."); } return new LegacyAsset((long) ((asset.getAmount() * this.getBase().getAmount()) / this.getQuote().getAmount()), this.getBase().getSymbol()); } else { throw new InvalidParameterException( "The provided asset does not fulfill the requirements to perform the multiply operation."); } } @JsonCreator  Price(@JsonProperty("base") LegacyAsset base, @JsonProperty("quote") LegacyAsset quote); LegacyAsset getBase(); void setBase(LegacyAsset base); LegacyAsset getQuote(); void setQuote(LegacyAsset quote); LegacyAsset multiply(LegacyAsset asset); @Override byte[] toByteArray(); @Override String toString(); @Override boolean equals(Object otherObject); @Override int hashCode();  }
@Test public void testMultiply() { LegacyAsset base = new LegacyAsset(50L, LegacyAssetSymbolType.SBD); LegacyAsset quote = new LegacyAsset(100L, LegacyAssetSymbolType.STEEM); Price exchangeRate = new Price(base, quote); LegacyAsset amountToSell = new LegacyAsset(2L, LegacyAssetSymbolType.SBD); assertTrue(exchangeRate.multiply(amountToSell).getAmount().equals(4L)); assertTrue(exchangeRate.multiply(amountToSell).getSymbol().equals(LegacyAssetSymbolType.STEEM)); }