Skip to content

Commit

Permalink
Update ClubServiceTest.java
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliipik committed Oct 9, 2023
1 parent 6b0a294 commit 146b1b3
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.softserve.teachua.service;

import static com.softserve.teachua.TestUtils.getUser;
import com.softserve.teachua.constants.Days;
import com.softserve.teachua.converter.ClubToClubResponseConverter;
import com.softserve.teachua.converter.ContactsStringConverter;
import com.softserve.teachua.converter.DtoConverter;
Expand All @@ -15,11 +16,13 @@
import com.softserve.teachua.model.Category;
import com.softserve.teachua.model.Club;
import com.softserve.teachua.model.User;
import com.softserve.teachua.model.WorkTime;
import com.softserve.teachua.model.archivable.ClubArch;
import com.softserve.teachua.repository.ClubRepository;
import com.softserve.teachua.repository.ComplaintRepository;
import com.softserve.teachua.repository.LocationRepository;
import com.softserve.teachua.repository.UserRepository;
import com.softserve.teachua.repository.WorkTimeRepository;
import com.softserve.teachua.service.impl.ClubServiceImpl;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -50,9 +53,11 @@ class ClubServiceTest {
private final String NEW_NAME = "New Club Name";
private final String CONTACTS = "123456789";
private final String DESCRIPTION = "Description Text";
private final WorkTime workTime =WorkTime.builder().day(Days.MONDAY).startTime("13:23").endTime("14:23").build();
private final List<String> CATEGORIES = Arrays.asList("Category1", "Category2");
private final Set<Category> CATEGORIES_SET = Sets.newSet(Category.builder().name("Category1").build(),
Category.builder().name("Category2").build());
private final List<WorkTime> WORK_TIMES_SET = Arrays.asList(workTime);
private final Long USER_EXISTING_ID = 1L;
private final Long USER_NOT_EXISTING_ID = 100L;
private final String USER_EXISTING_NAME = "User Existing Name";
Expand All @@ -68,6 +73,8 @@ class ClubServiceTest {
@Mock
private LocationRepository locationRepository;
@Mock
private WorkTimeRepository workTimeRepository;
@Mock
private FileUploadService fileUploadService;
@Mock
private CategoryService categoryService;
Expand Down Expand Up @@ -98,7 +105,7 @@ public void setUp() {
club = Club.builder().id(EXISTING_ID).name(NEW_NAME).user(user).categories(CATEGORIES_SET)
.feedbacks(Sets.newSet()).locations(Sets.newSet()).workTimes(Sets.newSet()).urlGallery(Lists.list()).build();
clubProfile = ClubProfile.builder().name(NEW_NAME).description(DESCRIPTION).contacts(CONTACTS)
.categoriesName(CATEGORIES).build();
.categoriesName(CATEGORIES).workTimes(WORK_TIMES_SET).build();
clubResponse = ClubResponse.builder().id(EXISTING_ID).name(NEW_NAME).build();
clubArch = ClubArch.builder().id(EXISTING_ID).name(NEW_NAME).build();
}
Expand Down Expand Up @@ -223,6 +230,7 @@ void addClubShouldReturnSuccessCreatedClub() {
when(dtoConverter.convertToDto(newClub, SuccessCreatedClub.class))
.thenReturn(SuccessCreatedClub.builder().name(NEW_NAME).build());
when(userService.getAuthenticatedUser()).thenReturn(user);
when(dtoConverter.convertToEntity(workTime, new WorkTime())).thenReturn(workTime);

SuccessCreatedClub actual = clubService.addClub(clubProfile);
assertEquals(clubProfile.getName(), actual.getName());
Expand Down

0 comments on commit 146b1b3

Please sign in to comment.