Investment investment = new Investment();
investment.setName("Investment");
investment.setProductType("stocks");
investment.setOwner(account.getOwner());
investment.persist();
InvestmentPrice price = new InvestmentPrice();
price.setPrice(1D);
price.setInvestment(investment);
price.setUpdateTime(DateUtils.getMidnight(new Date()));
price.persist();
InvestmentTransaction investmentTransaction = new InvestmentTransaction();
investmentTransaction.setId(14L);
investmentTransaction.setPrice(price);
investmentTransaction.setQuantity(10D);
investmentTransaction.setInvestment(investment);
investmentTransaction.setAccountTransaction(transaction);
transaction.setInvestment(investmentTransaction);
InvestmentStatus investmentStatus = new InvestmentStatus(account, investment);
investmentStatus.add(transaction);
assertEquals("JSON", "{operationDate:'', id: 5, label: 'Investment', buy: '10,00 €', sell: '', interest: '', gainLoss: '', pctg: '0%', quantity: '10', price: '1,00 €', operations: [{id: 999914, label: '', buy: '10,00 €', sell: '', interest: '', quantity: '10', price: '1,00 €', gainLoss: '', pctg: '', quant: 10.0, operationDate: '2000-11-20'}], quant: 10.0}", investmentStatus.getAsJSONString());
AccountTransaction sellTransaction = new AccountTransaction();
sellTransaction.setAccount(account);
Subcategory sellSubcategory = Subcategory.findBySubcategory("category.investment.sell", account.getOwner());
sellTransaction.setSubcategory(sellSubcategory);
sellTransaction.setAmount(new BigDecimal(1.5));
InvestmentPrice updatedPrice = new InvestmentPrice();
updatedPrice.setPrice(1.5D);
updatedPrice.setUpdateTime(DateUtils.nextDate(DateUtils.getMidnight(new Date())));
updatedPrice.setInvestment(investment);
updatedPrice.persist();
InvestmentTransaction investmentSellTransaction = new InvestmentTransaction();
investmentSellTransaction.setId(15L);
investmentSellTransaction.setQuantity(1D);
investmentSellTransaction.setPrice(updatedPrice);
investmentSellTransaction.setInvestment(investment);