Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package lapr.project.model;
- import java.sql.Timestamp;
- import java.util.Date;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import org.junit.jupiter.api.Test;
- /**
- *
- * @author morei
- */
- public class JourneyTest {
- Journey instance = new Journey();
- Journey instance1 = new Journey("1161263@isep.ipp.pt", new Timestamp(10), 1);
- Journey instance2 = new Journey(1, "1161263@isep.ipp.pt", new Timestamp(10), 1, 0, new Date(10));
- Journey instance3 = new Journey("1161263@isep.ipp.pt", new Timestamp(10), 1, 0);
- Journey instance4 = new Journey("1161263@isep.ipp.pt", new Timestamp(10), 1, 0, new Date(10));
- /**
- * Test of getId method, of class Journey.
- */
- @Test
- public void testGetIdReservation() {
- System.out.println("getIdReservation");
- int expResult = 1;
- int result = instance2.getIdReservation();
- assertEquals(expResult, result);
- }
- /**
- * Test of getReservationDate method, of class Journey.
- */
- @Test
- public void testGetReservationDate() {
- System.out.println("getReservationDate");
- Timestamp expResult = new Timestamp(10);
- Timestamp result = instance2.getReservationDate();
- assertEquals(expResult, result);
- }
- /**
- * Test of getEmail method, of class Journey.
- */
- @Test
- public void testGetEmail() {
- System.out.println("getEmail");
- String expResult = "1161263@isep.ipp.pt";
- String result = instance2.getEmail();
- assertEquals(expResult, result);
- }
- /**
- * Test of getIdBicycle method, of class Journey.
- */
- @Test
- public void testGetIdBicycle() {
- System.out.println("getIdBicycle");
- int expResult = 1;
- int result = instance2.getIdBicycle();
- assertEquals(expResult, result);
- }
- /**
- * Test of getPrice method, of class Journey.
- */
- @Test
- public void testGetPrice() {
- System.out.println("getPrice");
- int expResult = 0;
- int result = instance2.getPrice();
- assertEquals(expResult, result);
- }
- /**
- * Test of getMonthYear method, of class Journey.
- */
- @Test
- public void testGetMonthYear() {
- System.out.println("getMonthYear");
- Date expResult = new Date(10);
- Date result = instance2.getMonthYear();
- assertEquals(expResult, result);
- }
- /**
- * Test of setReservationDate method, of class Journey.
- */
- @Test
- public void testSetReservationDate() {
- System.out.println("setReservationDate");
- Timestamp reservationDate = new Timestamp(15);
- instance2.setReservationDate(reservationDate);
- assertEquals(reservationDate, instance2.getReservationDate());
- }
- /**
- * Test of setEmail method, of class Journey.
- */
- @Test
- public void testSetEmail() {
- System.out.println("setEmail");
- String email = "1171409@isep.ipp.pt";
- instance2.setEmail(email);
- assertEquals(email, instance2.getEmail());
- }
- /**
- * Test of setIdBicycle method, of class Journey.
- */
- @Test
- public void testSetIdBicycle() {
- System.out.println("setIdBicycle");
- int idBicycle = 2;
- instance2.setIdBicycle(idBicycle);
- assertEquals(idBicycle, instance2.getIdBicycle());
- }
- /**
- * Test of setPrice method, of class Journey.
- */
- @Test
- public void testSetPrice() {
- System.out.println("setPrice");
- int price = 15;
- instance2.setPrice(price);
- assertEquals(price, instance2.getPrice());
- }
- /**
- * Test of setMonthYear method, of class Journey.
- */
- @Test
- public void testSetMonthYear() {
- System.out.println("setMonthYear");
- Date monthYear = new Date(15);
- instance2.setMonthYear(monthYear);
- assertEquals(monthYear, instance2.getMonthYear());
- }
- /**
- * Test of toString method, of class Journey.
- */
- @Test
- public void testToString() {
- System.out.println("toString");
- String expResult = "Reservation date 1970-01-01 01:00:00.01 Email 1161263@isep.ipp.pt Id bicycle 1 Price 0 Month Year Thu Jan 01 01:00:00 GMT 1970";
- String result = instance2.toString();
- assertEquals(expResult, result);
- }
- /**
- * Test of equals method, of class Journey.
- */
- @Test
- public void testEquals() {
- System.out.println("equals");
- Object obj = null;
- boolean expResult = false;
- boolean result = instance.equals(obj);
- assertEquals(expResult, result);
- }
- /**
- * Test of equals method, of class Journey.
- */
- @Test
- public void testEqualsDiferentClass() {
- System.out.println("equals");
- Object obj = new Park(new Location(), 0, 0);
- boolean expResult = false;
- boolean result = instance.equals(obj);
- assertEquals(expResult, result);
- }
- /**
- * Test of equals method, of class Journey.
- */
- @Test
- public void testEquals1() {
- System.out.println("equals");
- Object obj = instance2;
- boolean expResult = true;
- boolean result = instance2.equals(obj);
- assertEquals(expResult, result);
- }
- /**
- * Test of equals method, of class Journey.
- */
- @Test
- public void testEquals2() {
- System.out.println("equals");
- Object obj = new Journey(2, "1161263@isep.ipp.pt", new Timestamp(10), 1, 0, new Date(10));
- boolean expResult = false;
- boolean result = instance2.equals(obj);
- assertEquals(expResult, result);
- }
- /**
- * Test of equals method, of class Journey.
- */
- @Test
- public void testEquals3() {
- System.out.println("equals");
- Object obj = new Journey(1, "1171709@isep.ipp.pt", new Timestamp(15), 2, 2, new Date(15));
- boolean expResult = true;
- boolean result = instance2.equals(obj);
- assertEquals(expResult, result);
- }
- /**
- * Test of hashCode method, of class Journey.
- */
- @Test
- public void testHashCode() {
- System.out.println("hashCode");
- int expResult = hashCode(instance2);
- int result = instance2.hashCode();
- assertEquals(expResult, result);
- }
- public int hashCode(Journey j) {
- int hash = 5;
- hash = 37 * hash + j.getIdReservation();
- return hash;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement