@Test public void shouldRemoveWhenRemoveCustomTranslationIfCustomTranslationIsntNull() throws Exception { String pluginIdentifier = "plugin"; Session session = Mockito.mock(Session.class, Mockito.RETURNS_DEEP_STUBS); CustomTranslationManagementService mockedCustomTranslationManagementService = PowerMockito .spy(customTranslationManagementService); PowerMockito.doReturn(session).when(mockedCustomTranslationManagementService, "getCurrentSession", customTranslationDD); given(customTranslation.getDataDefinition()).willReturn(customTranslationDD); mockedCustomTranslationManagementService.removeCustomTranslations(pluginIdentifier); verify(session).createQuery(Mockito.anyString()); }
@Override @Transactional public void removeCustomTranslations(final String pluginIdentifier) { DataDefinition customTranslationDD = getCustomTranslationDD(); Session currentSession = getCurrentSession(customTranslationDD); currentSession .createQuery( "UPDATE com.qcadoo.model.beans.qcadooCustomTranslation.QcadooCustomTranslationCustomTranslation " + "SET active = false WHERE pluginIdentifier = :pluginIdentifier AND active = true") .setString("pluginIdentifier", pluginIdentifier).executeUpdate(); }
CustomTranslationManagementServiceImpl implements CustomTranslationManagementService { @Override @Transactional public void removeCustomTranslations(final String pluginIdentifier) { DataDefinition customTranslationDD = getCustomTranslationDD(); Session currentSession = getCurrentSession(customTranslationDD); currentSession .createQuery( "UPDATE com.qcadoo.model.beans.qcadooCustomTranslation.QcadooCustomTranslationCustomTranslation " + "SET active = false WHERE pluginIdentifier = :pluginIdentifier AND active = true") .setString("pluginIdentifier", pluginIdentifier).executeUpdate(); } }
CustomTranslationManagementServiceImpl implements CustomTranslationManagementService { @Override @Transactional public void removeCustomTranslations(final String pluginIdentifier) { DataDefinition customTranslationDD = getCustomTranslationDD(); Session currentSession = getCurrentSession(customTranslationDD); currentSession .createQuery( "UPDATE com.qcadoo.model.beans.qcadooCustomTranslation.QcadooCustomTranslationCustomTranslation " + "SET active = false WHERE pluginIdentifier = :pluginIdentifier AND active = true") .setString("pluginIdentifier", pluginIdentifier).executeUpdate(); }  }
CustomTranslationManagementServiceImpl implements CustomTranslationManagementService { @Override @Transactional public void removeCustomTranslations(final String pluginIdentifier) { DataDefinition customTranslationDD = getCustomTranslationDD(); Session currentSession = getCurrentSession(customTranslationDD); currentSession .createQuery( "UPDATE com.qcadoo.model.beans.qcadooCustomTranslation.QcadooCustomTranslationCustomTranslation " + "SET active = false WHERE pluginIdentifier = :pluginIdentifier AND active = true") .setString("pluginIdentifier", pluginIdentifier).executeUpdate(); }  @Override @Transactional @SuppressWarnings("unchecked") void addCustomTranslations(final String pluginIdentifier, final String locale, final Map<String, String> translations); @Override @Transactional void removeCustomTranslations(final String pluginIdentifier); @Override @Transactional @SuppressWarnings("unchecked") List<String> getCustomTranslationKeys(final String pluginIdentifier); @Override Entity getCustomTranslation(final String pluginIdentifier, final String locale, final String key); @Override List<Entity> getCustomTranslations(final String locale); @Override List<Entity> getCustomTranslations(); @Override DataDefinition getCustomTranslationDD(); }
CustomTranslationManagementServiceImpl implements CustomTranslationManagementService { @Override @Transactional public void removeCustomTranslations(final String pluginIdentifier) { DataDefinition customTranslationDD = getCustomTranslationDD(); Session currentSession = getCurrentSession(customTranslationDD); currentSession .createQuery( "UPDATE com.qcadoo.model.beans.qcadooCustomTranslation.QcadooCustomTranslationCustomTranslation " + "SET active = false WHERE pluginIdentifier = :pluginIdentifier AND active = true") .setString("pluginIdentifier", pluginIdentifier).executeUpdate(); }  @Override @Transactional @SuppressWarnings("unchecked") void addCustomTranslations(final String pluginIdentifier, final String locale, final Map<String, String> translations); @Override @Transactional void removeCustomTranslations(final String pluginIdentifier); @Override @Transactional @SuppressWarnings("unchecked") List<String> getCustomTranslationKeys(final String pluginIdentifier); @Override Entity getCustomTranslation(final String pluginIdentifier, final String locale, final String key); @Override List<Entity> getCustomTranslations(final String locale); @Override List<Entity> getCustomTranslations(); @Override DataDefinition getCustomTranslationDD();  }