@Test public void addMessageToActionlogTest() throws Exception { contactRepository.save((Contact) dm.getSender(), i); controller.addReceivedMessage(dm); assertEquals(1, controller.messages.getChildren().size()); }
void addReceivedMessage(DropMessage dropMessage) throws EntityNotFoundException { Map<String, Object> injectionContext = new HashMap<>(); String senderKeyId = dropMessage.getSenderKeyId(); if (senderKeyId == null) { senderKeyId = dropMessage.getSender().getKeyIdentifier(); } Contact sender = contactRepository.findByKeyId(identity, senderKeyId); if (sender == null) { sender = contactRepository.findByKeyId(identity, dropMessage.getSender().getKeyIdentifier()); } boolean first = lastSender != sender; lastSender = sender; injectionContext.put("dropMessage", dropMessage); injectionContext.put("sender", sender.getAlias()); ActionlogItemView otherItemView = new ActionlogItemView(injectionContext::get); Parent view = otherItemView.getView(); view.getStyleClass().add("sent"); view.getStyleClass().add(first ? "first" : "sequence"); messages.getChildren().add(view); messageView.add(otherItemView); messageControllers.add((ActionlogItem) otherItemView.getPresenter()); }
ActionlogController extends AbstractController implements Initializable, Observer { void addReceivedMessage(DropMessage dropMessage) throws EntityNotFoundException { Map<String, Object> injectionContext = new HashMap<>(); String senderKeyId = dropMessage.getSenderKeyId(); if (senderKeyId == null) { senderKeyId = dropMessage.getSender().getKeyIdentifier(); } Contact sender = contactRepository.findByKeyId(identity, senderKeyId); if (sender == null) { sender = contactRepository.findByKeyId(identity, dropMessage.getSender().getKeyIdentifier()); } boolean first = lastSender != sender; lastSender = sender; injectionContext.put("dropMessage", dropMessage); injectionContext.put("sender", sender.getAlias()); ActionlogItemView otherItemView = new ActionlogItemView(injectionContext::get); Parent view = otherItemView.getView(); view.getStyleClass().add("sent"); view.getStyleClass().add(first ? "first" : "sequence"); messages.getChildren().add(view); messageView.add(otherItemView); messageControllers.add((ActionlogItem) otherItemView.getPresenter()); } }
ActionlogController extends AbstractController implements Initializable, Observer { void addReceivedMessage(DropMessage dropMessage) throws EntityNotFoundException { Map<String, Object> injectionContext = new HashMap<>(); String senderKeyId = dropMessage.getSenderKeyId(); if (senderKeyId == null) { senderKeyId = dropMessage.getSender().getKeyIdentifier(); } Contact sender = contactRepository.findByKeyId(identity, senderKeyId); if (sender == null) { sender = contactRepository.findByKeyId(identity, dropMessage.getSender().getKeyIdentifier()); } boolean first = lastSender != sender; lastSender = sender; injectionContext.put("dropMessage", dropMessage); injectionContext.put("sender", sender.getAlias()); ActionlogItemView otherItemView = new ActionlogItemView(injectionContext::get); Parent view = otherItemView.getView(); view.getStyleClass().add("sent"); view.getStyleClass().add(first ? "first" : "sequence"); messages.getChildren().add(view); messageView.add(otherItemView); messageControllers.add((ActionlogItem) otherItemView.getPresenter()); }  }
ActionlogController extends AbstractController implements Initializable, Observer { void addReceivedMessage(DropMessage dropMessage) throws EntityNotFoundException { Map<String, Object> injectionContext = new HashMap<>(); String senderKeyId = dropMessage.getSenderKeyId(); if (senderKeyId == null) { senderKeyId = dropMessage.getSender().getKeyIdentifier(); } Contact sender = contactRepository.findByKeyId(identity, senderKeyId); if (sender == null) { sender = contactRepository.findByKeyId(identity, dropMessage.getSender().getKeyIdentifier()); } boolean first = lastSender != sender; lastSender = sender; injectionContext.put("dropMessage", dropMessage); injectionContext.put("sender", sender.getAlias()); ActionlogItemView otherItemView = new ActionlogItemView(injectionContext::get); Parent view = otherItemView.getView(); view.getStyleClass().add("sent"); view.getStyleClass().add(first ? "first" : "sequence"); messages.getChildren().add(view); messageView.add(otherItemView); messageControllers.add((ActionlogItem) otherItemView.getPresenter()); }  @Override void initialize(URL location, ResourceBundle resources); List<PersistenceDropMessage> getReceivedDropMessages(); @Override synchronized void update(Observable o, Object arg); synchronized void setContact(Contact contact); void handleAccept(); void handleIgnore(); void selectEmoji(); }
ActionlogController extends AbstractController implements Initializable, Observer { void addReceivedMessage(DropMessage dropMessage) throws EntityNotFoundException { Map<String, Object> injectionContext = new HashMap<>(); String senderKeyId = dropMessage.getSenderKeyId(); if (senderKeyId == null) { senderKeyId = dropMessage.getSender().getKeyIdentifier(); } Contact sender = contactRepository.findByKeyId(identity, senderKeyId); if (sender == null) { sender = contactRepository.findByKeyId(identity, dropMessage.getSender().getKeyIdentifier()); } boolean first = lastSender != sender; lastSender = sender; injectionContext.put("dropMessage", dropMessage); injectionContext.put("sender", sender.getAlias()); ActionlogItemView otherItemView = new ActionlogItemView(injectionContext::get); Parent view = otherItemView.getView(); view.getStyleClass().add("sent"); view.getStyleClass().add(first ? "first" : "sequence"); messages.getChildren().add(view); messageView.add(otherItemView); messageControllers.add((ActionlogItem) otherItemView.getPresenter()); }  @Override void initialize(URL location, ResourceBundle resources); List<PersistenceDropMessage> getReceivedDropMessages(); @Override synchronized void update(Observable o, Object arg); synchronized void setContact(Contact contact); void handleAccept(); void handleIgnore(); void selectEmoji(); @FXML
    public BorderPane chat; @FXML
    public ImageView emojiSelector; }