Skip to content

Commit

Permalink
style fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lysalexy committed Mar 17, 2024
1 parent 6d17307 commit e74104f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
14 changes: 7 additions & 7 deletions src/test/java/org/example/controller/TestObjects.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.example.controller;

import java.sql.Date;
import java.util.Arrays;
import java.util.List;
import org.example.dto.cart.CartDto;
import org.example.dto.cart.CartToItemDto;
import org.example.dto.item.ItemDto;
Expand All @@ -10,10 +13,6 @@
import org.example.dto.user.SpecialityDto;
import org.example.dto.user.UserAccountDto;

import java.sql.Date;
import java.util.Arrays;
import java.util.List;

public class TestObjects {
public static TypeDto commonType;
public static TypeDto receiptType;
Expand Down Expand Up @@ -132,9 +131,10 @@ public class TestObjects {
simpleUser =
new UserAccountDto(-1L, "Иванов Иван Иванович", "+79260567450", simpleUserRole, null);
doctor =
new UserAccountDto(-2L, "Глазов Степан Фёдорович", "+79310367450", doctorRole, speciality);
pharmacist = new UserAccountDto(-3L, "Главный Пётр Петрович", "+79510367450", pharmacistRole, null);
itemsFirstOrder = new ItemDto[]{receipt};
new UserAccountDto(-2L, "Глазов Степан Фёдорович", "+79310367450", doctorRole, speciality);
pharmacist =
new UserAccountDto(-3L, "Главный Пётр Петрович", "+79510367450", pharmacistRole, null);
itemsFirstOrder = new ItemDto[] {receipt};
itemsSecondOrder = new ItemDto[] {special};
itemsThirdOrder = new ItemDto[] {receipt, special};
itemsFirstOrderSecUser = new ItemDto[] {special};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,47 +87,47 @@ void getAllItemsBySpecId() {
assertArrayEquals(new ItemDto[] {special}, resultDto);
}

//аутентификация пользователя фармацевта и просмотр всех препаратов
// аутентификация пользователя фармацевта и просмотр всех препаратов
@Test
@SneakyThrows
void getAllItemsByDoc() {
ResultActions result =
mockMvc
.perform(
post("/api/accounts/login")
.param("phone", doctor.phone())
.param("password", "654321"))
.andExpect(status().isOk());
mockMvc
.perform(
post("/api/accounts/login")
.param("phone", doctor.phone())
.param("password", "654321"))
.andExpect(status().isOk());
UserAccountDto resultDto = mvcUtil.readResponseValue(UserAccountDto.class, result);
assertEquals(doctor, resultDto);

ResultActions resultItem =
mockMvc
.perform(get("/api/item/doc/all?user_id="+resultDto.id()))
.andExpect(status().isOk())
.andExpect(jsonPath("$", hasSize(2)));
mockMvc
.perform(get("/api/item/doc/all?user_id=" + resultDto.id()))
.andExpect(status().isOk())
.andExpect(jsonPath("$", hasSize(2)));
ItemDto[] resultItemDto = mvcUtil.readResponseValue(ItemDto[].class, resultItem);
assertArrayEquals(new ItemDto[] {special, receipt}, resultItemDto);
}

//аутентификация пользователя фармацевта и просмотр всех препаратов
// аутентификация пользователя фармацевта и просмотр всех препаратов
@Test
@SneakyThrows
void getAllItemsBySpec() {
ResultActions result =
mockMvc
.perform(
post("/api/accounts/login")
.param("phone", doctor.phone())
.param("password", "654321"))
.andExpect(status().isOk());
mockMvc
.perform(
post("/api/accounts/login")
.param("phone", doctor.phone())
.param("password", "654321"))
.andExpect(status().isOk());
UserAccountDto resultDto = mvcUtil.readResponseValue(UserAccountDto.class, result);
assertEquals(doctor, resultDto);
ResultActions resultItem =
mockMvc
.perform(get("/api/item/type/category?speciality_id="+resultDto.speciality().id()))
.andExpect(status().isOk())
.andExpect(jsonPath("$", hasSize(1)));
mockMvc
.perform(get("/api/item/type/category?speciality_id=" + resultDto.speciality().id()))
.andExpect(status().isOk())
.andExpect(jsonPath("$", hasSize(1)));
ItemDto[] resultItemDto = mvcUtil.readResponseValue(ItemDto[].class, resultItem);
assertArrayEquals(new ItemDto[] {special}, resultItemDto);
}
Expand Down

0 comments on commit e74104f

Please sign in to comment.