@Test public void testSave() { final KModuleModel kModuleModel = spy(new KModuleModel()); knowledgeBasesPresenter.kModuleModel = kModuleModel; final Map<String, KBaseModel> kBasesMap = spy(new HashMap<>()); doReturn(kBasesMap).when(kModuleModel).getKBases(); knowledgeBasesPresenter.save("Test comment", null).catch_(i -> { Assert.fail("Promise should've been resolved!"); return promises.resolve(); }); verify(kBasesMap).clear(); verify(kBasesMap).putAll(any()); }
@Override public Promise<Void> save(final String comment, final Supplier<Promise<Void>> chain) { kModuleModel.getKBases().clear(); kModuleModel.getKBases().putAll( knowledgeBaseListPresenter.getObjectsList().stream() .collect(Collectors.toMap(KBaseModel::getName, identity()))); return promises.resolve(); }
KnowledgeBasesPresenter extends Section<ProjectScreenModel> { @Override public Promise<Void> save(final String comment, final Supplier<Promise<Void>> chain) { kModuleModel.getKBases().clear(); kModuleModel.getKBases().putAll( knowledgeBaseListPresenter.getObjectsList().stream() .collect(Collectors.toMap(KBaseModel::getName, identity()))); return promises.resolve(); } }
KnowledgeBasesPresenter extends Section<ProjectScreenModel> { @Override public Promise<Void> save(final String comment, final Supplier<Promise<Void>> chain) { kModuleModel.getKBases().clear(); kModuleModel.getKBases().putAll( knowledgeBaseListPresenter.getObjectsList().stream() .collect(Collectors.toMap(KBaseModel::getName, identity()))); return promises.resolve(); } @Inject  KnowledgeBasesPresenter(final View view,
                                   final Event<SettingsSectionChange<ProjectScreenModel>> settingsSectionChangeEvent,
                                   final Promises promises,
                                   final MenuItem<ProjectScreenModel> menuItem,
                                   final KnowledgeBaseListPresenter knowledgeBaseListPresenter); }
KnowledgeBasesPresenter extends Section<ProjectScreenModel> { @Override public Promise<Void> save(final String comment, final Supplier<Promise<Void>> chain) { kModuleModel.getKBases().clear(); kModuleModel.getKBases().putAll( knowledgeBaseListPresenter.getObjectsList().stream() .collect(Collectors.toMap(KBaseModel::getName, identity()))); return promises.resolve(); } @Inject  KnowledgeBasesPresenter(final View view,
                                   final Event<SettingsSectionChange<ProjectScreenModel>> settingsSectionChangeEvent,
                                   final Promises promises,
                                   final MenuItem<ProjectScreenModel> menuItem,
                                   final KnowledgeBaseListPresenter knowledgeBaseListPresenter); @Override Promise<Void> setup(final ProjectScreenModel model); @Override Promise<Void> save(final String comment,
                              final Supplier<Promise<Void>> chain); @Override SectionView<?> getView(); @Override int currentHashCode(); }
KnowledgeBasesPresenter extends Section<ProjectScreenModel> { @Override public Promise<Void> save(final String comment, final Supplier<Promise<Void>> chain) { kModuleModel.getKBases().clear(); kModuleModel.getKBases().putAll( knowledgeBaseListPresenter.getObjectsList().stream() .collect(Collectors.toMap(KBaseModel::getName, identity()))); return promises.resolve(); } @Inject  KnowledgeBasesPresenter(final View view,
                                   final Event<SettingsSectionChange<ProjectScreenModel>> settingsSectionChangeEvent,
                                   final Promises promises,
                                   final MenuItem<ProjectScreenModel> menuItem,
                                   final KnowledgeBaseListPresenter knowledgeBaseListPresenter); @Override Promise<Void> setup(final ProjectScreenModel model); @Override Promise<Void> save(final String comment,
                              final Supplier<Promise<Void>> chain); @Override SectionView<?> getView(); @Override int currentHashCode();  }