diff --git "a/\303\274bung1/.idea/misc.xml" "b/\303\274bung1/.idea/misc.xml" index bdc87d76b67dd7a343ca8c474343fdb29d43dc53..1763e153b6f24f136d4d5567320e74f68b248b87 100644 --- "a/\303\274bung1/.idea/misc.xml" +++ "b/\303\274bung1/.idea/misc.xml" @@ -1,11 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> - <component name="MavenProjectsManager"> - <option name="originalFiles"> - <list> - <option value="$PROJECT_DIR$/MiniProjekt/pom.xml" /> - </list> - </option> + <component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/out" /> </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK" /> </project> \ No newline at end of file diff --git "a/\303\274bung1/.idea/modules.xml" "b/\303\274bung1/.idea/modules.xml" index 549ed24cd8f988a5809be3fe62e06ef7d14b4ed9..211fc4dc20b27d6ce593f6bd656533fcfd594488 100644 --- "a/\303\274bung1/.idea/modules.xml" +++ "b/\303\274bung1/.idea/modules.xml" @@ -2,8 +2,8 @@ <project version="4"> <component name="ProjectModuleManager"> <modules> - <module fileurl="file://$PROJECT_DIR$/MiniProjekt/uebung1.iml" filepath="$PROJECT_DIR$/MiniProjekt/uebung1.iml" /> - <module fileurl="file://$PROJECT_DIR$/.idea/übung1.iml" filepath="$PROJECT_DIR$/.idea/übung1.iml" /> + <module fileurl="file://$PROJECT_DIR$/src/main/main.iml" filepath="$PROJECT_DIR$/src/main/main.iml" /> + <module fileurl="file://$PROJECT_DIR$/src/test/test.iml" filepath="$PROJECT_DIR$/src/test/test.iml" /> </modules> </component> </project> \ No newline at end of file diff --git "a/\303\274bung1/.idea/vcs.xml" "b/\303\274bung1/.idea/vcs.xml" index 67268f230d1626bfc02aa55baef47b10ee5555dd..94a25f7f4cb416c083d265558da75d457237d671 100644 --- "a/\303\274bung1/.idea/vcs.xml" +++ "b/\303\274bung1/.idea/vcs.xml" @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="VcsDirectoryMappings"> - <mapping directory="$PROJECT_DIR$/MiniProjekt" vcs="Git" /> + <mapping directory="$PROJECT_DIR$" vcs="Git" /> </component> </project> \ No newline at end of file diff --git "a/\303\274bung1/MiniProjekt" "b/\303\274bung1/MiniProjekt" deleted file mode 160000 index 7d01d07c61576438e12d2ddcd08ceaf33a77b5df..0000000000000000000000000000000000000000 --- "a/\303\274bung1/MiniProjekt" +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7d01d07c61576438e12d2ddcd08ceaf33a77b5df diff --git "a/\303\274bung1/README.md" "b/\303\274bung1/README.md" new file mode 100644 index 0000000000000000000000000000000000000000..6fe4a2942f243041e7eab22d37413c75b5fe3076 --- /dev/null +++ "b/\303\274bung1/README.md" @@ -0,0 +1 @@ +# MiniProjekt diff --git "a/\303\274bung1/pom.xml" "b/\303\274bung1/pom.xml" new file mode 100644 index 0000000000000000000000000000000000000000..664f1fb12e2dde3760058edcbe5d7017dd17de3d --- /dev/null +++ "b/\303\274bung1/pom.xml" @@ -0,0 +1,50 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>de.unibremen.swp</groupId> + <artifactId>uebung1</artifactId> + <version>1.0</version> + <packaging>jar</packaging> + + <name>uebung1</name> + <url>http://maven.apache.org</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>11</maven.compiler.source> + <maven.compiler.target>11</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> +<dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <version>5.6.1</version> + <scope>test</scope> +</dependency> + </dependencies> +<build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>8</source> + <target>1.8</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.22.2</version> + </plugin> + </plugins> + </build> +</project> diff --git "a/\303\274bung1/src/main/java/CSVUser/CSVUser.java" "b/\303\274bung1/src/main/java/CSVUser/CSVUser.java" new file mode 100644 index 0000000000000000000000000000000000000000..04bcf5cc66e188365334722bbc764bd88fb9887e --- /dev/null +++ "b/\303\274bung1/src/main/java/CSVUser/CSVUser.java" @@ -0,0 +1,153 @@ +package de.unibremen.swp.data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * Represents a user imported from a CSV file. + */ +public class CSVUser { + + /** + * The identification number of a user. + */ + private int id = 1; + + /** + * A user's first name. + */ + private String firstName = ""; + + /** + * A user's last name. + */ + private String lastName = ""; + + /** + * A user's motto. + */ + private String motto = ""; + + /** + * Stores the ids of the friends. + */ + private List<Integer> friends = new ArrayList<>(); + + /** + * Returns the identification number. + * + * @return + * The identification number. + */ + public int getId() { + return id; + } + + /** + * Sets the identification number. + * + * @param id + * The identification number to set. + */ + public void setId(final int id) { + this.id = id; + } + + /** + * Returns the first name. + * + * @return + * The first name. + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets the first name. + * + * @param firstName + * The first name to set. + * @throws NullPointerException + * If {@code firstName} is {@code null}. + */ + public void setFirstName(final String firstName) throws + NullPointerException { + this.firstName = Objects.requireNonNull(firstName); + } + + /** + * Returns the last name. + * + * @return + * The last name. + */ + public String getLastName() { + return lastName; + } + + /** + * Sets the last name. + * + * @param lastName + * The last name to set. + * @throws NullPointerException + * If {@code lastName} is {@code null}. + */ + public void setLastName(final String lastName) throws + NullPointerException { + this.lastName = Objects.requireNonNull(lastName); + } + + /** + * Returns the motto. + * + * @return + * The motto. + */ + public String getMotto() { + return motto; + } + + /** + * Sets the motto. + * + * @param motto + * The motto to set. + * @throws NullPointerException + * If {@code motto} is {@code null}. + */ + public void setMotto(final String motto) throws NullPointerException { + this.motto = Objects.requireNonNull(motto); + } + + /** + * Returns a flat copy of the friends (their id). + * + * @return + * A flat copy of the id of the friends. + */ + public List<Integer> getFriends() { + return new ArrayList<>(friends); + } + + /** + * Sets the friends (their id). Creates a flat copy of {@code friends}. + * + * @param friends + * The ids to set. + * @throws NullPointerException + * If {@code friends} is {@code null}. + * @throws IllegalArgumentException + * If {@code friends} contains {@code null}. + */ + public void setFriends(final List<Integer> friends) throws + NullPointerException, IllegalArgumentException { + if (Objects.requireNonNull(friends).stream() + .anyMatch(Objects::isNull)) { + throw new IllegalArgumentException(); + } + this.friends = new ArrayList<>(friends); + } +} diff --git "a/\303\274bung1/src/main/java/Converter/Converter.java" "b/\303\274bung1/src/main/java/Converter/Converter.java" new file mode 100644 index 0000000000000000000000000000000000000000..7d6081df0541e4e9af2e0b69211ee99443aaa97a --- /dev/null +++ "b/\303\274bung1/src/main/java/Converter/Converter.java" @@ -0,0 +1,66 @@ +package de.unibremen.swp; + +import de.unibremen.swp.data.CSVUser; +import de.unibremen.swp.data.JSONUser; + +import java.text.ParseException; + +/** + * Allows to convert between {@link CSVUser} stored in CSV strings and + * {@link JSONUser} stored in JSON strings. Uses {@link Parser} for + * serialization and deserialization. + */ +public class Converter { + + /** + * The parser that is used to serialize and deserialize the corresponding + * {@link CSVUser} and {@link JSONUser} objects. + */ + private final Parser parser = new Parser(); + + /** + * Converts the given CSV string with {@link CSVUser} to a JSON string with + * {@link JSONUser}. + * + * @param csv + * The CSV string to convert. + * @return + * The converted JSON string. + * @throws NullPointerException + * If {@code csv} is {@code null}. + * @throws IllegalArgumentException + * If {@link Parser#readCSVUsers(String)} or + * {@link Parser#writeJSONUsers(List)} throws an + * {@link IllegalArgumentException}. + * @throws ParseException + * If {@link Parser#readCSVUsers(String)} throws a + * {@link ParseException}. + */ + public String csvToJSON(final String csv) throws NullPointerException, + IllegalArgumentException, ParseException { + throw new UnsupportedOperationException(); + } + + /** + * Converts the given JSON string with {@link JSONUser} to a CSV string + * with {@link CSVUser}. + * + * @param json + * The JSON string to convert. + * @return + * The converted CSV string. + * @throws NullPointerException + * If {@code json} is {@code null}. + * @throws IllegalArgumentException + * If {@link Parser#readJSONUsers(String)} or + * {@link Parser#writeCSVUsers(List)} throws an + * {@link IllegalArgumentException}. + * @throws ParseException + * If {@link Parser#readJSONUsers(String)} throws a + * {@link ParseException}. + */ + public String jsonToCSV(final String json) throws NullPointerException, + IllegalArgumentException, ParseException { + throw new UnsupportedOperationException(); + } +} diff --git "a/\303\274bung1/src/main/java/JSONUser/JSONUser.java" "b/\303\274bung1/src/main/java/JSONUser/JSONUser.java" new file mode 100644 index 0000000000000000000000000000000000000000..dfc6a8e8fd7e3662afd50508651fd5812c32aac1 --- /dev/null +++ "b/\303\274bung1/src/main/java/JSONUser/JSONUser.java" @@ -0,0 +1,128 @@ +package de.unibremen.swp.data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * Represents a user imported from a JSON file. + */ +public class JSONUser { + + /** + * A user's first name. + */ + private String firstName = ""; + + /** + * A user's last name. + */ + private String lastName = ""; + + /** + * A user's motto. + */ + private String motto = ""; + + /** + * The friends of an user. + */ + private List<JSONUser> friends = new ArrayList<>(); + + /** + * Returns the first name. + * + * @return + * The first name. + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets the first name. + * + * @param firstName + * The first name to set. + * @throws NullPointerException + * If {@code firstName} is {@code null}. + */ + public void setFirstName(final String firstName) throws + NullPointerException { + this.firstName = Objects.requireNonNull(firstName); + } + + /** + * Returns the last name. + * + * @return + * The last name. + */ + public String getLastName() { + return lastName; + } + + /** + * Sets the last name. + * + * @param lastName + * The last name to set. + * @throws NullPointerException + * If {@code lastName} is {@code null}. + */ + public void setLastName(final String lastName) throws + NullPointerException { + this.lastName = Objects.requireNonNull(lastName); + } + + /** + * Returns the motto. + * + * @return + * The motto. + */ + public String getMotto() { + return motto; + } + + /** + * Sets the motto. + * + * @param motto + * The motto to set. + * @throws NullPointerException + * If {@code motto} is {@code null}. + */ + public void setMotto(final String motto) throws NullPointerException { + this.motto = Objects.requireNonNull(motto); + } + + /** + * Returns a flat copy of the friends. + * + * @return + * A flat copy of the friends. + */ + public List<JSONUser> getFriends() { + return new ArrayList<>(friends); + } + + /** + * Sets the friends. Creates a flat copy of {@code friends}. + * + * @param friends + * The friends to set. + * @throws NullPointerException + * If {@code friends} is {@code null}. + * @throws IllegalArgumentException + * If {@code friends} contains {@code null}. + */ + public void setFriends(final List<JSONUser> friends) throws + NullPointerException, IllegalArgumentException { + if (Objects.requireNonNull(friends).stream() + .anyMatch(Objects::isNull)) { + throw new IllegalArgumentException(); + } + this.friends = new ArrayList<>(friends); + } +} diff --git "a/\303\274bung1/src/main/java/Main/Main.java" "b/\303\274bung1/src/main/java/Main/Main.java" new file mode 100644 index 0000000000000000000000000000000000000000..4b5c016bfbc6d9f5ee436e91cf38af4f6f165e6e --- /dev/null +++ "b/\303\274bung1/src/main/java/Main/Main.java" @@ -0,0 +1,50 @@ +package de.unibremen.swp; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static java.nio.charset.StandardCharsets.UTF_8; + +public class Main { + + public static void main(final String[] args) { + if (args.length != 2) { + System.out.println("Usage: <input> <output>"); + System.exit(0); + } + + final Path in = Paths.get(args[0]); + final Path out = Paths.get(args[1]); + + // Check input and output formats. + if (!args[0].endsWith(".csv") && !args[0].endsWith(".json")) { + System.err.println("Unsupported input format: " + + in.getFileName()); + System.exit(-1); + } + if (!args[1].endsWith(".csv") && !args[1].endsWith(".json")) { + System.err.println("Unsupported output format: " + + out.getFileName()); + System.exit(-1); + } + + // Copy or convert input to output. + try { + if (args[0].endsWith(".csv") && args[1].endsWith(".csv") || + args[0].endsWith(".json") && args[1].endsWith(".json")) { + Files.copy(in, out); + } else { + final Converter converter = new Converter(); + final String input = Files.readString(in, UTF_8); + final String output = args[0].endsWith(".csv") + ? converter.csvToJSON(input) + : converter.jsonToCSV(input); + Files.writeString(out, output, UTF_8); + } + } catch (final Exception e) { + System.err.println("Error: " + e.getMessage()); + System.exit(-1); + } + } +} diff --git "a/\303\274bung1/src/main/java/Parser/Parser.java" "b/\303\274bung1/src/main/java/Parser/Parser.java" new file mode 100644 index 0000000000000000000000000000000000000000..d70f80705d92c61549f0aadbb4d13197f2890b55 --- /dev/null +++ "b/\303\274bung1/src/main/java/Parser/Parser.java" @@ -0,0 +1,114 @@ +package de.unibremen.swp; + +import de.unibremen.swp.data.CSVUser; +import de.unibremen.swp.data.JSONUser; + +import java.text.ParseException; +import java.util.List; + +/** + * Provides methods to read (also referred to as deserialization) and write + * (also referred to as serialization) {@link CSVUser} and {@link JSONUser} + * from and to strings. + */ +public class Parser { + + /** + * The delimiter used to separate values in CSV. + */ + private static final char CSV_DELIMITER = '‽'; + + /** + * Implements the integrity checks of {@link #readCSVUsers(String)} and + * {@link #writeCSVUsers(List)}. + */ + private void validate(final List<CSVUser> users) { + throw new UnsupportedOperationException(); + } + + /** + * Parses the given CSV string and creates a list of {@link CSVUser} from + * it. Duplicates (according to {@link CSVUser#equals(Object)}) are + * filtered out. + * + * @param csv + * The CSV string to parse. + * @return + * The users deserialized from {@code csv}. + * @throws NullPointerException + * If {@code csv} is {@code null}. + * @throws IllegalArgumentException + * If i) the id of a user is less than {@code 1} or greater than the + * total number of users stored in {@code csv}, ii) two users, + * {@code u1} and {@code u2} with {@code u1 != u2}, share the same id + * such that {@code u1.getId() == u2.getId()}, or iii) a user + * references a non-existing id in its list of friends (cf. + * {@link CSVUser#getFriends()}). + * @throws ParseException + * If an error occurred while parsing {@code csv}. + */ + public List<CSVUser> readCSVUsers(final String csv) throws + NullPointerException, IllegalArgumentException, ParseException { + throw new UnsupportedOperationException(); + } + + /** + * Creates a CSV string from the given list of {@link CSVUser}. Duplicates + * (according to {@link CSVUser#equals(Object)}) and {@code null} values in + * {@code users} are filtered out. + * + * @param users + * The users to serialize. + * @return + * The resulting CSV string. + * @throws NullPointerException + * If {@code users} is {@code null}. + * @throws IllegalArgumentException + * If i) the id of a user is less than {@code 1} or greater than the + * total number of users stored in {@code users}, ii) two users, + * {@code u1} and {@code u2} with {@code u1 != u2}, share the same id + * such that {@code u1.getId() == u2.getId()}, or iii) a user + * references a non-existing id in its list of friends (cf. + * {@link CSVUser#getFriends()}). + */ + public String writeCSVUsers(final List<CSVUser> users) throws + NullPointerException, IllegalArgumentException { + throw new UnsupportedOperationException(); + } + + /** + * Parses the given JSON string and creates a list of {@link JSONUser} from + * it. Duplicates (according to {@link JSONUser#equals(Object)}) are + * filtered out. + * + * @param json + * The JSON string to parse. + * @return + * The users deserialized from {@code json}. + * @throws NullPointerException + * If {@code json} is {@code null}. + * @throws ParseException + * If an error occurred while parsing {@code json}. + */ + public List<JSONUser> readJSONUsers(final String json) throws + NullPointerException, ParseException { + throw new UnsupportedOperationException(); + } + + /** + * Creates a JSON string from the given list of {@link JSONUser}. + * Duplicates (according to {@link JSONUser#equals(Object)}) and + * {@code null} values in {@code users} are filtered out. + * + * @param users + * The users to serialize. + * @return + * The resulting JSON string. + * @throws NullPointerException + * If {@code users} is {@code null}. + */ + public String writeJSONUsers(final List<JSONUser> users) throws + NullPointerException { + throw new UnsupportedOperationException(); + } +} diff --git "a/\303\274bung1/src/main/main.iml" "b/\303\274bung1/src/main/main.iml" new file mode 100644 index 0000000000000000000000000000000000000000..a08cc2256b2672477d6ee8e8851de50847be059f --- /dev/null +++ "b/\303\274bung1/src/main/main.iml" @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/java/Converter" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/java/CSVUser" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/java/JSONUser" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/java/Main" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/java/Parser" isTestSource="false" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> \ No newline at end of file diff --git "a/\303\274bung1/src/test/java/Convertertest/ConverterTest.java" "b/\303\274bung1/src/test/java/Convertertest/ConverterTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..e5aa23371c7d50b5cb9230ab2cff6b441fc81c4e --- /dev/null +++ "b/\303\274bung1/src/test/java/Convertertest/ConverterTest.java" @@ -0,0 +1,250 @@ +package de.unibremen.swp; + +import de.unibremen.swp.data.CSVUser; +import de.unibremen.swp.data.JSONUser; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.text.ParseException; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ConverterTest { + + private final Converter converter = new Converter(); + + private final Parser parser = new Parser(); + + @Test + void CSVToJSON() throws IOException, ParseException { + byte[] bytes = getClass() + .getResourceAsStream("/users.csv") + .readAllBytes(); + String csv = new String(bytes, StandardCharsets.UTF_8); + String json = converter.csvToJSON(csv); + + List<JSONUser> users = parser.readJSONUsers(json); + assertEquals( + 5, + users.size(), + "Number of user objects"); + + JSONUser michael = users.get(0); + JSONUser dwight = users.get(1); + JSONUser pam = users.get(2); + JSONUser jim = users.get(3); + JSONUser ryan = users.get(4); + + assertEquals( + "Michael", + michael.getFirstName(), + "Michael's first name"); + assertEquals( + "Scott", + michael.getLastName(), + "Michael's last name"); + assertEquals( + "Progress, not perfection.", + michael.getMotto(), + "Michael's motto"); + assertEquals( + List.of(pam, jim, ryan), + michael.getFriends(), + "Michael's friends"); + + assertEquals( + "Dwight", + dwight.getFirstName(), + "Dwight's first name"); + assertEquals( + "Schrute", + dwight.getLastName(), + "Dwight's last name"); + assertEquals( + "If you’re going through hell, keep going.", + dwight.getMotto(), + "Dwight's motto"); + assertEquals( + List.of(), + dwight.getFriends(), + "Dwight's friends"); + + assertEquals( + "Pam", + pam.getFirstName(), + "Pam's first name"); + assertEquals( + "Beesly", + pam.getLastName(), + "Pam's last name"); + assertEquals( + "Your pain today will be your strength tomorrow.", + pam.getMotto(), + "Pam's motto"); + assertEquals( + List.of(michael, jim), + pam.getFriends(), + "Pam's friends"); + + assertEquals( + "Jim", + jim.getFirstName(), + "Jim's first name"); + assertEquals( + "Halpert", + jim.getLastName(), + "Jim's last name"); + assertEquals( + "Act or accept.", + jim.getMotto(), + "Jim's motto"); + assertEquals( + List.of(michael, pam), + jim.getFriends(), + "Jim's friends"); + + assertEquals( + "Ryan", + ryan.getFirstName(), + "Ryan's first name"); + assertEquals( + "Howard", + ryan.getLastName(), + "Ryan's last name"); + assertEquals( + "I am strong,\nI am confident,\nand I am unstoppable.", + ryan.getMotto(), + "Ryan's motto"); + assertEquals( + List.of(ryan), + ryan.getFriends(), + "Ryan's friends"); + } + + @Test + void JSONToCSV() throws IOException, ParseException { + byte[] bytes = getClass() + .getResourceAsStream("/users.json") + .readAllBytes(); + String json = new String(bytes, StandardCharsets.UTF_8); + String csv = converter.jsonToCSV(json); + + List<CSVUser> users = parser.readCSVUsers(csv); + assertEquals( + 5, + users.size(), + "Number of user objects"); + + CSVUser michael = users.get(0); + assertEquals( + 1, + michael.getId(), + "Michael's id"); + assertEquals( + "Michael", + michael.getFirstName(), + "Michael's first name"); + assertEquals( + "Scott", + michael.getLastName(), + "Michael's last name"); + assertEquals( + "Progress, not perfection.", + michael.getMotto(), + "Michael's motto"); + assertEquals( + List.of(3, 4, 5), + michael.getFriends(), + "Michael's friends"); + + CSVUser dwight = users.get(1); + assertEquals( + 2, + dwight.getId(), + "Dwight's id"); + assertEquals( + "Dwight", + dwight.getFirstName(), + "Dwight's first name"); + assertEquals( + "Schrute", + dwight.getLastName(), + "Dwight's last name"); + assertEquals( + "If you’re going through hell, keep going.", + dwight.getMotto(), + "Dwight's motto"); + assertEquals( + List.of(), + dwight.getFriends(), + "Dwight's friends"); + + CSVUser pam = users.get(2); + assertEquals( + 3, + pam.getId(), + "Pam's id"); + assertEquals( + "Pam", + pam.getFirstName(), + "Pam's first name"); + assertEquals( + "Beesly", + pam.getLastName(), + "Pam's last name"); + assertEquals( + "Your pain today will be your strength tomorrow.", + pam.getMotto(), + "Pam's motto"); + assertEquals( + List.of(1, 4), + pam.getFriends(), + "Pam's friends"); + + CSVUser jim = users.get(3); + assertEquals( + 4, + jim.getId(), + "Jim's id"); + assertEquals( + "Jim", + jim.getFirstName(), + "Jim's first name"); + assertEquals( + "Halpert", + jim.getLastName(), + "Jim's last name"); + assertEquals( + "Act or accept.", + jim.getMotto(), + "Jim's motto"); + assertEquals( + List.of(1, 3), + jim.getFriends(), + "Jim's friends"); + + CSVUser ryan = users.get(4); + assertEquals( + 5, + ryan.getId(), + "Ryan's id"); + assertEquals( + "Ryan", + ryan.getFirstName(), + "Ryan's first name"); + assertEquals( + "Howard", + ryan.getLastName(), + "Ryan's last name"); + assertEquals( + "I am strong,\nI am confident,\nand I am unstoppable.", + ryan.getMotto(), + "Ryan's motto"); + assertEquals( + List.of(5), + ryan.getFriends(), + "Ryan's friends"); + } +} diff --git "a/\303\274bung1/src/test/java/Parsertest/ParserTest.java" "b/\303\274bung1/src/test/java/Parsertest/ParserTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..5efdb58876d1b058632818ec74cdafc3b694cc48 --- /dev/null +++ "b/\303\274bung1/src/test/java/Parsertest/ParserTest.java" @@ -0,0 +1,575 @@ +package de.unibremen.swp; + +import de.unibremen.swp.data.CSVUser; +import de.unibremen.swp.data.JSONUser; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +class ParserTest { + + private final Parser parser = new Parser(); + + @Nested + class CSV { + @Test + void readFromExampleFile() throws IOException, ParseException { + byte[] bytes = getClass() + .getResourceAsStream("/users.csv") + .readAllBytes(); + String csv = new String(bytes, StandardCharsets.UTF_8); + + List<CSVUser> users = parser.readCSVUsers(csv); + assertEquals( + 5, + users.size(), + "Number of user objects"); + + CSVUser michael = users.get(0); + assertEquals( + 1, + michael.getId(), + "Michael's id"); + assertEquals( + "Michael", + michael.getFirstName(), + "Michael's first name"); + assertEquals( + "Scott", + michael.getLastName(), + "Michael's last name"); + assertEquals( + "Progress, not perfection.", + michael.getMotto(), + "Michael's motto"); + assertEquals( + List.of(3, 4, 5), + michael.getFriends(), + "Michael's friends"); + + CSVUser dwight = users.get(1); + assertEquals( + 2, + dwight.getId(), + "Dwight's id"); + assertEquals( + "Dwight", + dwight.getFirstName(), + "Dwight's first name"); + assertEquals( + "Schrute", + dwight.getLastName(), + "Dwight's last name"); + assertEquals( + "If you’re going through hell, keep going.", + dwight.getMotto(), + "Dwight's motto"); + assertEquals( + List.of(), + dwight.getFriends(), + "Dwight's friends"); + + CSVUser pam = users.get(2); + assertEquals( + 3, + pam.getId(), + "Pam's id"); + assertEquals( + "Pam", + pam.getFirstName(), + "Pam's first name"); + assertEquals( + "Beesly", + pam.getLastName(), + "Pam's last name"); + assertEquals( + "Your pain today will be your strength tomorrow.", + pam.getMotto(), + "Pam's motto"); + assertEquals( + List.of(1, 4), + pam.getFriends(), + "Pam's friends"); + + CSVUser jim = users.get(3); + assertEquals( + 4, + jim.getId(), + "Jim's id"); + assertEquals( + "Jim", + jim.getFirstName(), + "Jim's first name"); + assertEquals( + "Halpert", + jim.getLastName(), + "Jim's last name"); + assertEquals( + "Act or accept.", + jim.getMotto(), + "Jim's motto"); + assertEquals( + List.of(1, 3), + jim.getFriends(), + "Jim's friends"); + + CSVUser ryan = users.get(4); + assertEquals( + 5, + ryan.getId(), + "Ryan's id"); + assertEquals( + "Ryan", + ryan.getFirstName(), + "Ryan's first name"); + assertEquals( + "Howard", + ryan.getLastName(), + "Ryan's last name"); + assertEquals( + "I am strong,\nI am confident,\nand I am unstoppable.", + ryan.getMotto(), + "Ryan's motto"); + assertEquals( + List.of(5), + ryan.getFriends(), + "Ryan's friends"); + } + + @Test + void writeAndCompareWithRead() throws ParseException { + CSVUser stanly = new CSVUser(); + stanly.setId(1); + stanly.setFirstName("Stanly"); + stanly.setLastName("Hudson"); + stanly.setMotto("Either you run the day or the day runs you."); + + CSVUser kelly = new CSVUser(); + kelly.setId(2); + kelly.setFirstName("Kelly"); + kelly.setLastName("Kapoor"); + kelly.setFriends(List.of(3)); + + CSVUser phyllis = new CSVUser(); + phyllis.setId(3); + phyllis.setFirstName("Phyllis"); + phyllis.setLastName("Vance"); + phyllis.setFriends(List.of(1, 2)); + + String csv = parser.writeCSVUsers(List.of(stanly, kelly, phyllis)); + List<CSVUser> users = parser.readCSVUsers(csv); + assertEquals( + 3, + users.size(), + "Number of user objects"); + + stanly = users.get(0); + assertEquals( + 1, + stanly.getId(), + "Stanly's id"); + assertEquals( + "Stanly", + stanly.getFirstName(), + "Stanly's first name"); + assertEquals( + "Hudson", + stanly.getLastName(), + "Stanly's last name"); + assertEquals( + "Either you run the day or the day runs you.", + stanly.getMotto(), + "Stanly's motto"); + assertEquals( + List.of(), + stanly.getFriends(), + "Stanly's friends"); + + kelly = users.get(1); + assertEquals( + 2, + kelly.getId(), + "Kelly's id"); + assertEquals( + "Kelly", + kelly.getFirstName(), + "Kelly's first name"); + assertEquals( + "Kapoor", + kelly.getLastName(), + "Kelly's last name"); + assertEquals( + "", + kelly.getMotto(), + "Kelly's motto"); + assertEquals( + List.of(3), + kelly.getFriends(), + "Kelly's friends"); + + phyllis = users.get(2); + assertEquals( + 3, + phyllis.getId(), + "Phyllis' id"); + assertEquals( + "Phyllis", + phyllis.getFirstName(), + "Phyllis' first name"); + assertEquals( + "Vance", + phyllis.getLastName(), + "Phyllis' last name"); + assertEquals( + "", + phyllis.getMotto(), + "Phyllis' motto"); + assertEquals( + List.of(1, 2), + phyllis.getFriends(), + "Phyllis' friends"); + } + + @Test + void readWithInvalidId() { + assertThrows(IllegalArgumentException.class, + () -> parser.readCSVUsers( + "ID‽First Name‽Last Name‽Motto‽Friends\n0‽‽‽‽")); + + assertThrows(IllegalArgumentException.class, + () -> parser.readCSVUsers( + "ID‽First Name‽Last Name‽Motto‽Friends\n2‽‽‽‽")); + } + + @Test + void writeWithInvalidId() { + CSVUser user = new CSVUser(); + Executable executable = () -> + parser.writeCSVUsers(List.of(user)); + + user.setId(0); + assertThrows(IllegalArgumentException.class, executable); + + user.setId(2); + assertThrows(IllegalArgumentException.class, executable); + } + + @Test + void readDifferentWithSameId() { + assertThrows(IllegalArgumentException.class, + () -> parser.readCSVUsers( + "ID‽First Name‽Last Name‽Motto‽Friends\n" + + "1‽a‽‽‽\n" + + "1‽b‽‽‽")); + } + + @Test + void writeDifferentWithSameId() { + CSVUser u1 = new CSVUser(); + u1.setId(1); + CSVUser u2 = new CSVUser(); + u2.setId(1); + + assertThrows(IllegalArgumentException.class, () -> + parser.writeCSVUsers(List.of(u1, u2))); + } + + @Test + void writeSameTwice() { + CSVUser u = new CSVUser(); + u.setId(1); + + String csv = parser.writeCSVUsers(List.of(u, u)); + int count = (int) csv.chars().filter(c -> c == '1').count(); + assertEquals( + 1, + count, + "Occurrence of id"); + } + + @Test + void readWithInvalidFriends() { + assertThrows(IllegalArgumentException.class, + () -> parser.readCSVUsers( + "ID‽First Name‽Last Name‽Motto‽Friends\n1‽‽‽‽2,3")); + } + + @Test + void writeWithInvalidFriends() { + CSVUser u = new CSVUser(); + u.setId(1); + u.setFriends(List.of(2, 3)); + + assertThrows(IllegalArgumentException.class, () -> + parser.writeCSVUsers(List.of(u))); + } + + @Test + void readNullParameter() { + assertThrows(NullPointerException.class, + () -> parser.readCSVUsers(null)); + } + + @Test + void writeNullParameter() { + assertThrows(NullPointerException.class, + () -> parser.writeCSVUsers(null)); + } + + @Test + void writeNullInListAndCompareWithRead() throws ParseException { + CSVUser u = new CSVUser(); + u.setId(1); + // ArrayList permits null. + ArrayList<CSVUser> list = new ArrayList<>(); + list.add(u); + list.add(null); + + String csv = parser.writeCSVUsers(list); + List<CSVUser> users = parser.readCSVUsers(csv); + assertEquals( + 1, + users.size(), + "Number of user objects"); + } + } + + @Nested + class JSON { + @Test + void readFromExampleFile() throws IOException, ParseException { + byte[] bytes = getClass() + .getResourceAsStream("/users.json") + .readAllBytes(); + String json = new String(bytes, StandardCharsets.UTF_8); + + List<JSONUser> users = parser.readJSONUsers(json); + assertEquals( + 5, + users.size(), + "Number of user objects"); + + JSONUser michael = users.get(0); + JSONUser dwight = users.get(1); + JSONUser pam = users.get(2); + JSONUser jim = users.get(3); + JSONUser ryan = users.get(4); + + assertEquals( + "Michael", + michael.getFirstName(), + "Michael's first name"); + assertEquals( + "Scott", + michael.getLastName(), + "Michael's last name"); + assertEquals( + "Progress, not perfection.", + michael.getMotto(), + "Michael's motto"); + assertEquals( + List.of(pam, jim, ryan), + michael.getFriends(), + "Michael's friends"); + + assertEquals( + "Dwight", + dwight.getFirstName(), + "Dwight's first name"); + assertEquals( + "Schrute", + dwight.getLastName(), + "Dwight's last name"); + assertEquals( + "If you’re going through hell, keep going.", + dwight.getMotto(), + "Dwight's motto"); + assertEquals( + List.of(), + dwight.getFriends(), + "Dwight's friends"); + + assertEquals( + "Pam", + pam.getFirstName(), + "Pam's first name"); + assertEquals( + "Beesly", + pam.getLastName(), + "Pam's last name"); + assertEquals( + "Your pain today will be your strength tomorrow.", + pam.getMotto(), + "Pam's motto"); + assertEquals( + List.of(michael, jim), + pam.getFriends(), + "Pam's friends"); + + assertEquals( + "Jim", + jim.getFirstName(), + "Jim's first name"); + assertEquals( + "Halpert", + jim.getLastName(), + "Jim's last name"); + assertEquals( + "Act or accept.", + jim.getMotto(), + "Jim's motto"); + assertEquals( + List.of(michael, pam), + jim.getFriends(), + "Jim's friends"); + + assertEquals( + "Ryan", + ryan.getFirstName(), + "Ryan's first name"); + assertEquals( + "Howard", + ryan.getLastName(), + "Ryan's last name"); + assertEquals( + "I am strong,\nI am confident,\nand I am unstoppable.", + ryan.getMotto(), + "Ryan's motto"); + assertEquals( + List.of(ryan), + ryan.getFriends(), + "Ryan's friends"); + } + + @Test + void writeAndCompareWithRead() throws ParseException { + JSONUser stanly = new JSONUser(); + stanly.setFirstName("Stanly"); + stanly.setLastName("Hudson"); + stanly.setMotto("Either you run the day or the day runs you."); + + JSONUser kelly = new JSONUser(); + kelly.setFirstName("Kelly"); + kelly.setLastName("Kapoor"); + + JSONUser phyllis = new JSONUser(); + phyllis.setFirstName("Phyllis"); + phyllis.setLastName("Vance"); + + kelly.setFriends(List.of(phyllis)); + phyllis.setFriends(List.of(stanly, kelly)); + + String json = parser.writeJSONUsers( + List.of(stanly, kelly, phyllis)); + List<JSONUser> users = parser.readJSONUsers(json); + assertEquals( + 3, + users.size(), + "Number of user objects"); + + stanly = users.get(0); + kelly = users.get(1); + phyllis = users.get(2); + + assertEquals( + "Stanly", + stanly.getFirstName(), + "Stanly's first name"); + assertEquals( + "Hudson", + stanly.getLastName(), + "Stanly's last name"); + assertEquals( + "Either you run the day or the day runs you.", + stanly.getMotto(), + "Stanly's motto"); + assertEquals( + List.of(), + stanly.getFriends(), + "Stanly's friends"); + + assertEquals( + "Kelly", + kelly.getFirstName(), + "Kelly's first name"); + assertEquals( + "Kapoor", + kelly.getLastName(), + "Kelly's last name"); + assertEquals( + "", + kelly.getMotto(), + "Kelly's motto"); + assertEquals( + List.of(phyllis), + kelly.getFriends(), + "Kelly's friends"); + + assertEquals( + "Phyllis", + phyllis.getFirstName(), + "Phyllis' first name"); + assertEquals( + "Vance", + phyllis.getLastName(), + "Phyllis' last name"); + assertEquals( + "", + phyllis.getMotto(), + "Phyllis' motto"); + assertEquals( + List.of(stanly, kelly), + phyllis.getFriends(), + "Phyllis' friends"); + } + + @Test + void writeSameTwice() { + JSONUser u = new JSONUser(); + + String json = parser.writeJSONUsers(List.of(u, u)); + int count = (int) json.chars().filter(c -> c == '@').count(); + assertEquals( + 1, + count, + "Occurrence of @ (from @id)"); + } + + @Test + void readNullParameter() { + assertThrows(NullPointerException.class, + () -> parser.readJSONUsers(null)); + } + + @Test + void writeNullParameter() { + assertThrows(NullPointerException.class, + () -> parser.writeJSONUsers(null)); + } + + @Test + void writeNullInListAndCompareWithRead() throws ParseException { + JSONUser u = new JSONUser(); + // ArrayList permits null. + ArrayList<JSONUser> list = new ArrayList<>(); + list.add(u); + list.add(null); + + String json = parser.writeJSONUsers(list); + List<JSONUser> users = parser.readJSONUsers(json); + assertEquals( + 1, + users.size(), + "Number of user objects"); + } + } +} diff --git "a/\303\274bung1/src/test/resources/users.csv" "b/\303\274bung1/src/test/resources/users.csv" new file mode 100644 index 0000000000000000000000000000000000000000..a54d1f127b36081a327a6b3fd53b731b2685963b --- /dev/null +++ "b/\303\274bung1/src/test/resources/users.csv" @@ -0,0 +1,9 @@ +ID‽First Name‽Last Name‽Motto‽Friends +1‽Michael‽Scott‽"Progress, not perfection."‽3, 4,5 +2‽Dwight‽Schrute‽"If you’re going through hell, keep going."‽ +3‽Pam‽Beesly‽"Your pain today will be your strength tomorrow."‽"1, +4" +4‽Jim‽Halpert‽"Act or accept."‽1,3 +5‽Ryan‽Howard‽"I am strong, +I am confident, +and I am unstoppable."‽5 diff --git "a/\303\274bung1/src/test/resources/users.json" "b/\303\274bung1/src/test/resources/users.json" new file mode 100644 index 0000000000000000000000000000000000000000..586088ea1471ea1268433032bea6d6481957c6f6 --- /dev/null +++ "b/\303\274bung1/src/test/resources/users.json" @@ -0,0 +1,47 @@ +[ { + "@id" : "1", + "firstName" : "Michael", + "lastName" : "Scott", + "motto" : "Progress, not perfection.", + "friends" : [ { + "@id" : "2", + "firstName" : "Pam", + "lastName" : "Beesly", + "motto" : "Your pain today will be your strength tomorrow.", + "friends" : [ { + "@ref" : "1" + }, { + "@id" : "3", + "firstName" : "Jim", + "lastName" : "Halpert", + "motto" : "Act or accept.", + "friends" : [ { + "@ref" : "1" + }, { + "@ref" : "2" + } ] + } ] + }, { + "@ref" : "3" + }, { + "@id" : "4", + "firstName" : "Ryan", + "lastName" : "Howard", + "motto" : "I am strong,\nI am confident,\nand I am unstoppable.", + "friends" : [ { + "@ref" : "4" + } ] + } ] +}, { + "@id" : "5", + "firstName" : "Dwight", + "lastName" : "Schrute", + "motto" : "If you’re going through hell, keep going.", + "friends" : [ ] +}, { + "@ref" : "2" +}, { + "@ref" : "3" +}, { + "@ref" : "4" +} ] diff --git "a/\303\274bung1/src/test/test.iml" "b/\303\274bung1/src/test/test.iml" new file mode 100644 index 0000000000000000000000000000000000000000..b51f04d4dbc5cc319edb9dfb50e578aedaf6f6d2 --- /dev/null +++ "b/\303\274bung1/src/test/test.iml" @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/java/Convertertest" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/java/Parsertest" isTestSource="false" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="main" /> + <orderEntry type="module" module-name="main" /> + </component> +</module> \ No newline at end of file diff --git "a/\303\274bung1/target/classes/de/unibremen/swp/Converter.class" "b/\303\274bung1/target/classes/de/unibremen/swp/Converter.class" new file mode 100644 index 0000000000000000000000000000000000000000..cc8b2199b6b22db153b4988b7c0a670e507cdf25 Binary files /dev/null and "b/\303\274bung1/target/classes/de/unibremen/swp/Converter.class" differ diff --git "a/\303\274bung1/target/classes/de/unibremen/swp/Main.class" "b/\303\274bung1/target/classes/de/unibremen/swp/Main.class" new file mode 100644 index 0000000000000000000000000000000000000000..271cad051d7b81b3c9b6da812d9dfb08bc8676af Binary files /dev/null and "b/\303\274bung1/target/classes/de/unibremen/swp/Main.class" differ diff --git "a/\303\274bung1/target/classes/de/unibremen/swp/Parser.class" "b/\303\274bung1/target/classes/de/unibremen/swp/Parser.class" new file mode 100644 index 0000000000000000000000000000000000000000..f0b1dc751f420546a6b302ccbd1fd96068677527 Binary files /dev/null and "b/\303\274bung1/target/classes/de/unibremen/swp/Parser.class" differ diff --git "a/\303\274bung1/target/classes/de/unibremen/swp/data/CSVUser.class" "b/\303\274bung1/target/classes/de/unibremen/swp/data/CSVUser.class" new file mode 100644 index 0000000000000000000000000000000000000000..91faf9155ffdf67057f08712b21111ea9e04b828 Binary files /dev/null and "b/\303\274bung1/target/classes/de/unibremen/swp/data/CSVUser.class" differ diff --git "a/\303\274bung1/target/classes/de/unibremen/swp/data/JSONUser.class" "b/\303\274bung1/target/classes/de/unibremen/swp/data/JSONUser.class" new file mode 100644 index 0000000000000000000000000000000000000000..66f6ca16f0c560636c5702a71d47e6218527ccda Binary files /dev/null and "b/\303\274bung1/target/classes/de/unibremen/swp/data/JSONUser.class" differ diff --git "a/\303\274bung1/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst" "b/\303\274bung1/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst" new file mode 100644 index 0000000000000000000000000000000000000000..c65f060cd41752535648136e583456bbcf3033ac --- /dev/null +++ "b/\303\274bung1/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst" @@ -0,0 +1,5 @@ +de\unibremen\swp\Main.class +de\unibremen\swp\data\CSVUser.class +de\unibremen\swp\data\JSONUser.class +de\unibremen\swp\Converter.class +de\unibremen\swp\Parser.class diff --git "a/\303\274bung1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst" "b/\303\274bung1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst" new file mode 100644 index 0000000000000000000000000000000000000000..bf0d2fd4af8a8661157f22839731f7aaf777d503 --- /dev/null +++ "b/\303\274bung1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst" @@ -0,0 +1,6 @@ +C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\src\main\java\Parser\Parser.java +C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\src\main\java\de\unibremen\swp\App.java +C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\src\main\java\Main\Main.java +C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\src\main\java\Converter\Converter.java +C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\src\main\java\CSVUser\CSVUser.java +C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\src\main\java\JSONUser\JSONUser.java diff --git "a/\303\274bung1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst" "b/\303\274bung1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst" new file mode 100644 index 0000000000000000000000000000000000000000..f4c585e409c86a7895a7992dacbcdfba592d4570 --- /dev/null +++ "b/\303\274bung1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst" @@ -0,0 +1,4 @@ +de\unibremen\swp\ParserTest$CSV.class +de\unibremen\swp\ConverterTest.class +de\unibremen\swp\ParserTest$JSON.class +de\unibremen\swp\ParserTest.class diff --git "a/\303\274bung1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst" "b/\303\274bung1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst" new file mode 100644 index 0000000000000000000000000000000000000000..60481e073c7a8a785d542fbf9fdeb8302d522c03 --- /dev/null +++ "b/\303\274bung1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst" @@ -0,0 +1,3 @@ +C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\src\test\java\de\unibremen\swp\AppTest.java +C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\src\test\java\Convertertest\ConverterTest.java +C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\src\test\java\Parsertest\ParserTest.java diff --git "a/\303\274bung1/target/surefire-reports/TEST-de.unibremen.swp.ConverterTest.xml" "b/\303\274bung1/target/surefire-reports/TEST-de.unibremen.swp.ConverterTest.xml" new file mode 100644 index 0000000000000000000000000000000000000000..ad4ab9c4dcd0ba5cad4cd1d564e00f37dc0ddfd9 --- /dev/null +++ "b/\303\274bung1/target/surefire-reports/TEST-de.unibremen.swp.ConverterTest.xml" @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="UTF-8"?> +<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" name="de.unibremen.swp.ConverterTest" time="0.031" tests="2" errors="2" skipped="0" failures="0"> + <properties> + <property name="sun.desktop" value="windows"/> + <property name="awt.toolkit" value="sun.awt.windows.WToolkit"/> + <property name="java.specification.version" value="11"/> + <property name="sun.cpu.isalist" value="amd64"/> + <property name="sun.jnu.encoding" value="Cp1252"/> + <property name="java.class.path" value="C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\target\test-classes;C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\target\classes;C:\Users\Administrator\.m2\repository\junit\junit\3.8.1\junit-3.8.1.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-engine\5.6.1\junit-jupiter-engine-5.6.1.jar;C:\Users\Administrator\.m2\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;C:\Users\Administrator\.m2\repository\org\junit\platform\junit-platform-engine\1.6.1\junit-platform-engine-1.6.1.jar;C:\Users\Administrator\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\Administrator\.m2\repository\org\junit\platform\junit-platform-commons\1.6.1\junit-platform-commons-1.6.1.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.6.1\junit-jupiter-api-5.6.1.jar;"/> + <property name="java.vm.vendor" value="AdoptOpenJDK"/> + <property name="sun.arch.data.model" value="64"/> + <property name="user.variant" value=""/> + <property name="java.vendor.url" value="https://adoptopenjdk.net/"/> + <property name="user.timezone" value="Europe/Berlin"/> + <property name="java.vm.specification.version" value="11"/> + <property name="os.name" value="Windows 10"/> + <property name="sun.java.launcher" value="SUN_STANDARD"/> + <property name="user.country" value="DE"/> + <property name="sun.boot.library.path" value="C:\Program Files\AdoptOpenJDK\jdk-11.0.8.10-hotspot\bin"/> + <property name="sun.java.command" value="C:\Users\ADMINI~1\AppData\Local\Temp\surefire16384117284068919217\surefirebooter6360847745344186146.jar C:\Users\Administrator\AppData\Local\Temp\surefire16384117284068919217 2020-10-28T22-13-34_783-jvmRun1 surefire12350635713470639493tmp surefire_01285077207227050327tmp"/> + <property name="jdk.debug" value="release"/> + <property name="surefire.test.class.path" value="C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\target\test-classes;C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\target\classes;C:\Users\Administrator\.m2\repository\junit\junit\3.8.1\junit-3.8.1.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-engine\5.6.1\junit-jupiter-engine-5.6.1.jar;C:\Users\Administrator\.m2\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;C:\Users\Administrator\.m2\repository\org\junit\platform\junit-platform-engine\1.6.1\junit-platform-engine-1.6.1.jar;C:\Users\Administrator\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\Administrator\.m2\repository\org\junit\platform\junit-platform-commons\1.6.1\junit-platform-commons-1.6.1.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.6.1\junit-jupiter-api-5.6.1.jar;"/> + <property name="sun.cpu.endian" value="little"/> + <property name="user.home" value="C:\Users\Administrator"/> + <property name="user.language" value="de"/> + <property name="java.specification.vendor" value="Oracle Corporation"/> + <property name="java.version.date" value="2020-07-14"/> + <property name="java.home" value="C:\Program Files\AdoptOpenJDK\jdk-11.0.8.10-hotspot"/> + <property name="file.separator" value="\"/> + <property name="basedir" value="C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt"/> + <property name="java.vm.compressedOopsMode" value="32-bit"/> + <property name="line.separator" value=" "/> + <property name="java.specification.name" value="Java Platform API Specification"/> + <property name="java.vm.specification.vendor" value="Oracle Corporation"/> + <property name="java.awt.graphicsenv" value="sun.awt.Win32GraphicsEnvironment"/> + <property name="surefire.real.class.path" value="C:\Users\ADMINI~1\AppData\Local\Temp\surefire16384117284068919217\surefirebooter6360847745344186146.jar"/> + <property name="user.script" value=""/> + <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/> + <property name="java.runtime.version" value="11.0.8+10"/> + <property name="user.name" value="Administrator"/> + <property name="path.separator" value=";"/> + <property name="os.version" value="10.0"/> + <property name="java.runtime.name" value="OpenJDK Runtime Environment"/> + <property name="file.encoding" value="Cp1252"/> + <property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/> + <property name="java.vendor.version" value="AdoptOpenJDK"/> + <property name="localRepository" value="C:\Users\Administrator\.m2\repository"/> + <property name="java.vendor.url.bug" value="https://github.com/AdoptOpenJDK/openjdk-support/issues"/> + <property name="java.io.tmpdir" value="C:\Users\ADMINI~1\AppData\Local\Temp\"/> + <property name="java.version" value="11.0.8"/> + <property name="user.dir" value="C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt"/> + <property name="os.arch" value="amd64"/> + <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/> + <property name="java.awt.printerjob" value="sun.awt.windows.WPrinterJob"/> + <property name="sun.os.patch.level" value=""/> + <property name="java.library.path" value="C:\Program Files\AdoptOpenJDK\jdk-11.0.8.10-hotspot\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\AdoptOpenJDK\jdk-11.0.8.10-hotspot\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.6.3\bin;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.6.3\bin;C:\Program Files\Git\cmd;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;;."/> + <property name="java.vm.info" value="mixed mode"/> + <property name="java.vendor" value="AdoptOpenJDK"/> + <property name="java.vm.version" value="11.0.8+10"/> + <property name="sun.io.unicode.encoding" value="UnicodeLittle"/> + <property name="java.class.version" value="55.0"/> + </properties> + <testcase name="CSVToJSON" classname="de.unibremen.swp.ConverterTest" time="0.031"> + <error type="java.lang.UnsupportedOperationException">java.lang.UnsupportedOperationException + at de.unibremen.swp.ConverterTest.CSVToJSON(ConverterTest.java:26) +</error> + </testcase> + <testcase name="JSONToCSV" classname="de.unibremen.swp.ConverterTest" time="0"> + <error type="java.lang.UnsupportedOperationException">java.lang.UnsupportedOperationException + at de.unibremen.swp.ConverterTest.JSONToCSV(ConverterTest.java:132) +</error> + </testcase> +</testsuite> \ No newline at end of file diff --git "a/\303\274bung1/target/surefire-reports/TEST-de.unibremen.swp.ParserTest.xml" "b/\303\274bung1/target/surefire-reports/TEST-de.unibremen.swp.ParserTest.xml" new file mode 100644 index 0000000000000000000000000000000000000000..0530632318292a76df3fd9f1b40dd38aa5926262 --- /dev/null +++ "b/\303\274bung1/target/surefire-reports/TEST-de.unibremen.swp.ParserTest.xml" @@ -0,0 +1,183 @@ +<?xml version="1.0" encoding="UTF-8"?> +<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" name="de.unibremen.swp.ParserTest" time="0" tests="18" errors="8" skipped="0" failures="10"> + <properties> + <property name="sun.desktop" value="windows"/> + <property name="awt.toolkit" value="sun.awt.windows.WToolkit"/> + <property name="java.specification.version" value="11"/> + <property name="sun.cpu.isalist" value="amd64"/> + <property name="sun.jnu.encoding" value="Cp1252"/> + <property name="java.class.path" value="C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\target\test-classes;C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\target\classes;C:\Users\Administrator\.m2\repository\junit\junit\3.8.1\junit-3.8.1.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-engine\5.6.1\junit-jupiter-engine-5.6.1.jar;C:\Users\Administrator\.m2\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;C:\Users\Administrator\.m2\repository\org\junit\platform\junit-platform-engine\1.6.1\junit-platform-engine-1.6.1.jar;C:\Users\Administrator\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\Administrator\.m2\repository\org\junit\platform\junit-platform-commons\1.6.1\junit-platform-commons-1.6.1.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.6.1\junit-jupiter-api-5.6.1.jar;"/> + <property name="java.vm.vendor" value="AdoptOpenJDK"/> + <property name="sun.arch.data.model" value="64"/> + <property name="user.variant" value=""/> + <property name="java.vendor.url" value="https://adoptopenjdk.net/"/> + <property name="user.timezone" value="Europe/Berlin"/> + <property name="java.vm.specification.version" value="11"/> + <property name="os.name" value="Windows 10"/> + <property name="sun.java.launcher" value="SUN_STANDARD"/> + <property name="user.country" value="DE"/> + <property name="sun.boot.library.path" value="C:\Program Files\AdoptOpenJDK\jdk-11.0.8.10-hotspot\bin"/> + <property name="sun.java.command" value="C:\Users\ADMINI~1\AppData\Local\Temp\surefire16384117284068919217\surefirebooter6360847745344186146.jar C:\Users\Administrator\AppData\Local\Temp\surefire16384117284068919217 2020-10-28T22-13-34_783-jvmRun1 surefire12350635713470639493tmp surefire_01285077207227050327tmp"/> + <property name="jdk.debug" value="release"/> + <property name="surefire.test.class.path" value="C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\target\test-classes;C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt\target\classes;C:\Users\Administrator\.m2\repository\junit\junit\3.8.1\junit-3.8.1.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-engine\5.6.1\junit-jupiter-engine-5.6.1.jar;C:\Users\Administrator\.m2\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;C:\Users\Administrator\.m2\repository\org\junit\platform\junit-platform-engine\1.6.1\junit-platform-engine-1.6.1.jar;C:\Users\Administrator\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\Administrator\.m2\repository\org\junit\platform\junit-platform-commons\1.6.1\junit-platform-commons-1.6.1.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.6.1\junit-jupiter-api-5.6.1.jar;"/> + <property name="sun.cpu.endian" value="little"/> + <property name="user.home" value="C:\Users\Administrator"/> + <property name="user.language" value="de"/> + <property name="java.specification.vendor" value="Oracle Corporation"/> + <property name="java.version.date" value="2020-07-14"/> + <property name="java.home" value="C:\Program Files\AdoptOpenJDK\jdk-11.0.8.10-hotspot"/> + <property name="file.separator" value="\"/> + <property name="basedir" value="C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt"/> + <property name="java.vm.compressedOopsMode" value="32-bit"/> + <property name="line.separator" value=" "/> + <property name="java.specification.name" value="Java Platform API Specification"/> + <property name="java.vm.specification.vendor" value="Oracle Corporation"/> + <property name="java.awt.graphicsenv" value="sun.awt.Win32GraphicsEnvironment"/> + <property name="surefire.real.class.path" value="C:\Users\ADMINI~1\AppData\Local\Temp\surefire16384117284068919217\surefirebooter6360847745344186146.jar"/> + <property name="user.script" value=""/> + <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/> + <property name="java.runtime.version" value="11.0.8+10"/> + <property name="user.name" value="Administrator"/> + <property name="path.separator" value=";"/> + <property name="os.version" value="10.0"/> + <property name="java.runtime.name" value="OpenJDK Runtime Environment"/> + <property name="file.encoding" value="Cp1252"/> + <property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/> + <property name="java.vendor.version" value="AdoptOpenJDK"/> + <property name="localRepository" value="C:\Users\Administrator\.m2\repository"/> + <property name="java.vendor.url.bug" value="https://github.com/AdoptOpenJDK/openjdk-support/issues"/> + <property name="java.io.tmpdir" value="C:\Users\ADMINI~1\AppData\Local\Temp\"/> + <property name="java.version" value="11.0.8"/> + <property name="user.dir" value="C:\Users\Administrator\Desktop\Universität Bremen\Semester 5\SWP2\Vorbereitung\Repository\MiniProjekt"/> + <property name="os.arch" value="amd64"/> + <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/> + <property name="java.awt.printerjob" value="sun.awt.windows.WPrinterJob"/> + <property name="sun.os.patch.level" value=""/> + <property name="java.library.path" value="C:\Program Files\AdoptOpenJDK\jdk-11.0.8.10-hotspot\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\AdoptOpenJDK\jdk-11.0.8.10-hotspot\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.6.3\bin;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.6.3\bin;C:\Program Files\Git\cmd;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;;."/> + <property name="java.vm.info" value="mixed mode"/> + <property name="java.vendor" value="AdoptOpenJDK"/> + <property name="java.vm.version" value="11.0.8+10"/> + <property name="sun.io.unicode.encoding" value="UnicodeLittle"/> + <property name="java.class.version" value="55.0"/> + </properties> + <testcase name="readFromExampleFile" classname="de.unibremen.swp.ParserTest$JSON" time="0"> + <error type="java.lang.UnsupportedOperationException">java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$JSON.readFromExampleFile(ParserTest.java:355) +</error> + </testcase> + <testcase name="readFromExampleFile" classname="de.unibremen.swp.ParserTest$CSV" time="0"> + <error type="java.lang.UnsupportedOperationException">java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.readFromExampleFile(ParserTest.java:31) +</error> + </testcase> + <testcase name="writeNullParameter" classname="de.unibremen.swp.ParserTest$JSON" time="0"> + <failure message="Unexpected exception type thrown ==> expected: <java.lang.NullPointerException> but was: <java.lang.UnsupportedOperationException>" type="org.opentest4j.AssertionFailedError"><![CDATA[org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.NullPointerException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$JSON.writeNullParameter(ParserTest.java:555) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$JSON.lambda$writeNullParameter$2(ParserTest.java:556) + at de.unibremen.swp.ParserTest$JSON.writeNullParameter(ParserTest.java:555) +]]></failure> + </testcase> + <testcase name="writeNullParameter" classname="de.unibremen.swp.ParserTest$CSV" time="0"> + <failure message="Unexpected exception type thrown ==> expected: <java.lang.NullPointerException> but was: <java.lang.UnsupportedOperationException>" type="org.opentest4j.AssertionFailedError"><![CDATA[org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.NullPointerException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.writeNullParameter(ParserTest.java:324) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$writeNullParameter$9(ParserTest.java:325) + at de.unibremen.swp.ParserTest$CSV.writeNullParameter(ParserTest.java:324) +]]></failure> + </testcase> + <testcase name="writeSameTwice" classname="de.unibremen.swp.ParserTest$JSON" time="0"> + <error type="java.lang.UnsupportedOperationException">java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$JSON.writeSameTwice(ParserTest.java:539) +</error> + </testcase> + <testcase name="writeSameTwice" classname="de.unibremen.swp.ParserTest$CSV" time="0"> + <error type="java.lang.UnsupportedOperationException">java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.writeSameTwice(ParserTest.java:291) +</error> + </testcase> + <testcase name="writeNullInListAndCompareWithRead" classname="de.unibremen.swp.ParserTest$JSON" time="0"> + <error type="java.lang.UnsupportedOperationException">java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$JSON.writeNullInListAndCompareWithRead(ParserTest.java:567) +</error> + </testcase> + <testcase name="writeNullInListAndCompareWithRead" classname="de.unibremen.swp.ParserTest$CSV" time="0"> + <error type="java.lang.UnsupportedOperationException">java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.writeNullInListAndCompareWithRead(ParserTest.java:337) +</error> + </testcase> + <testcase name="readNullParameter" classname="de.unibremen.swp.ParserTest$JSON" time="0"> + <failure message="Unexpected exception type thrown ==> expected: <java.lang.NullPointerException> but was: <java.lang.UnsupportedOperationException>" type="org.opentest4j.AssertionFailedError"><![CDATA[org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.NullPointerException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$JSON.readNullParameter(ParserTest.java:549) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$JSON.lambda$readNullParameter$1(ParserTest.java:550) + at de.unibremen.swp.ParserTest$JSON.readNullParameter(ParserTest.java:549) +]]></failure> + </testcase> + <testcase name="readNullParameter" classname="de.unibremen.swp.ParserTest$CSV" time="0"> + <failure message="Unexpected exception type thrown ==> expected: <java.lang.NullPointerException> but was: <java.lang.UnsupportedOperationException>" type="org.opentest4j.AssertionFailedError"><![CDATA[org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.NullPointerException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.readNullParameter(ParserTest.java:318) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$readNullParameter$8(ParserTest.java:319) + at de.unibremen.swp.ParserTest$CSV.readNullParameter(ParserTest.java:318) +]]></failure> + </testcase> + <testcase name="writeAndCompareWithRead" classname="de.unibremen.swp.ParserTest$JSON" time="0"> + <error type="java.lang.UnsupportedOperationException">java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$JSON.writeAndCompareWithRead(ParserTest.java:471) +</error> + </testcase> + <testcase name="writeAndCompareWithRead" classname="de.unibremen.swp.ParserTest$CSV" time="0"> + <error type="java.lang.UnsupportedOperationException">java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.writeAndCompareWithRead(ParserTest.java:168) +</error> + </testcase> + <testcase name="readDifferentWithSameId" classname="de.unibremen.swp.ParserTest$CSV" time="0"> + <failure message="Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException>" type="org.opentest4j.AssertionFailedError"><![CDATA[org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.readDifferentWithSameId(ParserTest.java:268) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$readDifferentWithSameId$3(ParserTest.java:269) + at de.unibremen.swp.ParserTest$CSV.readDifferentWithSameId(ParserTest.java:268) +]]></failure> + </testcase> + <testcase name="writeWithInvalidId" classname="de.unibremen.swp.ParserTest$CSV" time="0"> + <failure message="Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException>" type="org.opentest4j.AssertionFailedError"><![CDATA[org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.writeWithInvalidId(ParserTest.java:260) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$writeWithInvalidId$2(ParserTest.java:257) + at de.unibremen.swp.ParserTest$CSV.writeWithInvalidId(ParserTest.java:260) +]]></failure> + </testcase> + <testcase name="writeDifferentWithSameId" classname="de.unibremen.swp.ParserTest$CSV" time="0"> + <failure message="Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException>" type="org.opentest4j.AssertionFailedError"><![CDATA[org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.writeDifferentWithSameId(ParserTest.java:282) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$writeDifferentWithSameId$4(ParserTest.java:283) + at de.unibremen.swp.ParserTest$CSV.writeDifferentWithSameId(ParserTest.java:282) +]]></failure> + </testcase> + <testcase name="writeWithInvalidFriends" classname="de.unibremen.swp.ParserTest$CSV" time="0"> + <failure message="Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException>" type="org.opentest4j.AssertionFailedError"><![CDATA[org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.writeWithInvalidFriends(ParserTest.java:312) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$writeWithInvalidFriends$7(ParserTest.java:313) + at de.unibremen.swp.ParserTest$CSV.writeWithInvalidFriends(ParserTest.java:312) +]]></failure> + </testcase> + <testcase name="readWithInvalidId" classname="de.unibremen.swp.ParserTest$CSV" time="0"> + <failure message="Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException>" type="org.opentest4j.AssertionFailedError"><![CDATA[org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.readWithInvalidId(ParserTest.java:244) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$readWithInvalidId$0(ParserTest.java:245) + at de.unibremen.swp.ParserTest$CSV.readWithInvalidId(ParserTest.java:244) +]]></failure> + </testcase> + <testcase name="readWithInvalidFriends" classname="de.unibremen.swp.ParserTest$CSV" time="0"> + <failure message="Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException>" type="org.opentest4j.AssertionFailedError"><![CDATA[org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.readWithInvalidFriends(ParserTest.java:301) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$readWithInvalidFriends$6(ParserTest.java:302) + at de.unibremen.swp.ParserTest$CSV.readWithInvalidFriends(ParserTest.java:301) +]]></failure> + </testcase> +</testsuite> \ No newline at end of file diff --git "a/\303\274bung1/target/surefire-reports/de.unibremen.swp.ConverterTest.txt" "b/\303\274bung1/target/surefire-reports/de.unibremen.swp.ConverterTest.txt" new file mode 100644 index 0000000000000000000000000000000000000000..6a3bb70d10d59dd498054c2d02faeef94da1e63f --- /dev/null +++ "b/\303\274bung1/target/surefire-reports/de.unibremen.swp.ConverterTest.txt" @@ -0,0 +1,12 @@ +------------------------------------------------------------------------------- +Test set: de.unibremen.swp.ConverterTest +------------------------------------------------------------------------------- +Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.031 s <<< FAILURE! - in de.unibremen.swp.ConverterTest +CSVToJSON Time elapsed: 0.031 s <<< ERROR! +java.lang.UnsupportedOperationException + at de.unibremen.swp.ConverterTest.CSVToJSON(ConverterTest.java:26) + +JSONToCSV Time elapsed: 0 s <<< ERROR! +java.lang.UnsupportedOperationException + at de.unibremen.swp.ConverterTest.JSONToCSV(ConverterTest.java:132) + diff --git "a/\303\274bung1/target/surefire-reports/de.unibremen.swp.ParserTest.txt" "b/\303\274bung1/target/surefire-reports/de.unibremen.swp.ParserTest.txt" new file mode 100644 index 0000000000000000000000000000000000000000..47c0fd9858ce7dd2189f6d07c1fe6d071884a456 --- /dev/null +++ "b/\303\274bung1/target/surefire-reports/de.unibremen.swp.ParserTest.txt" @@ -0,0 +1,106 @@ +------------------------------------------------------------------------------- +Test set: de.unibremen.swp.ParserTest +------------------------------------------------------------------------------- +Tests run: 18, Failures: 10, Errors: 8, Skipped: 0, Time elapsed: 0 s <<< FAILURE! - in de.unibremen.swp.ParserTest +readFromExampleFile Time elapsed: 0 s <<< ERROR! +java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$JSON.readFromExampleFile(ParserTest.java:355) + +writeNullParameter Time elapsed: 0 s <<< FAILURE! +org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.NullPointerException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$JSON.writeNullParameter(ParserTest.java:555) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$JSON.lambda$writeNullParameter$2(ParserTest.java:556) + at de.unibremen.swp.ParserTest$JSON.writeNullParameter(ParserTest.java:555) + +writeSameTwice Time elapsed: 0 s <<< ERROR! +java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$JSON.writeSameTwice(ParserTest.java:539) + +writeNullInListAndCompareWithRead Time elapsed: 0 s <<< ERROR! +java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$JSON.writeNullInListAndCompareWithRead(ParserTest.java:567) + +readNullParameter Time elapsed: 0 s <<< FAILURE! +org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.NullPointerException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$JSON.readNullParameter(ParserTest.java:549) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$JSON.lambda$readNullParameter$1(ParserTest.java:550) + at de.unibremen.swp.ParserTest$JSON.readNullParameter(ParserTest.java:549) + +writeAndCompareWithRead Time elapsed: 0 s <<< ERROR! +java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$JSON.writeAndCompareWithRead(ParserTest.java:471) + +readDifferentWithSameId Time elapsed: 0 s <<< FAILURE! +org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.readDifferentWithSameId(ParserTest.java:268) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$readDifferentWithSameId$3(ParserTest.java:269) + at de.unibremen.swp.ParserTest$CSV.readDifferentWithSameId(ParserTest.java:268) + +writeWithInvalidId Time elapsed: 0 s <<< FAILURE! +org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.writeWithInvalidId(ParserTest.java:260) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$writeWithInvalidId$2(ParserTest.java:257) + at de.unibremen.swp.ParserTest$CSV.writeWithInvalidId(ParserTest.java:260) + +writeDifferentWithSameId Time elapsed: 0 s <<< FAILURE! +org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.writeDifferentWithSameId(ParserTest.java:282) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$writeDifferentWithSameId$4(ParserTest.java:283) + at de.unibremen.swp.ParserTest$CSV.writeDifferentWithSameId(ParserTest.java:282) + +readFromExampleFile Time elapsed: 0 s <<< ERROR! +java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.readFromExampleFile(ParserTest.java:31) + +writeNullParameter Time elapsed: 0 s <<< FAILURE! +org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.NullPointerException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.writeNullParameter(ParserTest.java:324) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$writeNullParameter$9(ParserTest.java:325) + at de.unibremen.swp.ParserTest$CSV.writeNullParameter(ParserTest.java:324) + +writeWithInvalidFriends Time elapsed: 0 s <<< FAILURE! +org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.writeWithInvalidFriends(ParserTest.java:312) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$writeWithInvalidFriends$7(ParserTest.java:313) + at de.unibremen.swp.ParserTest$CSV.writeWithInvalidFriends(ParserTest.java:312) + +writeSameTwice Time elapsed: 0 s <<< ERROR! +java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.writeSameTwice(ParserTest.java:291) + +writeNullInListAndCompareWithRead Time elapsed: 0 s <<< ERROR! +java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.writeNullInListAndCompareWithRead(ParserTest.java:337) + +readWithInvalidId Time elapsed: 0 s <<< FAILURE! +org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.readWithInvalidId(ParserTest.java:244) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$readWithInvalidId$0(ParserTest.java:245) + at de.unibremen.swp.ParserTest$CSV.readWithInvalidId(ParserTest.java:244) + +readWithInvalidFriends Time elapsed: 0 s <<< FAILURE! +org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.IllegalArgumentException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.readWithInvalidFriends(ParserTest.java:301) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$readWithInvalidFriends$6(ParserTest.java:302) + at de.unibremen.swp.ParserTest$CSV.readWithInvalidFriends(ParserTest.java:301) + +readNullParameter Time elapsed: 0 s <<< FAILURE! +org.opentest4j.AssertionFailedError: Unexpected exception type thrown ==> expected: <java.lang.NullPointerException> but was: <java.lang.UnsupportedOperationException> + at de.unibremen.swp.ParserTest$CSV.readNullParameter(ParserTest.java:318) +Caused by: java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.lambda$readNullParameter$8(ParserTest.java:319) + at de.unibremen.swp.ParserTest$CSV.readNullParameter(ParserTest.java:318) + +writeAndCompareWithRead Time elapsed: 0 s <<< ERROR! +java.lang.UnsupportedOperationException + at de.unibremen.swp.ParserTest$CSV.writeAndCompareWithRead(ParserTest.java:168) + diff --git "a/\303\274bung1/target/test-classes/de/unibremen/swp/ConverterTest.class" "b/\303\274bung1/target/test-classes/de/unibremen/swp/ConverterTest.class" new file mode 100644 index 0000000000000000000000000000000000000000..3d39ba842dc1ce5beef1a7f10905bad35bb61411 Binary files /dev/null and "b/\303\274bung1/target/test-classes/de/unibremen/swp/ConverterTest.class" differ diff --git "a/\303\274bung1/target/test-classes/de/unibremen/swp/ParserTest$CSV.class" "b/\303\274bung1/target/test-classes/de/unibremen/swp/ParserTest$CSV.class" new file mode 100644 index 0000000000000000000000000000000000000000..a77e3e3d4dbc6152d961e1ca3051e0aa492cee02 Binary files /dev/null and "b/\303\274bung1/target/test-classes/de/unibremen/swp/ParserTest$CSV.class" differ diff --git "a/\303\274bung1/target/test-classes/de/unibremen/swp/ParserTest$JSON.class" "b/\303\274bung1/target/test-classes/de/unibremen/swp/ParserTest$JSON.class" new file mode 100644 index 0000000000000000000000000000000000000000..d558c64725383c679773151793315cbb64eaf32c Binary files /dev/null and "b/\303\274bung1/target/test-classes/de/unibremen/swp/ParserTest$JSON.class" differ diff --git "a/\303\274bung1/target/test-classes/de/unibremen/swp/ParserTest.class" "b/\303\274bung1/target/test-classes/de/unibremen/swp/ParserTest.class" new file mode 100644 index 0000000000000000000000000000000000000000..0506e5f2daf41d8043c1523b1e4b0083d9af12fb Binary files /dev/null and "b/\303\274bung1/target/test-classes/de/unibremen/swp/ParserTest.class" differ diff --git "a/\303\274bung1/target/test-classes/users.csv" "b/\303\274bung1/target/test-classes/users.csv" new file mode 100644 index 0000000000000000000000000000000000000000..a54d1f127b36081a327a6b3fd53b731b2685963b --- /dev/null +++ "b/\303\274bung1/target/test-classes/users.csv" @@ -0,0 +1,9 @@ +ID‽First Name‽Last Name‽Motto‽Friends +1‽Michael‽Scott‽"Progress, not perfection."‽3, 4,5 +2‽Dwight‽Schrute‽"If you’re going through hell, keep going."‽ +3‽Pam‽Beesly‽"Your pain today will be your strength tomorrow."‽"1, +4" +4‽Jim‽Halpert‽"Act or accept."‽1,3 +5‽Ryan‽Howard‽"I am strong, +I am confident, +and I am unstoppable."‽5 diff --git "a/\303\274bung1/target/test-classes/users.json" "b/\303\274bung1/target/test-classes/users.json" new file mode 100644 index 0000000000000000000000000000000000000000..586088ea1471ea1268433032bea6d6481957c6f6 --- /dev/null +++ "b/\303\274bung1/target/test-classes/users.json" @@ -0,0 +1,47 @@ +[ { + "@id" : "1", + "firstName" : "Michael", + "lastName" : "Scott", + "motto" : "Progress, not perfection.", + "friends" : [ { + "@id" : "2", + "firstName" : "Pam", + "lastName" : "Beesly", + "motto" : "Your pain today will be your strength tomorrow.", + "friends" : [ { + "@ref" : "1" + }, { + "@id" : "3", + "firstName" : "Jim", + "lastName" : "Halpert", + "motto" : "Act or accept.", + "friends" : [ { + "@ref" : "1" + }, { + "@ref" : "2" + } ] + } ] + }, { + "@ref" : "3" + }, { + "@id" : "4", + "firstName" : "Ryan", + "lastName" : "Howard", + "motto" : "I am strong,\nI am confident,\nand I am unstoppable.", + "friends" : [ { + "@ref" : "4" + } ] + } ] +}, { + "@id" : "5", + "firstName" : "Dwight", + "lastName" : "Schrute", + "motto" : "If you’re going through hell, keep going.", + "friends" : [ ] +}, { + "@ref" : "2" +}, { + "@ref" : "3" +}, { + "@ref" : "4" +} ] diff --git "a/\303\274bung1/uebung1.iml" "b/\303\274bung1/uebung1.iml" new file mode 100644 index 0000000000000000000000000000000000000000..3a8eafeba0c37b5ed6bd27acfd61088374b09f31 --- /dev/null +++ "b/\303\274bung1/uebung1.iml" @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> + <output url="file://$MODULE_DIR$/target/classes" /> + <output-test url="file://$MODULE_DIR$/target/test-classes" /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> + <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> + <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" /> + <excludeFolder url="file://$MODULE_DIR$/target" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.6.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.6.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.6.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.6.1" level="project" /> + </component> +</module> \ No newline at end of file