Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Admin cabinet] Fixed nameEN in Position #1163 #1166

Merged
merged 11 commits into from
Jul 4, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import greencity.dto.pageble.PageableAdvancedDto;
import greencity.dto.position.PositionAuthoritiesDto;
import greencity.dto.position.PositionDto;
import greencity.dto.position.PositionWithTranslateDto;
import greencity.dto.tariff.GetTariffInfoForEmployeeDto;
import greencity.filters.EmployeeFilterCriteria;
import greencity.filters.EmployeePage;
Expand Down Expand Up @@ -153,7 +152,7 @@ public ResponseEntity<HttpStatus> deleteEmployee(@PathVariable Long id) {
})
@PreAuthorize("@preAuthorizer.hasAuthority('SEE_EMPLOYEES_PAGE', authentication)")
@GetMapping("/get-all-positions")
public ResponseEntity<List<PositionWithTranslateDto>> getAllPositions() {
public ResponseEntity<List<PositionDto>> getAllPositions() {
return ResponseEntity.status(HttpStatus.OK).body(employeeService.getAllPositions());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import greencity.dto.employee.EmployeeWithTariffsIdDto;
import greencity.dto.position.AddingPositionDto;
import greencity.dto.position.PositionDto;
import greencity.dto.position.PositionWithTranslateDto;
import greencity.dto.tariff.GetTariffInfoForEmployeeDto;
import greencity.filters.EmployeeFilterCriteria;
import greencity.filters.EmployeePage;
Expand Down Expand Up @@ -74,7 +73,7 @@ public interface UBSManagementEmployeeService {
* @return {@link PositionDto}
* @author Mykola Danylko
*/
List<PositionWithTranslateDto> getAllPositions();
List<PositionDto> getAllPositions();

/**
* Method deletes position by id.
Expand Down
1 change: 1 addition & 0 deletions service-api/src/test/java/greencity/ModelUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public static PositionDto getEmployeePosition() {
return PositionDto.builder()
.id(1L)
.name("Менеджер послуги")
.name("Service Manager")
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ void signUpEmployee() {
assertThrows(RemoteServerUnavailableException.class, () -> client.signUpEmployee(dto));
}

@Test
void signUpEmployeeError() {
EmployeeSignUpDto dto = EmployeeSignUpDto.builder().build();
assertThrows(RemoteServerUnavailableException.class, () -> client.signUpEmployee(dto));
}

@Test
void updateEmployeeEmailTest() {
String newEmail = "[email protected]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import greencity.dto.employee.EmployeePositionsDto;
import greencity.dto.position.AddingPositionDto;
import greencity.dto.position.PositionDto;
import greencity.dto.position.PositionWithTranslateDto;
import greencity.dto.tariff.GetTariffInfoForEmployeeDto;
import greencity.entity.order.TariffsInfo;
import greencity.entity.user.employee.Employee;
Expand Down Expand Up @@ -104,7 +103,8 @@ private void signUpEmployee(Employee employee) {
try {
userRemoteClient.signUpEmployee(signUpDto);
} catch (HystrixRuntimeException e) {
throw new BadRequestException("User with this email already exists: " + signUpDto.getEmail());
throw new BadRequestException(
"Error to create user(): User with this email already exists or not valid data ");
}
}

Expand Down Expand Up @@ -329,9 +329,9 @@ private Position buildPosition(AddingPositionDto dto) {
* {@inheritDoc}
*/
@Override
public List<PositionWithTranslateDto> getAllPositions() {
public List<PositionDto> getAllPositions() {
return positionRepository.findAll().stream()
.map(p -> modelMapper.map(p, PositionWithTranslateDto.class))
.map(p -> modelMapper.map(p, PositionDto.class))
.collect(Collectors.toList());
}

Expand Down
1 change: 1 addition & 0 deletions service/src/test/java/greencity/ModelUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,7 @@ public static List<Employee> getEmployeeList() {
.employeePosition(Set.of(Position.builder()
.id(6L)
.name("Супер адмін")
.nameEn("Super admin")
.build()))
.tariffInfos(new HashSet<>())
.imagePath("path")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ void updatePositionTest() {
@Test
void getAllPositionTest() {
when(positionRepository.findAll()).thenReturn(List.of(getPosition()));
when(modelMapper.map(any(), any())).thenReturn(getPositionWithTranslateDto(1L));
when(modelMapper.map(any(), any())).thenReturn(getPositionDto(1L));

List<PositionWithTranslateDto> positionWithTranslateDtos = employeeService.getAllPositions();
List<PositionDto> positionWithTranslateDtos = employeeService.getAllPositions();
assertEquals(1, positionWithTranslateDtos.size());

verify(positionRepository, times(1)).findAll();
Expand Down