@@ -0,0 +1,3080 @@
+package bg.car_wash.areas.activity.serviceImpl;%0A%0Aimport bg.car_wash.areas.activity.entity.Activity;%0Aimport bg.car_wash.areas.activity.exceptions.ActivityNotFoundException;%0Aimport bg.car_wash.areas.activity.models.viewModel.ActivityViewModel;%0Aimport bg.car_wash.areas.activity.repository.ActivityRepository;%0Aimport bg.car_wash.areas.activity.service.ActivityService;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Mockito;%0Aimport org.modelmapper.ModelMapper;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.test.context.SpringBootTest;%0Aimport org.springframework.boot.test.mock.mockito.MockBean;%0Aimport org.springframework.test.context.ActiveProfiles;%0Aimport org.springframework.test.context.junit4.SpringRunner;%0A%0Aimport java.math.BigDecimal;%0A%0Aimport static org.junit.Assert.*;%0A%0A@RunWith(SpringRunner.class)%0A@SpringBootTest%0A@ActiveProfiles(%22test%22)%0Apublic class ActivityServiceTest %7B%0A%0A%09public static final Long VALID_ACTIVITY_ID = 1L;%0A%09public static final Long INVALID_ACTIVITY_ID = -1L;%0A%09public static final String ACTIVITY_NAME = %22Activity 1%22;%0A%09public static final BigDecimal ACTIVITY_PRICE = new BigDecimal(%2215%22);%0A%0A%09@MockBean%0A%09private ActivityRepository activityRepository;%0A%0A%09@Autowired%0A%09private ActivityService activityService;%0A%0A%09@Before%0A%09public void setUp() throws Exception %7B%0A%09%09Activity activity = new Activity();%0A%09%09activity.setId(VALID_ACTIVITY_ID);%0A%09%09activity.setActivityName(ACTIVITY_NAME);%0A%09%09activity.setActivityPrice(ACTIVITY_PRICE);%0A%0A%09%09Mockito.when(activityRepository.findActivityById(1L)).thenReturn(activity);%0A%09%7D%0A%0A%09@Test%0A%09public void findActivityByIdGivenValidActivity_ShouldReturnValidActivityId() throws Exception %7B%0A%09%09//Act%0A%09%09ActivityViewModel activityViewModel = this.activityService.findActivityById(VALID_ACTIVITY_ID);%0A%0A%09%09//Assert%0A%09%09assertEquals(VALID_ACTIVITY_ID, activityViewModel.getId());%0A%09%7D%0A%0A%09@Test%0A%09public void findActivityByIdGivenValidActivity_ShouldReturnValidActivityName() throws Exception %7B%0A%09%09//Act%0A%09%09ActivityViewModel activityViewModel = this.activityService.findActivityById(VALID_ACTIVITY_ID);%0A%0A%09%09//Assert%0A%09%09assertEquals(ACTIVITY_NAME, activityViewModel.getActivityName());%0A%09%7D%0A%0A%09@Test%0A%09public void findActivityByIdGivenValidActivity_ShouldReturnValidActivityPrice() throws Exception %7B%0A%09%09//Act%0A%09%09ActivityViewModel activityViewModel = this.activityService.findActivityById(VALID_ACTIVITY_ID);%0A%0A%09%09//Assert%0A%09%09assertEquals(ACTIVITY_PRICE, activityViewModel.getActivityPrice());%0A%09%7D%0A%0A%09@Test%0A%09public void findActivityByIdGivenValidActivity_ShouldOneCallFindActivityById() throws Exception %7B%0A%09%09//Act%0A%09%09ActivityViewModel activityViewModel = this.activityService.findActivityById(VALID_ACTIVITY_ID);%0A%0A%09%09//Assert%0A%09%09Mockito.verify(this.activityRepository, Mockito.times(1)).findActivityById(VALID_ACTIVITY_ID);%0A%09%7D%0A%0A%09@Test(expected = ActivityNotFoundException.class)%0A%09public void findCarByIdGivenInvalidCar_ShouldThrowException() throws Exception %7B%0A%09%09//Act%0A%09%09ActivityViewModel activityViewModel = this.activityService.findActivityById(INVALID_ACTIVITY_ID);%0A%09%7D%0A%0A%7D

create ActivityServiceTest