### Question:
SelectionEventFactory { public SelectionEvent newSelectionEvent(JsonNode node) { final Record record = recordFactory.newRecord(node.getNode("record")); final boolean state = node.getBooleanValue("state"); final ListGridRecord[] selection = listGridRecordFactory.newListGridRecords(node.getArrayNode("selection")); final ListGridRecord selectedRecord = listGridRecordFactory.newListGridRecord(node.getNode("selectedRecord")); return new SelectionEvent(record, state, selection, selectedRecord); } @Inject  SelectionEventFactory(RecordFactory recordFactory, ListGridRecordFactory listGridRecordFactory); SelectionEvent newSelectionEvent(JsonNode node);  }### Answer:
@Test public void test_configuresRecordAttribute() { final JsonRootNode node = buildJSON(); when(recordFactory.newRecord(node.getNode("record"))).thenReturn(new Record()); final SelectionEvent event = selectionEventFactory.newSelectionEvent(node); assertEquals(recordFactory.newRecord(node.getNode("record")), event.getRecord()); }
@Test public void test_configuresStateAttribute() { final JsonRootNode node = buildJSON(); final SelectionEvent event = selectionEventFactory.newSelectionEvent(node); assertEquals(node.getBooleanValue("state"), event.getState()); }
@Test public void test_configuresSelectionAttribute() { final JsonRootNode node = buildJSON(); when(listGridRecordFactory.newListGridRecords(node.getArrayNode("selection"))).thenReturn(new ListGridRecord[0]); final SelectionEvent event = selectionEventFactory.newSelectionEvent(node); assertArrayEquals(listGridRecordFactory.newListGridRecords(node.getArrayNode("selection")), event.getSelection()); }
@Test public void test_configuresSelectedRecordAttribute() { final JsonRootNode node = buildJSON(); when(listGridRecordFactory.newListGridRecord(node.getNode("selectedRecord"))).thenReturn(new ListGridRecord()); final SelectionEvent event = selectionEventFactory.newSelectionEvent(node); assertEquals(listGridRecordFactory.newListGridRecord(node.getNode("selectedRecord")), event.getSelectedRecord()); }