Skip to content

Commit

Permalink
Merge pull request #69 from onesimus-wiafe/SCRUM-62-portfolio-control…
Browse files Browse the repository at this point in the history
…-and-access

Scrum 62 portfolio control and access
  • Loading branch information
onesimus-wiafe authored Aug 8, 2024
2 parents 0cb35d5 + 44c165c commit df16bf8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public class MarketData implements Serializable {

private String EXCHANGE;

public MarketData(String ticker){
this.TICKER = ticker;
}

@Override
public String toString() {
return "MarketData{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void testInitialSubscriptionCheck(){

@Test
void buildInitialCacheEntryTest() throws JsonProcessingException {
List<MarketData> marketDataList = Arrays.asList(new MarketData(), new MarketData());
List<MarketData> marketDataList = Arrays.asList(new MarketData("IBM"), new MarketData("AAPL"));
Object[] marketDataArray = marketDataList.toArray();

when(restTemplate.getForEntity(anyString(), eq(Object[].class)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ public void setUp(){
void testPublishOrderBook() throws JsonProcessingException {
doNothing().when(natsService).publish(any(), any());

List<OrderBook> orderBooks = new ArrayList<>();
orderBooks.add(new OrderBook());
orderBooks.add(new OrderBook());
List<com.joe.trading.shared.dtos.OrderBook> orderBooks = new ArrayList<>();
orderBooks.add(new com.joe.trading.shared.dtos.OrderBook());
orderBooks.add(new com.joe.trading.shared.dtos.OrderBook());

OrderBook[] orderBookArray = new OrderBook[orderBooks.size()];
com.joe.trading.shared.dtos.OrderBook[] orderBookArray = new com.joe.trading.shared.dtos.OrderBook[orderBooks.size()];
int count = 0;

while (count < orderBooks.size()){
orderBookArray[count] = orderBooks.get(count);
count += 1;;
}

when(restTemplate.getForEntity(anyString(), eq(OrderBook[].class)))
when(restTemplate.getForEntity(anyString(), eq(com.joe.trading.shared.dtos.OrderBook[].class)))
.thenReturn(ResponseEntity.ok(orderBookArray));

orderBookService.publishOrderBook();

verify(natsService, times(8)).publish(any(), any());
verify(natsService, times(32)).publish(any(), any());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ private List<OrderBook> updateInternalOrders(String cacheKey, String key, List<c
List<OrderBook> orderBooksForKey = books.stream()
.map(orderBookMapper::mapToOrderBook).toList();

if (openOrders == null){
return orderBooksForKey;
}

orderBooksForKey.forEach(book -> {
if (openOrders.contains(book.getId())){
internalOrders.add(book);
Expand Down

0 comments on commit df16bf8

Please sign in to comment.