Skip to content

Commit

Permalink
delete utils folder incl functions from ReviewPage folder in frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
nora-kauczor committed Nov 19, 2024
1 parent 05f6cd9 commit 53409ce
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 181 deletions.
65 changes: 32 additions & 33 deletions backend/src/main/java/org/example/backend/check/CorrectAnswers.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,40 @@
import org.example.backend.vocab.Language;

import java.util.List;
import java.util.Objects;


public class CorrectAnswers {

// public List<String> getCorrectAnswers(String word, Language language) {
// String leftSideOfSlash = getLeftSideOfSlash(word);
// String leftSideOfSlashWithoutArticle = getWordWithoutArticle(leftSideOfSlash, language);
// String rightSideOfSlash = getRightSideOfSlash(word);
// String rightSideOfSlashWithoutArticle = getWordWithoutArticle(word, language);
// String leftSideOfSlashWithEndingOfRightSide = getLeftSideOfSlashWithEndingOfRightSide(word);
// /*
//
// String wordWithoutBrackets =
// String wordWithoutBracketsIncludingContent,
// String wordWithoutArticle =
// String wordWithoutArticleWithoutBrackets,
// String wordWithoutArticleWithoutBracketsIncludingContent,
//
// */
// List<String> correctAnswers = List.of(
// word,
// leftSideOfSlash,
// leftSideOfSlashWithoutArticle,
// rightSideOfSlash,
// rightSideOfSlashWithoutArticle,
// leftSideOfSlashWithEndingOfRightSide);
// correctAnswers.stream().filter(Objects::nonNull).toList();
// }
public List<String> getCorrectAnswers(String word, Language language) {
String leftSideOfSlash = getLeftSideOfSlash(word);
String leftSideOfSlashWithoutArticle = getWordWithoutArticle(leftSideOfSlash, language);
String rightSideOfSlash = getRightSideOfSlash(word);
String rightSideOfSlashWithoutArticle = getWordWithoutArticle(word, language);
String leftSideOfSlashWithEndingOfRightSide = getLeftSideOfSlashWithEndingOfRightSide(word);
String wordWithoutBrackets = getWordWithoutBrackets(word);
String wordWithoutBracketsAndWithoutContent = getWordWithoutBracketsAndWithoutBracketsContent(word);
String wordWithoutArticle = getWordWithoutArticle(word, language);
String wordWithoutArticleWithoutBrackets = getWordWithoutBrackets(wordWithoutArticle);
String wordWithoutArticleWithoutBracketsIncludingContent = getWordWithoutBracketsAndWithoutBracketsContent(wordWithoutArticle);
return List.of(
word,
leftSideOfSlash,
leftSideOfSlashWithoutArticle,
rightSideOfSlash,
rightSideOfSlashWithoutArticle,
leftSideOfSlashWithEndingOfRightSide,
wordWithoutBrackets,
wordWithoutBracketsAndWithoutContent,
wordWithoutArticle,
wordWithoutArticleWithoutBrackets,
wordWithoutArticleWithoutBracketsIncludingContent);
}

public static String getLeftSideOfSlash(String word) {
char slash = '/';
boolean wordHasSlash = word.indexOf(slash) != -1;
if (!wordHasSlash) {
return null;
return word;
}
int indexOfSlash = word.indexOf(slash);
return word.substring(0, indexOfSlash);
Expand All @@ -47,7 +46,7 @@ public static String getRightSideOfSlash(String word) {
char slash = '/';
boolean wordHasSlash = word.indexOf(slash) != -1;
if (!wordHasSlash) {
return null;
return word;
}
int indexOfSlash = word.indexOf(slash);
return word.substring(indexOfSlash + 1);
Expand All @@ -57,13 +56,13 @@ public static String getLeftSideOfSlashWithEndingOfRightSide(String word) {
char slash = '/';
boolean wordHasSlash = word.indexOf(slash) != -1;
if (!wordHasSlash) {
return null;
return word;
}
int indexOfSlash = word.indexOf(slash);
char minus = '-';
boolean wordHasMinus = word.indexOf(minus) != -1;
if (!wordHasMinus) {
return null;
return word;
}
String ending = word.substring(indexOfSlash + 2);
String leftSideWithoutLastLetter = word.substring(0, indexOfSlash - 1);
Expand All @@ -83,9 +82,9 @@ public static String getWordWithoutArticle(String word, Language language) {
}
boolean wordStartsWithArticlesLetters = articles.stream().anyMatch(word::contains);
if (!wordStartsWithArticlesLetters) {
return null;
return word;
}
String wordWithoutArticle = null;
String wordWithoutArticle = word;
for (String article : articles) {
boolean articleIsAtBeginning = word.indexOf(article) == 0;
int articleLength = article.length();
Expand All @@ -103,7 +102,7 @@ public static String getWordWithoutBrackets(String word) {
char closingBracket = ')';
boolean wordHasBrackets = word.indexOf(openingBracket) != -1;
if (!wordHasBrackets) {
return null;
return word;
}
int indexOfOpeningBracket = word.indexOf(openingBracket);
int indexOfClosingBracket = word.indexOf(closingBracket);
Expand All @@ -118,7 +117,7 @@ public static String getWordWithoutBracketsAndWithoutBracketsContent(String word
char closingBracket = ')';
boolean wordHasBrackets = word.indexOf(openingBracket) != -1;
if (!wordHasBrackets) {
return null;
return word;
}
int indexOfOpeningBracket = word.indexOf(openingBracket);
int indexOfClosingBracket = word.indexOf(closingBracket);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ void getLeftSideOfSlash_shouldReturnBeau_whenCalledWithBeauBelle() {
}

@Test
void getLeftSideOfSlash_shouldReturnNull_whenCalledWithLaLiberte() {
void getLeftSideOfSlash_shouldReturnLaLiberte_whenCalledWithLaLiberte() {
String word = "la liberté";
String expected = null;
String expected = "la liberté";
String actual = CorrectAnswers.getLeftSideOfSlash(word);
assertEquals(expected, actual);
}
Expand All @@ -32,9 +32,9 @@ void getRightSideOfSlash_shouldReturnBelle_whenCalledWithBeauBelle() {
}

@Test
void getRightSideOfSlash_shouldReturnNull_whenCalledWithLaLiberte() {
void getRightSideOfSlash_shouldReturnLaLiberte_whenCalledWithLaLiberte() {
String word = "la liberté";
String expected = null;
String expected = "la liberté";
String actual = CorrectAnswers.getRightSideOfSlash(word);
assertEquals(expected, actual);
}
Expand All @@ -48,9 +48,9 @@ void getLeftSideOfSlashWithEndingOfRightSide_shouldReturnRoja_whenCalledWithRojo
}

@Test
void getLeftSideOfSlashWithEndingOfRightSide_shouldReturnNull_whenCalledWithBeauBelle() {
void getLeftSideOfSlashWithEndingOfRightSide_shouldReturnBeauBelle_whenCalledWithBeauBelle() {
String word = "beau/belle";
String expected = null;
String expected = "beau/belle";
String actual = CorrectAnswers.getLeftSideOfSlashWithEndingOfRightSide(word);
assertEquals(expected, actual);
}
Expand All @@ -66,9 +66,9 @@ void getLeftSideOfSlashWithEndingOfRightSide_shouldReturnNull_whenCalledWithBeau

@Test
void
getWordWithoutArticle_shouldReturnNull_whenCalledWithElSuenoAndFrench(){
getWordWithoutArticle_shouldReturnElSueno_whenCalledWithElSuenoAndFrench(){
String word = "el sueño";
String expected = null;
String expected = "el sueño";
String actual = CorrectAnswers.getWordWithoutArticle(word, Language.FRENCH);
assertEquals(expected, actual);
}
Expand All @@ -82,9 +82,9 @@ void getWordWithoutBrackets_shouldReturnContente_whenCalledWithContente(){
}

@Test
void getWordWithoutBrackets_shouldReturnNull_whenCalledWithLaLiberte(){
void getWordWithoutBrackets_shouldReturnLaLiberte_whenCalledWithLaLiberte(){
String word = "la liberté";
String expected = null;
String expected = "la liberté";
String actual = CorrectAnswers.getWordWithoutBrackets(word);
assertEquals(expected, actual);
}
Expand All @@ -98,9 +98,9 @@ void getWordWithoutBracketsAndWithoutBracketsContent_shouldReturnContent_whenCal
}

@Test
void getWordWithoutBracketsAndWithoutBracketsContent_shouldReturnNull_whenCalledWithLaLiberte(){
void getWordWithoutBracketsAndWithoutBracketsContent_shouldReturnLaLiberte_whenCalledWithLaLiberte(){
String word = "la liberté";
String expected = null;
String expected = "la liberté";
String actual = CorrectAnswers.getWordWithoutBracketsAndWithoutBracketsContent(word);
assertEquals(expected, actual);
}
Expand Down
15 changes: 0 additions & 15 deletions frontend/src/pages/ReviewPage/utils/getInputWithoutExtraSpaces.ts

This file was deleted.

12 changes: 0 additions & 12 deletions frontend/src/pages/ReviewPage/utils/getLeftSideOfSlash.ts

This file was deleted.

29 changes: 0 additions & 29 deletions frontend/src/pages/ReviewPage/utils/getRightAnswer.ts

This file was deleted.

12 changes: 0 additions & 12 deletions frontend/src/pages/ReviewPage/utils/getRightSideOfSlash.ts

This file was deleted.

27 changes: 0 additions & 27 deletions frontend/src/pages/ReviewPage/utils/getWordWithoutArticle.ts

This file was deleted.

23 changes: 0 additions & 23 deletions frontend/src/pages/ReviewPage/utils/getWordWithoutBrackets.ts

This file was deleted.

This file was deleted.

0 comments on commit 53409ce

Please sign in to comment.