Skip to content

Commit

Permalink
[FIX] 요소 전체 확인 코드로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekks committed Feb 27, 2024
1 parent b7377c5 commit e12fa41
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package synk.meeteam.domain.common.university;

import static org.hamcrest.Matchers.notNullValue;
import static org.mockito.Mockito.doReturn;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import com.nimbusds.jose.shaded.gson.Gson;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -16,6 +17,7 @@
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import synk.meeteam.domain.common.university.api.UniversityController;
import synk.meeteam.domain.common.university.entity.University;
import synk.meeteam.domain.common.university.service.UniversityService;

@ExtendWith(MockitoExtension.class)
Expand All @@ -42,14 +44,15 @@ public void init() {
// given
final String url = "/university";
doReturn(UniversityFixture.createUniversities()).when(universityService).getUniversities();
List<University> universities = UniversityFixture.createUniversities();

// when
final ResultActions resultActions = mockMvc.perform(
MockMvcRequestBuilders.get(url));

// then
resultActions.andExpect(status().isOk())
.andExpect(jsonPath("$[0]").exists());

for (int cnt = 0; cnt < universities.size(); cnt++) {
resultActions.andExpect(jsonPath("$[" + cnt + "].universityName", notNullValue()));
}
}
}

0 comments on commit e12fa41

Please sign in to comment.