Skip to content

Commit ef02115

Browse files
committed
fix
1 parent 9a103fc commit ef02115

10 files changed

Lines changed: 18 additions & 113 deletions

File tree

backend/src/main/java/com/booking/backend/controller/BookingController.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

backend/src/main/java/com/booking/backend/controller/OrganizationController.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,4 @@ public List<OrganizationDto> getAllOrganization() {
3636
return organizationService.getAll();
3737
}
3838

39-
@PostMapping("/organization")
40-
public void addNewBooking(@RequestBody OrganizationDto organizationDto) {
41-
organizationService.updateOrganization(organizationDto);
42-
}
4339
}

backend/src/main/java/com/booking/backend/entity/Organization.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class Organization {
2323
private Double averageCheck;
2424

2525
private Double rating;
26+
2627
@Enumerated(EnumType.STRING)
2728
private TypeOrganization typeOrganization;
2829
}

backend/src/main/java/com/booking/backend/mapper/PersonMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public interface PersonMapper {
99

1010
Person convert(PersonDto personDto);
1111

12-
PersonDto convertFromPersonToPersonDto(Person person);
12+
PersonDto convert(Person person);
1313

1414
PersonDto convertFromPersonToPersonDtoInController(Optional<Person> person);
1515

backend/src/test/java/com/booking/backend/controller/BookingControllerTest.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

backend/src/test/java/com/booking/backend/controller/OrganizationControllerTest.java

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.booking.backend.dto.OrganizationDto;
44
import com.booking.backend.entity.Organization;
5+
import com.booking.backend.entity.TypeOrganization;
56
import com.booking.backend.mapper.OrganizationMapper;
67
import com.booking.backend.repository.OrganizationRepository;
78
import com.booking.backend.service.OrganizationService;
@@ -49,7 +50,7 @@ class OrganizationControllerTest {
4950
@BeforeEach
5051
void init() {
5152
organizationRepository.save(
52-
new Organization(null, "Al", "10-22", 1000.0, 8.9));
53+
new Organization(null, "Al", "10-22", 1000.0, 8.9, TypeOrganization.BAR));
5354
}
5455

5556
@AfterEach
@@ -67,8 +68,8 @@ void getAll() throws Exception {
6768

6869
@Test
6970
void getAllWithPage() throws Exception {
70-
Organization organization = new Organization(null, "Al", "10-22", 1000.0, 7.7);
71-
Organization organization1 = new Organization(null, "Al", "10-22", 1000.0, 8.0);
71+
Organization organization = new Organization(null, "Al", "10-22", 1000.0, 7.7, TypeOrganization.BAR);
72+
Organization organization1 = new Organization(null, "Al", "10-22", 1000.0, 8.0, TypeOrganization.BAR);
7273
List<Organization> list = List.of(organization, organization1);
7374
organizationRepository.saveAll(list);
7475

@@ -77,14 +78,14 @@ void getAllWithPage() throws Exception {
7778
.param("sortBy", "rate"))
7879
.andDo(print())
7980
.andExpect(status().isOk())
80-
.andExpect(jsonPath("$", hasSize(2)))
81-
.andExpect(jsonPath("$[0].rating", is(7.7)));
81+
.andExpect(jsonPath("$", hasSize(3)))
82+
.andExpect(jsonPath("$[1].rating", is(7.7)));
8283
}
8384

8485
@Test
8586
void getAllOrganization() throws Exception {
86-
Organization organization = new Organization(null, "Al", "10-22", 1000.0, 7.7);
87-
Organization organization1 = new Organization(null, "Al", "10-22", 1000.0, 8.0);
87+
Organization organization = new Organization(null, "Al", "10-22", 1000.0, 7.7, TypeOrganization.BAR);
88+
Organization organization1 = new Organization(null, "Al", "10-22", 1000.0, 8.0, TypeOrganization.BAR);
8889
List<Organization> list = List.of(organization, organization1);
8990
organizationRepository.saveAll(list);
9091

@@ -93,14 +94,4 @@ void getAllOrganization() throws Exception {
9394
.andExpect(status().isOk())
9495
.andExpect(jsonPath("$", hasSize(3)));
9596
}
96-
97-
@Test
98-
void addNewBooking() throws Exception {
99-
OrganizationDto organization = new OrganizationDto(null, "Al", "10-22", 1000.0, 8.7);
100-
101-
mockMvc.perform(post("/organization").contentType(MediaType.APPLICATION_JSON)
102-
.content(objectMapper.writeValueAsString(organization)))
103-
.andDo(print())
104-
.andExpect(status().isOk());
105-
}
10697
}

backend/src/test/java/com/booking/backend/mapper/OrganizationMapperImplTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
import com.booking.backend.dto.OrganizationDto;
44
import com.booking.backend.entity.Organization;
5+
import com.booking.backend.entity.TypeOrganization;
56
import org.junit.jupiter.api.Test;
67

78
import static org.junit.jupiter.api.Assertions.*;
89

910
class OrganizationMapperImplTest {
1011

1112
private OrganizationMapperImpl organizationMapper = new OrganizationMapperImpl();
12-
private Organization organizationEx = new Organization(1L, "Org", "10-22", 100.4, 8.7);
13-
private OrganizationDto organizationDtoEx = new OrganizationDto(1L, "Org", "10-22", 100.4, 8.7);
13+
private Organization organizationEx = new Organization(1L, "Org", "10-22", 100.4, 8.7, TypeOrganization.BAR);
14+
private OrganizationDto organizationDtoEx = new OrganizationDto(1L, "Org", "10-22", 100.4, 8.7, "Bar");
1415

1516

1617
@Test

backend/src/test/java/com/booking/backend/mapper/PersonMapperImplTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ void convertFromPersonDtoToPersonInController() {
2323
assertEquals(personDtoEx, personMapper.convertFromPersonToPersonDtoInController(java.util.Optional.ofNullable(personEx)));
2424
}
2525

26-
@Test
27-
void convertFromPersonToPersonDtoInController() {
28-
assertEquals(personEx, personMapper.convertFromPersonDtoToPersonInController(java.util.Optional.ofNullable(personDtoEx)));
29-
30-
}
31-
3226
@Test
3327
void convertFromPersonToPersonDto() {
3428
assertEquals(personDtoEx, personMapper.convert(personEx));

backend/src/test/java/com/booking/backend/repository/OrganizationRepositoryTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.booking.backend.repository;
22

33
import com.booking.backend.entity.Organization;
4+
import com.booking.backend.entity.TypeOrganization;
45
import org.junit.jupiter.api.BeforeEach;
56
import org.junit.jupiter.api.Test;
67
import org.springframework.beans.factory.annotation.Autowired;
@@ -18,8 +19,8 @@ class OrganizationRepositoryTest {
1819

1920
@BeforeEach
2021
void init() {
21-
organizationRepository.save(new Organization(null, "Org", "1-2", 2000.4, 8.7));
22-
organizationRepository.save(new Organization(null, "Org", "1-2", 2000.4, 8.7));
22+
organizationRepository.save(new Organization(null, "Org", "1-2", 2000.4, 8.7, TypeOrganization.BAR));
23+
organizationRepository.save(new Organization(null, "Org", "1-2", 2000.4, 8.7, TypeOrganization.BAR));
2324

2425
}
2526

backend/src/test/java/com/booking/backend/service/OrganizationServiceImplTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ void getAll() {
5555

5656
@Test
5757
void updateOrganization() {
58-
OrganizationDto organizationDto = new OrganizationDto(1L, "Org", "10-22", 234.0, 8.7);
58+
OrganizationDto organizationDto
59+
= new OrganizationDto(1L, "Org", "10-22", 234.0, 8.7, "Bar");
5960
organizationService.updateOrganization(organizationDto);
6061
organizationMapper.convertFromOrganizationDtoToOrganization(organizationDto);
6162
organizationRepository.save(any());

0 commit comments

Comments
 (0)