@Test public void shouldAddCustomTranslationWhenUpdateCacheIfPluginIsEnabledAndNotContainsKey() { String plugin = "plugin"; String key = "key"; String locale = "locale"; String translation = "translation"; given(customTranslation.getStringField(PLUGIN_IDENTIFIER)).willReturn(plugin); given(customTranslation.getStringField(KEY)).willReturn(key); given(customTranslation.getStringField(LOCALE)).willReturn(locale); given(customTranslation.getStringField(CUSTOM_TRANSLATION)).willReturn(translation); given(pluginStateResolver.isEnabled(plugin)).willReturn(true); given(customTranslationCacheService.isCustomTranslationAdded(key)).willReturn(false); customTranslationModelHooks.updateCache(customTranslationDD, customTranslation); verify(customTranslationCacheService).addCustomTranslation(Mockito.anyString(), Mockito.anyString(), Mockito.anyString()); verify(customTranslationCacheService, never()).updateCustomTranslation(Mockito.anyString(), Mockito.anyString(), Mockito.anyString()); }
public void updateCache(final DataDefinition customTranslationDD, final Entity customTranslation) { boolean active = customTranslation.getBooleanField(ACTIVE); String key = customTranslation.getStringField(KEY); String locale = customTranslation.getStringField(LOCALE); String translation = (active) ? customTranslation.getStringField(CUSTOM_TRANSLATION) : null; customTranslationCacheService.manageCustomTranslation(key, locale, translation); }
CustomTranslationModelHooks { public void updateCache(final DataDefinition customTranslationDD, final Entity customTranslation) { boolean active = customTranslation.getBooleanField(ACTIVE); String key = customTranslation.getStringField(KEY); String locale = customTranslation.getStringField(LOCALE); String translation = (active) ? customTranslation.getStringField(CUSTOM_TRANSLATION) : null; customTranslationCacheService.manageCustomTranslation(key, locale, translation); } }
CustomTranslationModelHooks { public void updateCache(final DataDefinition customTranslationDD, final Entity customTranslation) { boolean active = customTranslation.getBooleanField(ACTIVE); String key = customTranslation.getStringField(KEY); String locale = customTranslation.getStringField(LOCALE); String translation = (active) ? customTranslation.getStringField(CUSTOM_TRANSLATION) : null; customTranslationCacheService.manageCustomTranslation(key, locale, translation); }  }
CustomTranslationModelHooks { public void updateCache(final DataDefinition customTranslationDD, final Entity customTranslation) { boolean active = customTranslation.getBooleanField(ACTIVE); String key = customTranslation.getStringField(KEY); String locale = customTranslation.getStringField(LOCALE); String translation = (active) ? customTranslation.getStringField(CUSTOM_TRANSLATION) : null; customTranslationCacheService.manageCustomTranslation(key, locale, translation); }  boolean checkIfCustomTranslationIsUnique(final DataDefinition customTranslationDD, final Entity customTranslation); void changeActiveState(final DataDefinition customTranslationDD, final Entity customTranslation); void updateCache(final DataDefinition customTranslationDD, final Entity customTranslation); }
CustomTranslationModelHooks { public void updateCache(final DataDefinition customTranslationDD, final Entity customTranslation) { boolean active = customTranslation.getBooleanField(ACTIVE); String key = customTranslation.getStringField(KEY); String locale = customTranslation.getStringField(LOCALE); String translation = (active) ? customTranslation.getStringField(CUSTOM_TRANSLATION) : null; customTranslationCacheService.manageCustomTranslation(key, locale, translation); }  boolean checkIfCustomTranslationIsUnique(final DataDefinition customTranslationDD, final Entity customTranslation); void changeActiveState(final DataDefinition customTranslationDD, final Entity customTranslation); void updateCache(final DataDefinition customTranslationDD, final Entity customTranslation);  }