-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into LANG_012b
- Loading branch information
Showing
15 changed files
with
170 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
spring.jpa.hibernate.ddl-auto=update | ||
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/db_vocabularytrainer?useLegacyDatetimeCode=false&serverTimezone=CET | ||
spring.datasource.username=root | ||
spring.datasource.password=1234 | ||
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/db_vocabularytrainer?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false | ||
spring.datasource.username=student | ||
spring.datasource.password=student |
1 change: 1 addition & 0 deletions
1
src/main/resources/templates/user/csv-output/export_vocabularies_TestUser.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
id;user;german_word;engl_trans;rating;tag |
4 changes: 0 additions & 4 deletions
4
src/main/resources/templates/user/csv-output/export_vocabularies_user.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
id;user;german_word;engl_trans;rating;tag | ||
2;user;essen;eat;0;sda | ||
3;user;schön;beautiful;0;adjective | ||
4;user;Kraftwerk;"power plant";4;noun | ||
5;user;sjdalsdj;asdasd;0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/test/java/com/vocabularytrainer/project/CSVWriterTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.vocabularytrainer.project; | ||
|
||
|
||
import com.vocabularytrainer.project.CSVParser.CSVWriter; | ||
import com.vocabularytrainer.project.db.VocabularyRepository; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.security.core.userdetails.UserDetails; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.mockito.Mockito.when; | ||
|
||
@SpringBootTest | ||
public class CSVWriterTests { | ||
|
||
@Mock | ||
private VocabularyRepository vocabularyRepository; // MVCController is dependent on VocabularyRepository -> MockBean VocabularyRepository | ||
|
||
@Mock | ||
private UserDetails userDetails; | ||
|
||
@InjectMocks | ||
private CSVWriter csvWriter; | ||
|
||
private String savedFilePath; | ||
|
||
@Before | ||
public void before() { | ||
|
||
MockitoAnnotations.initMocks(this); | ||
|
||
when(this.userDetails.getUsername()).thenReturn("TestUser"); | ||
|
||
String filepath = "src/main/resources/templates/user/csv-output/"; | ||
String filename = filepath + "export_vocabularies_" + userDetails.getUsername() + ".csv"; | ||
|
||
File file = new File(filename); | ||
savedFilePath = file.getAbsolutePath(); | ||
} | ||
|
||
@Test | ||
public void testPath() { | ||
|
||
//System.out.println(savedFilePath); | ||
|
||
assertTrue(savedFilePath.endsWith("/Users/Simon/git-repos/ASD-Morning-4/src/main/resources/templates/user/csv-output/export_vocabularies_TestUser.csv")); | ||
|
||
} | ||
|
||
@Test | ||
public void testFileCreation() | ||
{ | ||
|
||
List<Integer> ids = Arrays.asList(); | ||
|
||
File file = csvWriter.writeAllEntriesToCSV(vocabularyRepository, userDetails, savedFilePath, ids); | ||
|
||
assertNotNull(file); | ||
|
||
//System.out.print(file.toString()); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.