Skip to content

Commit

Permalink
chore: uploading work to prevent loss of progress
Browse files Browse the repository at this point in the history
  • Loading branch information
VicenteVigueras committed Apr 10, 2024
1 parent 25c28bd commit 56f4307
Showing 1 changed file with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import java.util.Set;

import static org.assertj.core.api.Assertions.assertThat;

import com.codedifferently.lesson16.Lesson16;
import com.codedifferently.lesson16.library.Library;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -16,6 +21,22 @@
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

import com.codedifferently.lesson16.library.LibraryGuest;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

import com.codedifferently.lesson16.library.Library;
import com.codedifferently.lesson16.library.LibraryGuest;
import java.util.Collections;
import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

@SpringBootTest
@ContextConfiguration(classes = Lesson16.class)
class PatronsControllerTest {
Expand Down Expand Up @@ -44,4 +65,30 @@ void testController_getsPatron() throws Exception {
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
}
}


// @Test
// void testController_addsItem() throws Exception {
// String json =
// """
// {
// "patron": {
// "type": "patron",
// "name": "someone",
// "email": "vicente@example.com"
// }
// }
// """;

// mockMvc
// .perform(post("/patrons").contentType(MediaType.APPLICATION_JSON).content(json))
// .andExpect(status().isOk())
// .andExpect(jsonPath("$.patron.email").value("vicente@example.com"));

// Set<LibraryGuest> patrons =
// library.getPatrons();
// assertThat(patrons).hasSize(1);
// var patron = patrons.iterator().next();
// assertThat(patron.getEmail()).isEqualTo("vicente@example.com");
// }
// }

0 comments on commit 56f4307

Please sign in to comment.