@Test void submitContentNew() { when(dataService.findOneById(STATIC_CONTENT, "home", StaticContent.class)).thenReturn(null); when(staticContentFactory.create("home")).thenReturn(staticContent); assertTrue(this.staticContentService.submitContent("home", "<p>New Content!</p>")); verify(staticContent).setContent("<p>New Content!</p>"); verify(dataService).add(STATIC_CONTENT, staticContent); }
@Override @Transactional public boolean submitContent(String key, String content) { try { StaticContent staticContent = dataService.findOneById(STATIC_CONTENT, key, StaticContent.class); if (staticContent == null) { staticContent = staticContentFactory.create(key); staticContent.setContent(content); dataService.add(STATIC_CONTENT, staticContent); } else { staticContent.setContent(content); dataService.update(STATIC_CONTENT, staticContent); } return true; } catch (RuntimeException e) { LOG.error("", e); return false; } }
StaticContentServiceImpl implements StaticContentService { @Override @Transactional public boolean submitContent(String key, String content) { try { StaticContent staticContent = dataService.findOneById(STATIC_CONTENT, key, StaticContent.class); if (staticContent == null) { staticContent = staticContentFactory.create(key); staticContent.setContent(content); dataService.add(STATIC_CONTENT, staticContent); } else { staticContent.setContent(content); dataService.update(STATIC_CONTENT, staticContent); } return true; } catch (RuntimeException e) { LOG.error("", e); return false; } } }
StaticContentServiceImpl implements StaticContentService { @Override @Transactional public boolean submitContent(String key, String content) { try { StaticContent staticContent = dataService.findOneById(STATIC_CONTENT, key, StaticContent.class); if (staticContent == null) { staticContent = staticContentFactory.create(key); staticContent.setContent(content); dataService.add(STATIC_CONTENT, staticContent); } else { staticContent.setContent(content); dataService.update(STATIC_CONTENT, staticContent); } return true; } catch (RuntimeException e) { LOG.error("", e); return false; } } StaticContentServiceImpl(
      DataService dataService,
      StaticContentFactory staticContentFactory,
      UserPermissionEvaluator permissionService); }
StaticContentServiceImpl implements StaticContentService { @Override @Transactional public boolean submitContent(String key, String content) { try { StaticContent staticContent = dataService.findOneById(STATIC_CONTENT, key, StaticContent.class); if (staticContent == null) { staticContent = staticContentFactory.create(key); staticContent.setContent(content); dataService.add(STATIC_CONTENT, staticContent); } else { staticContent.setContent(content); dataService.update(STATIC_CONTENT, staticContent); } return true; } catch (RuntimeException e) { LOG.error("", e); return false; } } StaticContentServiceImpl(
      DataService dataService,
      StaticContentFactory staticContentFactory,
      UserPermissionEvaluator permissionService); @Override @Transactional boolean submitContent(String key, String content); @Transactional(readOnly = true) @Override boolean isCurrentUserCanEdit(String pluginId); @Transactional(readOnly = true) @Override String getContent(String key); void checkPermissions(String pluginId); }
StaticContentServiceImpl implements StaticContentService { @Override @Transactional public boolean submitContent(String key, String content) { try { StaticContent staticContent = dataService.findOneById(STATIC_CONTENT, key, StaticContent.class); if (staticContent == null) { staticContent = staticContentFactory.create(key); staticContent.setContent(content); dataService.add(STATIC_CONTENT, staticContent); } else { staticContent.setContent(content); dataService.update(STATIC_CONTENT, staticContent); } return true; } catch (RuntimeException e) { LOG.error("", e); return false; } } StaticContentServiceImpl(
      DataService dataService,
      StaticContentFactory staticContentFactory,
      UserPermissionEvaluator permissionService); @Override @Transactional boolean submitContent(String key, String content); @Transactional(readOnly = true) @Override boolean isCurrentUserCanEdit(String pluginId); @Transactional(readOnly = true) @Override String getContent(String key); void checkPermissions(String pluginId);  }