package nl.yacht.lakesideresort.domain;

import nl.yacht.lakesideresort.BoatRental;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import java.time.Duration;
import java.time.LocalDateTime;

public class BoatRentalTest {

    private Trip trip1;
    private Trip trip2;
    private Trip trip3;

    @Before
    public void setUp() {
        this.trip1 = new Trip(3);
        this.trip2 = new Trip(4);
        this.trip3 = new Trip(5);
    }

    @Test
    public void testCalculateAverageDuration() {
        BoatRental boatRental = new BoatRental();
        boatRental.addTrip(trip1);
        boatRental.addTrip(trip2);
        boatRental.addTrip(trip3);

        try {
            LocalDateTime now = LocalDateTime.now();
            this.trip1.end();
            this.trip2.end();
            this.trip3.end();
            this.trip1.setEndTime(now.plusMinutes(55));
            this.trip2.setEndTime(now.plusMinutes(40));
            this.trip3.setEndTime(now.plusMinutes(34));

            double average = boatRental.calculateAverageDuration();

            Assert.assertTrue(average == 43);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

@@ -155,35 +155,8 @@
 t;%0A%0A
-import java.time.Duration;%0A
 impo
@@ -654,26 +654,8 @@
 );%0A%0A
-        try %7B%0A    
     
@@ -699,36 +699,32 @@
 .now();%0A        
-    
 this.trip1.end()
@@ -725,36 +725,32 @@
 .end();%0A        
-  
-  
 this.trip2.end()
@@ -743,36 +743,32 @@
 is.trip2.end();%0A
-    
         this.tri
@@ -777,36 +777,32 @@
 .end();%0A        
-  
-  
 this.trip1.setEn
@@ -825,28 +825,24 @@
 nutes(55));%0A
-    
         this
@@ -885,28 +885,24 @@
 ));%0A        
-  
-  
 this.trip3.s
@@ -930,28 +930,24 @@
 utes(34));%0A%0A
-    
         doub
@@ -1007,20 +1007,16 @@
         
-  
-  
 Assert.a
@@ -1045,85 +1045,8 @@
 3);%0A
-%0A        %7D catch (Exception e) %7B%0A            e.printStackTrace();%0A        %7D%0A%0A
     

Clean up