@@ -0,0 +1,2062 @@
+package org.iti.hrmManager.persistence;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.io.IOException;%0Aimport java.nio.file.FileSystems;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.sql.Connection;%0Aimport java.sql.DriverManager;%0Aimport java.sql.SQLException;%0Aimport java.sql.Statement;%0A%0Aimport org.hibernate.Session;%0Aimport org.hibernate.Transaction;%0Aimport org.iti.hrmManager.test.util.HibernateUtil;%0Aimport org.junit.After;%0Aimport org.junit.AfterClass;%0Aimport org.junit.Before;%0Aimport org.junit.BeforeClass;%0Aimport org.junit.Test;%0A%0Apublic class CustomerTest %7B%0A%0A%09private static Session session;%0A%09private static Transaction trx;%0A%0A%09@BeforeClass%0A%09public static void setUpBeforeClass() throws Exception %7B%0A%09%09createTestDatabase();%0A%0A%09%09session = HibernateUtil.getSession();%0A%09%09trx = session.beginTransaction();%0A%09%7D%0A%0A%09private static void createTestDatabase() throws IOException, SQLException %7B%0A%09%09Path path = FileSystems.getDefault().getPath(%22sql%22, %2200_schema.sql%22);%0A%09%09String schema = new String(Files.readAllBytes(path));%0A%09%09Connection connection = DriverManager.getConnection(%22jdbc:sqlite:hrm_test.sqlite%22);%0A%09%09Statement stm = connection.createStatement();%0A%0A%09%09try %7B%0A%09%09%09stm.execute(schema);%0A%09%09%7D finally %7B%0A%09%09%09connection.close();%0A%09%09%7D%0A%09%7D%0A%0A%09@AfterClass%0A%09public static void tearDownAfterClass() throws Exception %7B%0A%09%09try %7B%0A%09%09%09trx.rollback();%0A%09%09%09session.close();%0A%09%09%7D finally %7B%0A%09%09%09Path database = FileSystems.getDefault().getPath(%22hrm_test.sqlite%22);%0A%09%09%09%0A%09%09%09if (database.toFile().exists()) %7B%0A%09%09%09%09database.toFile().delete();%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09@Before%0A%09public void setUp() throws Exception %7B%0A%09%09session.save(createCustomer());%0A%09%7D%0A%0A%09@After%0A%09public void tearDown() throws Exception %7B%0A%09%7D%0A%0A%09@Test%0A%09public void test() %7B%0A%09%09Customer customer = (Customer) session.get(Customer.class, 1);%0A%0A%09%09assertEquals(%22Max%22, customer.getFirstName());%0A%09%09assertEquals(%22Mustermann%22, customer.getSurname());%0A%09%7D%0A%0A%09private Customer createCustomer() %7B%0A%09%09Customer customer = new Customer();%0A%0A%09%09customer.setFirstName(%22Max%22);%0A%09%09customer.setSurname(%22Mustermann%22);%0A%0A%09%09return customer;%0A%09%7D%0A%7D%0A

Add rudimentary tests for class Customer