Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stoerr committed Dec 18, 2024
1 parent 4aea000 commit 8588e68
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

Expand All @@ -33,7 +31,6 @@
import org.mockito.Spy;

import com.composum.ai.backend.base.service.chat.GPTTranslationService;
import com.composum.ai.backend.slingbase.AIConfigurationService;
import com.day.cq.wcm.api.WCMException;
import com.day.cq.wcm.msm.api.LiveCopy;
import com.day.cq.wcm.msm.api.LiveRelationship;
Expand All @@ -46,10 +43,6 @@ public class AutoPageTranslateServiceImplTest {
@Mock
protected LiveRelationshipManager liveRelationshipManager;
@Mock
protected AutoTranslateService autoTranslateService;
@Mock
protected AIConfigurationService configurationService;
@Mock
protected ConfigurationBuilder configurationBuilder;
@Mock
protected AutoTranslateCaConfig config;
Expand Down Expand Up @@ -246,8 +239,8 @@ public void testConfigurationOrOverride() {
public void testRulesTable() {
AutoPageTranslateServiceImpl service = new AutoPageTranslateServiceImpl() {
@Override
protected Map<String, String> getRawRules(AutoTranslateTranslationTableConfig tableConfig, Resource tableResource) throws IOException {
Map<String, String> rules = new LinkedHashMap<String, String>();
protected Map<String, String> getRawRules(AutoTranslateTranslationTableConfig tableConfig, Resource tableResource) {
Map<String, String> rules = new LinkedHashMap<>();
rules.put("apple", "Apfel");
rules.put("egg", "Ei");
return rules;
Expand All @@ -259,9 +252,8 @@ protected Map<String, String> getRawRules(AutoTranslateTranslationTableConfig ta
when(config.translationTables()).thenReturn(new AutoTranslateTranslationTableConfig[]{tableConfig});
List<AutoTranslateRuleConfig> rules = service.collectTranslationTables(config, resource);
assertEquals(2, rules.size());
assertEquals("TranslationRule{contentPattern=\"apple\", additionalInstructions=\"Translate 'apple' as 'Apfel'.\"}\n" +
"TranslationRule{contentPattern=\"egg\", additionalInstructions=\"Translate 'egg' as 'Ei'.\"}",
rules.stream().map(Objects::toString).collect(Collectors.joining("\n")));
assertEquals("TranslationRule{contentPattern=\"apple\", additionalInstructions=\"Translate 'apple' as 'Apfel'.\"}", rules.get(0).toString());
assertEquals("TranslationRule{contentPattern=\"egg\", additionalInstructions=\"Translate 'egg' as 'Ei'.\"}", rules.get(1).toString());
}

}

0 comments on commit 8588e68

Please sign in to comment.