### Question:
OrderBook implements Comparable { @Override public String toString() { String result; if (this.action.equals("bid")) { result = String.format("%7s%9.2f", this.volume, this.price); } else { result = String.format("%7s%9.2f%6s", " ", this.price, this.volume); } char[] charArray = result.toCharArray(); for (int i = 0; i < charArray.length; i++) { if (charArray[i] == '.') { charArray[i] = ','; } result = new String(charArray); } return result; } OrderBook(int id, String book, String type, String action, double price, int volume); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(Object o); int getId(); String getBook(); String getType(); String getAction(); double getPrice(); int getVolume();  }### Answer:
@Test public void ifAddOrdersToTreeSetOrdersShouldBeSorted() { Set<OrderBook> testSet = new TreeSet<>(); testSet.add(new OrderBook(1, "gazprom", "add", "bid", 100, 1000)); testSet.add(new OrderBook(2, "gazprom", "add", "bid", 10, 100)); testSet.add(new OrderBook(3, "gazprom", "add", "bid", 11, 100)); testSet.add(new OrderBook(4, "gazprom", "add", "ask", 13, 104)); testSet.add(new OrderBook(5, "gazprom", "add", "ask", 14, 100)); testSet.add(new OrderBook(6, "gazprom", "add", "ask", 15, 100)); for (OrderBook item : testSet) { System.out.println(item); } assertThat( new String(out.toByteArray()), is( new StringJoiner(ln) .add(" 15,00 100") .add(" 14,00 100") .add(" 13,00 104") .add(" 1000 100,00") .add(" 100 11,00") .add(" 100 10,00" + ln) .toString() ) ); }