/** * Test class for the BookResource REST controller. * * @see BookResource */ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) @WebAppConfiguration @IntegrationTest public class BookResourceIntTest { private static final String DEFAULT_TITLE = "AAAAA"; private static final String UPDATED_TITLE = "BBBBB"; private static final String DEFAULT_DESCRIPTION = "AAAAA"; private static final String UPDATED_DESCRIPTION = "BBBBB"; private static final String DEFAULT_PUBLISHER = "AAAAA"; private static final String UPDATED_PUBLISHER = "BBBBB"; private static final LocalDate DEFAULT_PUBLICATION_DATE = LocalDate.ofEpochDay(0L); private static final LocalDate UPDATED_PUBLICATION_DATE = LocalDate.now(ZoneId.systemDefault()); private static final BigDecimal DEFAULT_PRICE = new BigDecimal(1); private static final BigDecimal UPDATED_PRICE = new BigDecimal(2); @Inject private BookRepository bookRepository; @Inject private MappingJackson2HttpMessageConverter jacksonMessageConverter; @Inject private PageableHandlerMethodArgumentResolver pageableArgumentResolver; private MockMvc restBookMockMvc; private Book book; @PostConstruct public void setup() { MockitoAnnotations.initMocks(this); BookResource bookResource = new BookResource(); ReflectionTestUtils.setField(bookResource, "bookRepository", bookRepository); this.restBookMockMvc = MockMvcBuilders.standaloneSetup(bookResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setMessageConverters(jacksonMessageConverter) .build(); } @Before public void initTest() { bookRepository.deleteAll(); book = new Book(); book.setTitle(DEFAULT_TITLE); book.setDescription(DEFAULT_DESCRIPTION); book.setPublisher(DEFAULT_PUBLISHER); book.setPublicationDate(DEFAULT_PUBLICATION_DATE); book.setPrice(DEFAULT_PRICE); } @Test public void createBook() throws Exception { int databaseSizeBeforeCreate = bookRepository.findAll().size(); // Create the Book restBookMockMvc .perform( post("/api/books") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(book))) .andExpect(status().isCreated()); // Validate the Book in the database List<Book> books = bookRepository.findAll(); assertThat(books).hasSize(databaseSizeBeforeCreate + 1); Book testBook = books.get(books.size() - 1); assertThat(testBook.getTitle()).isEqualTo(DEFAULT_TITLE); assertThat(testBook.getDescription()).isEqualTo(DEFAULT_DESCRIPTION); assertThat(testBook.getPublisher()).isEqualTo(DEFAULT_PUBLISHER); assertThat(testBook.getPublicationDate()).isEqualTo(DEFAULT_PUBLICATION_DATE); assertThat(testBook.getPrice()).isEqualTo(DEFAULT_PRICE); } @Test public void checkTitleIsRequired() throws Exception { int databaseSizeBeforeTest = bookRepository.findAll().size(); // set the field null book.setTitle(null); // Create the Book, which fails. restBookMockMvc .perform( post("/api/books") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(book))) .andExpect(status().isBadRequest()); List<Book> books = bookRepository.findAll(); assertThat(books).hasSize(databaseSizeBeforeTest); } @Test public void getAllBooks() throws Exception { // Initialize the database bookRepository.save(book); // Get all the books restBookMockMvc .perform(get("/api/books?sort=id,desc")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.[*].id").value(hasItem(book.getId()))) .andExpect(jsonPath("$.[*].title").value(hasItem(DEFAULT_TITLE.toString()))) .andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))) .andExpect(jsonPath("$.[*].publisher").value(hasItem(DEFAULT_PUBLISHER.toString()))) .andExpect( jsonPath("$.[*].publicationDate").value(hasItem(DEFAULT_PUBLICATION_DATE.toString()))) .andExpect(jsonPath("$.[*].price").value(hasItem(DEFAULT_PRICE.intValue()))); } @Test public void getBook() throws Exception { // Initialize the database bookRepository.save(book); // Get the book restBookMockMvc .perform(get("/api/books/{id}", book.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id").value(book.getId())) .andExpect(jsonPath("$.title").value(DEFAULT_TITLE.toString())) .andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString())) .andExpect(jsonPath("$.publisher").value(DEFAULT_PUBLISHER.toString())) .andExpect(jsonPath("$.publicationDate").value(DEFAULT_PUBLICATION_DATE.toString())) .andExpect(jsonPath("$.price").value(DEFAULT_PRICE.intValue())); } @Test public void getNonExistingBook() throws Exception { // Get the book restBookMockMvc .perform(get("/api/books/{id}", Long.MAX_VALUE)) .andExpect(status().isNotFound()); } @Test public void updateBook() throws Exception { // Initialize the database bookRepository.save(book); int databaseSizeBeforeUpdate = bookRepository.findAll().size(); // Update the book book.setTitle(UPDATED_TITLE); book.setDescription(UPDATED_DESCRIPTION); book.setPublisher(UPDATED_PUBLISHER); book.setPublicationDate(UPDATED_PUBLICATION_DATE); book.setPrice(UPDATED_PRICE); restBookMockMvc .perform( put("/api/books") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(book))) .andExpect(status().isOk()); // Validate the Book in the database List<Book> books = bookRepository.findAll(); assertThat(books).hasSize(databaseSizeBeforeUpdate); Book testBook = books.get(books.size() - 1); assertThat(testBook.getTitle()).isEqualTo(UPDATED_TITLE); assertThat(testBook.getDescription()).isEqualTo(UPDATED_DESCRIPTION); assertThat(testBook.getPublisher()).isEqualTo(UPDATED_PUBLISHER); assertThat(testBook.getPublicationDate()).isEqualTo(UPDATED_PUBLICATION_DATE); assertThat(testBook.getPrice()).isEqualTo(UPDATED_PRICE); } @Test public void deleteBook() throws Exception { // Initialize the database bookRepository.save(book); int databaseSizeBeforeDelete = bookRepository.findAll().size(); // Get the book restBookMockMvc .perform(delete("/api/books/{id}", book.getId()).accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<Book> books = bookRepository.findAll(); assertThat(books).hasSize(databaseSizeBeforeDelete - 1); } }
/** * Test class for the Os_typeResource REST controller. * * @see Os_typeResource */ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) @WebAppConfiguration @IntegrationTest public class Os_typeResourceTest { private static final String DEFAULT_OS_TYPE_NAME = "AAAAA"; private static final String UPDATED_OS_TYPE_NAME = "BBBBB"; private static final String DEFAULT_DESCRIPTION = "AAAAA"; private static final String UPDATED_DESCRIPTION = "BBBBB"; private static final Integer DEFAULT_STATUS_ID = 1; private static final Integer UPDATED_STATUS_ID = 2; private static final String DEFAULT_CREATED_BY = "AAAAA"; private static final String UPDATED_CREATED_BY = "BBBBB"; private static final LocalDate DEFAULT_CREATED_DATE = LocalDate.ofEpochDay(0L); private static final LocalDate UPDATED_CREATED_DATE = LocalDate.now(ZoneId.systemDefault()); private static final String DEFAULT_MODIFIED_BY = "AAAAA"; private static final String UPDATED_MODIFIED_BY = "BBBBB"; private static final LocalDate DEFAULT_MODIFIED_DATE = LocalDate.ofEpochDay(0L); private static final LocalDate UPDATED_MODIFIED_DATE = LocalDate.now(ZoneId.systemDefault()); @Inject private Os_typeRepository os_typeRepository; @Inject private Os_typeSearchRepository os_typeSearchRepository; @Inject private MappingJackson2HttpMessageConverter jacksonMessageConverter; @Inject private PageableHandlerMethodArgumentResolver pageableArgumentResolver; private MockMvc restOs_typeMockMvc; private Os_type os_type; @PostConstruct public void setup() { MockitoAnnotations.initMocks(this); Os_typeResource os_typeResource = new Os_typeResource(); ReflectionTestUtils.setField(os_typeResource, "os_typeRepository", os_typeRepository); ReflectionTestUtils.setField( os_typeResource, "os_typeSearchRepository", os_typeSearchRepository); this.restOs_typeMockMvc = MockMvcBuilders.standaloneSetup(os_typeResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setMessageConverters(jacksonMessageConverter) .build(); } @Before public void initTest() { os_type = new Os_type(); os_type.setOs_type_name(DEFAULT_OS_TYPE_NAME); os_type.setDescription(DEFAULT_DESCRIPTION); os_type.setStatus_id(DEFAULT_STATUS_ID); os_type.setCreated_by(DEFAULT_CREATED_BY); os_type.setCreated_date(DEFAULT_CREATED_DATE); os_type.setModified_by(DEFAULT_MODIFIED_BY); os_type.setModified_date(DEFAULT_MODIFIED_DATE); } @Test @Transactional public void createOs_type() throws Exception { int databaseSizeBeforeCreate = os_typeRepository.findAll().size(); // Create the Os_type restOs_typeMockMvc .perform( post("/api/os_types") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(os_type))) .andExpect(status().isCreated()); // Validate the Os_type in the database List<Os_type> os_types = os_typeRepository.findAll(); assertThat(os_types).hasSize(databaseSizeBeforeCreate + 1); Os_type testOs_type = os_types.get(os_types.size() - 1); assertThat(testOs_type.getOs_type_name()).isEqualTo(DEFAULT_OS_TYPE_NAME); assertThat(testOs_type.getDescription()).isEqualTo(DEFAULT_DESCRIPTION); assertThat(testOs_type.getStatus_id()).isEqualTo(DEFAULT_STATUS_ID); assertThat(testOs_type.getCreated_by()).isEqualTo(DEFAULT_CREATED_BY); assertThat(testOs_type.getCreated_date()).isEqualTo(DEFAULT_CREATED_DATE); assertThat(testOs_type.getModified_by()).isEqualTo(DEFAULT_MODIFIED_BY); assertThat(testOs_type.getModified_date()).isEqualTo(DEFAULT_MODIFIED_DATE); } @Test @Transactional public void checkOs_type_nameIsRequired() throws Exception { int databaseSizeBeforeTest = os_typeRepository.findAll().size(); // set the field null os_type.setOs_type_name(null); // Create the Os_type, which fails. restOs_typeMockMvc .perform( post("/api/os_types") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(os_type))) .andExpect(status().isBadRequest()); List<Os_type> os_types = os_typeRepository.findAll(); assertThat(os_types).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void checkDescriptionIsRequired() throws Exception { int databaseSizeBeforeTest = os_typeRepository.findAll().size(); // set the field null os_type.setDescription(null); // Create the Os_type, which fails. restOs_typeMockMvc .perform( post("/api/os_types") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(os_type))) .andExpect(status().isBadRequest()); List<Os_type> os_types = os_typeRepository.findAll(); assertThat(os_types).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void checkStatus_idIsRequired() throws Exception { int databaseSizeBeforeTest = os_typeRepository.findAll().size(); // set the field null os_type.setStatus_id(null); // Create the Os_type, which fails. restOs_typeMockMvc .perform( post("/api/os_types") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(os_type))) .andExpect(status().isBadRequest()); List<Os_type> os_types = os_typeRepository.findAll(); assertThat(os_types).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void checkCreated_byIsRequired() throws Exception { int databaseSizeBeforeTest = os_typeRepository.findAll().size(); // set the field null os_type.setCreated_by(null); // Create the Os_type, which fails. restOs_typeMockMvc .perform( post("/api/os_types") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(os_type))) .andExpect(status().isBadRequest()); List<Os_type> os_types = os_typeRepository.findAll(); assertThat(os_types).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void checkCreated_dateIsRequired() throws Exception { int databaseSizeBeforeTest = os_typeRepository.findAll().size(); // set the field null os_type.setCreated_date(null); // Create the Os_type, which fails. restOs_typeMockMvc .perform( post("/api/os_types") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(os_type))) .andExpect(status().isBadRequest()); List<Os_type> os_types = os_typeRepository.findAll(); assertThat(os_types).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void checkModified_byIsRequired() throws Exception { int databaseSizeBeforeTest = os_typeRepository.findAll().size(); // set the field null os_type.setModified_by(null); // Create the Os_type, which fails. restOs_typeMockMvc .perform( post("/api/os_types") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(os_type))) .andExpect(status().isBadRequest()); List<Os_type> os_types = os_typeRepository.findAll(); assertThat(os_types).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void checkModified_dateIsRequired() throws Exception { int databaseSizeBeforeTest = os_typeRepository.findAll().size(); // set the field null os_type.setModified_date(null); // Create the Os_type, which fails. restOs_typeMockMvc .perform( post("/api/os_types") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(os_type))) .andExpect(status().isBadRequest()); List<Os_type> os_types = os_typeRepository.findAll(); assertThat(os_types).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void getAllOs_types() throws Exception { // Initialize the database os_typeRepository.saveAndFlush(os_type); // Get all the os_types restOs_typeMockMvc .perform(get("/api/os_types")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.[*].id").value(hasItem(os_type.getId().intValue()))) .andExpect(jsonPath("$.[*].os_type_name").value(hasItem(DEFAULT_OS_TYPE_NAME.toString()))) .andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))) .andExpect(jsonPath("$.[*].status_id").value(hasItem(DEFAULT_STATUS_ID))) .andExpect(jsonPath("$.[*].created_by").value(hasItem(DEFAULT_CREATED_BY.toString()))) .andExpect(jsonPath("$.[*].created_date").value(hasItem(DEFAULT_CREATED_DATE.toString()))) .andExpect(jsonPath("$.[*].modified_by").value(hasItem(DEFAULT_MODIFIED_BY.toString()))) .andExpect( jsonPath("$.[*].modified_date").value(hasItem(DEFAULT_MODIFIED_DATE.toString()))); } @Test @Transactional public void getOs_type() throws Exception { // Initialize the database os_typeRepository.saveAndFlush(os_type); // Get the os_type restOs_typeMockMvc .perform(get("/api/os_types/{id}", os_type.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id").value(os_type.getId().intValue())) .andExpect(jsonPath("$.os_type_name").value(DEFAULT_OS_TYPE_NAME.toString())) .andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString())) .andExpect(jsonPath("$.status_id").value(DEFAULT_STATUS_ID)) .andExpect(jsonPath("$.created_by").value(DEFAULT_CREATED_BY.toString())) .andExpect(jsonPath("$.created_date").value(DEFAULT_CREATED_DATE.toString())) .andExpect(jsonPath("$.modified_by").value(DEFAULT_MODIFIED_BY.toString())) .andExpect(jsonPath("$.modified_date").value(DEFAULT_MODIFIED_DATE.toString())); } @Test @Transactional public void getNonExistingOs_type() throws Exception { // Get the os_type restOs_typeMockMvc .perform(get("/api/os_types/{id}", Long.MAX_VALUE)) .andExpect(status().isNotFound()); } @Test @Transactional public void updateOs_type() throws Exception { // Initialize the database os_typeRepository.saveAndFlush(os_type); int databaseSizeBeforeUpdate = os_typeRepository.findAll().size(); // Update the os_type os_type.setOs_type_name(UPDATED_OS_TYPE_NAME); os_type.setDescription(UPDATED_DESCRIPTION); os_type.setStatus_id(UPDATED_STATUS_ID); os_type.setCreated_by(UPDATED_CREATED_BY); os_type.setCreated_date(UPDATED_CREATED_DATE); os_type.setModified_by(UPDATED_MODIFIED_BY); os_type.setModified_date(UPDATED_MODIFIED_DATE); restOs_typeMockMvc .perform( put("/api/os_types") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(os_type))) .andExpect(status().isOk()); // Validate the Os_type in the database List<Os_type> os_types = os_typeRepository.findAll(); assertThat(os_types).hasSize(databaseSizeBeforeUpdate); Os_type testOs_type = os_types.get(os_types.size() - 1); assertThat(testOs_type.getOs_type_name()).isEqualTo(UPDATED_OS_TYPE_NAME); assertThat(testOs_type.getDescription()).isEqualTo(UPDATED_DESCRIPTION); assertThat(testOs_type.getStatus_id()).isEqualTo(UPDATED_STATUS_ID); assertThat(testOs_type.getCreated_by()).isEqualTo(UPDATED_CREATED_BY); assertThat(testOs_type.getCreated_date()).isEqualTo(UPDATED_CREATED_DATE); assertThat(testOs_type.getModified_by()).isEqualTo(UPDATED_MODIFIED_BY); assertThat(testOs_type.getModified_date()).isEqualTo(UPDATED_MODIFIED_DATE); } @Test @Transactional public void deleteOs_type() throws Exception { // Initialize the database os_typeRepository.saveAndFlush(os_type); int databaseSizeBeforeDelete = os_typeRepository.findAll().size(); // Get the os_type restOs_typeMockMvc .perform( delete("/api/os_types/{id}", os_type.getId()).accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<Os_type> os_types = os_typeRepository.findAll(); assertThat(os_types).hasSize(databaseSizeBeforeDelete - 1); } }
/** * Test class for the JugadoresResource REST controller. * * @see JugadoresResource */ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) @WebAppConfiguration @IntegrationTest public class JugadoresResourceIntTest { private static final String DEFAULT_NOMBRE_JUGADOR = "AAAAA"; private static final String UPDATED_NOMBRE_JUGADOR = "BBBBB"; private static final LocalDate DEFAULT_FECHA_NACIMIENTO = LocalDate.ofEpochDay(0L); private static final LocalDate UPDATED_FECHA_NACIMIENTO = LocalDate.now(ZoneId.systemDefault()); private static final Integer DEFAULT_NUM_CANASTAS = 1; private static final Integer UPDATED_NUM_CANASTAS = 2; private static final Integer DEFAULT_NUM_ASISTENCIAS = 1; private static final Integer UPDATED_NUM_ASISTENCIAS = 2; private static final Integer DEFAULT_NUM_REBOTES = 1; private static final Integer UPDATED_NUM_REBOTES = 2; private static final String DEFAULT_POSICION = "AAAAA"; private static final String UPDATED_POSICION = "BBBBB"; @Inject private JugadoresRepository jugadoresRepository; @Inject private MappingJackson2HttpMessageConverter jacksonMessageConverter; @Inject private PageableHandlerMethodArgumentResolver pageableArgumentResolver; private MockMvc restJugadoresMockMvc; private Jugadores jugadores; @PostConstruct public void setup() { MockitoAnnotations.initMocks(this); JugadoresResource jugadoresResource = new JugadoresResource(); ReflectionTestUtils.setField(jugadoresResource, "jugadoresRepository", jugadoresRepository); this.restJugadoresMockMvc = MockMvcBuilders.standaloneSetup(jugadoresResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setMessageConverters(jacksonMessageConverter) .build(); } @Before public void initTest() { jugadores = new Jugadores(); jugadores.setNombreJugador(DEFAULT_NOMBRE_JUGADOR); jugadores.setFechaNacimiento(DEFAULT_FECHA_NACIMIENTO); jugadores.setNumCanastas(DEFAULT_NUM_CANASTAS); jugadores.setNumAsistencias(DEFAULT_NUM_ASISTENCIAS); jugadores.setNumRebotes(DEFAULT_NUM_REBOTES); jugadores.setPosicion(DEFAULT_POSICION); } @Test @Transactional public void createJugadores() throws Exception { int databaseSizeBeforeCreate = jugadoresRepository.findAll().size(); // Create the Jugadores restJugadoresMockMvc .perform( post("/api/jugadoress") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(jugadores))) .andExpect(status().isCreated()); // Validate the Jugadores in the database List<Jugadores> jugadoress = jugadoresRepository.findAll(); assertThat(jugadoress).hasSize(databaseSizeBeforeCreate + 1); Jugadores testJugadores = jugadoress.get(jugadoress.size() - 1); assertThat(testJugadores.getNombreJugador()).isEqualTo(DEFAULT_NOMBRE_JUGADOR); assertThat(testJugadores.getFechaNacimiento()).isEqualTo(DEFAULT_FECHA_NACIMIENTO); assertThat(testJugadores.getNumCanastas()).isEqualTo(DEFAULT_NUM_CANASTAS); assertThat(testJugadores.getNumAsistencias()).isEqualTo(DEFAULT_NUM_ASISTENCIAS); assertThat(testJugadores.getNumRebotes()).isEqualTo(DEFAULT_NUM_REBOTES); assertThat(testJugadores.getPosicion()).isEqualTo(DEFAULT_POSICION); } @Test @Transactional public void checkNombreJugadorIsRequired() throws Exception { int databaseSizeBeforeTest = jugadoresRepository.findAll().size(); // set the field null jugadores.setNombreJugador(null); // Create the Jugadores, which fails. restJugadoresMockMvc .perform( post("/api/jugadoress") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(jugadores))) .andExpect(status().isBadRequest()); List<Jugadores> jugadoress = jugadoresRepository.findAll(); assertThat(jugadoress).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void getAllJugadoress() throws Exception { // Initialize the database jugadoresRepository.saveAndFlush(jugadores); // Get all the jugadoress restJugadoresMockMvc .perform(get("/api/jugadoress?sort=id,desc")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.[*].id").value(hasItem(jugadores.getId().intValue()))) .andExpect( jsonPath("$.[*].nombreJugador").value(hasItem(DEFAULT_NOMBRE_JUGADOR.toString()))) .andExpect( jsonPath("$.[*].fechaNacimiento").value(hasItem(DEFAULT_FECHA_NACIMIENTO.toString()))) .andExpect(jsonPath("$.[*].numCanastas").value(hasItem(DEFAULT_NUM_CANASTAS))) .andExpect(jsonPath("$.[*].numAsistencias").value(hasItem(DEFAULT_NUM_ASISTENCIAS))) .andExpect(jsonPath("$.[*].numRebotes").value(hasItem(DEFAULT_NUM_REBOTES))) .andExpect(jsonPath("$.[*].posicion").value(hasItem(DEFAULT_POSICION.toString()))); } @Test @Transactional public void getJugadores() throws Exception { // Initialize the database jugadoresRepository.saveAndFlush(jugadores); // Get the jugadores restJugadoresMockMvc .perform(get("/api/jugadoress/{id}", jugadores.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id").value(jugadores.getId().intValue())) .andExpect(jsonPath("$.nombreJugador").value(DEFAULT_NOMBRE_JUGADOR.toString())) .andExpect(jsonPath("$.fechaNacimiento").value(DEFAULT_FECHA_NACIMIENTO.toString())) .andExpect(jsonPath("$.numCanastas").value(DEFAULT_NUM_CANASTAS)) .andExpect(jsonPath("$.numAsistencias").value(DEFAULT_NUM_ASISTENCIAS)) .andExpect(jsonPath("$.numRebotes").value(DEFAULT_NUM_REBOTES)) .andExpect(jsonPath("$.posicion").value(DEFAULT_POSICION.toString())); } @Test @Transactional public void getNonExistingJugadores() throws Exception { // Get the jugadores restJugadoresMockMvc .perform(get("/api/jugadoress/{id}", Long.MAX_VALUE)) .andExpect(status().isNotFound()); } @Test @Transactional public void updateJugadores() throws Exception { // Initialize the database jugadoresRepository.saveAndFlush(jugadores); int databaseSizeBeforeUpdate = jugadoresRepository.findAll().size(); // Update the jugadores jugadores.setNombreJugador(UPDATED_NOMBRE_JUGADOR); jugadores.setFechaNacimiento(UPDATED_FECHA_NACIMIENTO); jugadores.setNumCanastas(UPDATED_NUM_CANASTAS); jugadores.setNumAsistencias(UPDATED_NUM_ASISTENCIAS); jugadores.setNumRebotes(UPDATED_NUM_REBOTES); jugadores.setPosicion(UPDATED_POSICION); restJugadoresMockMvc .perform( put("/api/jugadoress") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(jugadores))) .andExpect(status().isOk()); // Validate the Jugadores in the database List<Jugadores> jugadoress = jugadoresRepository.findAll(); assertThat(jugadoress).hasSize(databaseSizeBeforeUpdate); Jugadores testJugadores = jugadoress.get(jugadoress.size() - 1); assertThat(testJugadores.getNombreJugador()).isEqualTo(UPDATED_NOMBRE_JUGADOR); assertThat(testJugadores.getFechaNacimiento()).isEqualTo(UPDATED_FECHA_NACIMIENTO); assertThat(testJugadores.getNumCanastas()).isEqualTo(UPDATED_NUM_CANASTAS); assertThat(testJugadores.getNumAsistencias()).isEqualTo(UPDATED_NUM_ASISTENCIAS); assertThat(testJugadores.getNumRebotes()).isEqualTo(UPDATED_NUM_REBOTES); assertThat(testJugadores.getPosicion()).isEqualTo(UPDATED_POSICION); } @Test @Transactional public void deleteJugadores() throws Exception { // Initialize the database jugadoresRepository.saveAndFlush(jugadores); int databaseSizeBeforeDelete = jugadoresRepository.findAll().size(); // Get the jugadores restJugadoresMockMvc .perform( delete("/api/jugadoress/{id}", jugadores.getId()) .accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<Jugadores> jugadoress = jugadoresRepository.findAll(); assertThat(jugadoress).hasSize(databaseSizeBeforeDelete - 1); } }
/** * Test class for the EntryResource REST controller. * * @see EntryResource */ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) @WebAppConfiguration @IntegrationTest public class EntryResourceIntTest { private static final LocalDate DEFAULT_DATE = LocalDate.ofEpochDay(0L); private static final LocalDate UPDATED_DATE = LocalDate.now(ZoneId.systemDefault()); private static final Integer DEFAULT_EXERCISE = 1; private static final Integer UPDATED_EXERCISE = 2; private static final Integer DEFAULT_MEALS = 1; private static final Integer UPDATED_MEALS = 2; private static final Integer DEFAULT_ALCOHOL = 1; private static final Integer UPDATED_ALCOHOL = 2; private static final String DEFAULT_NOTES = "AAAAA"; private static final String UPDATED_NOTES = "BBBBB"; @Inject private EntryRepository entryRepository; @Inject private MappingJackson2HttpMessageConverter jacksonMessageConverter; @Inject private PageableHandlerMethodArgumentResolver pageableArgumentResolver; private MockMvc restEntryMockMvc; private Entry entry; @PostConstruct public void setup() { MockitoAnnotations.initMocks(this); EntryResource entryResource = new EntryResource(); ReflectionTestUtils.setField(entryResource, "entryRepository", entryRepository); this.restEntryMockMvc = MockMvcBuilders.standaloneSetup(entryResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setMessageConverters(jacksonMessageConverter) .build(); } @Before public void initTest() { entry = new Entry(); entry.setDate(DEFAULT_DATE); entry.setExercise(DEFAULT_EXERCISE); entry.setMeals(DEFAULT_MEALS); entry.setAlcohol(DEFAULT_ALCOHOL); entry.setNotes(DEFAULT_NOTES); } @Test @Transactional public void createEntry() throws Exception { int databaseSizeBeforeCreate = entryRepository.findAll().size(); // Create the Entry restEntryMockMvc .perform( post("/api/entrys") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(entry))) .andExpect(status().isCreated()); // Validate the Entry in the database List<Entry> entrys = entryRepository.findAll(); assertThat(entrys).hasSize(databaseSizeBeforeCreate + 1); Entry testEntry = entrys.get(entrys.size() - 1); assertThat(testEntry.getDate()).isEqualTo(DEFAULT_DATE); assertThat(testEntry.getExercise()).isEqualTo(DEFAULT_EXERCISE); assertThat(testEntry.getMeals()).isEqualTo(DEFAULT_MEALS); assertThat(testEntry.getAlcohol()).isEqualTo(DEFAULT_ALCOHOL); assertThat(testEntry.getNotes()).isEqualTo(DEFAULT_NOTES); } @Test @Transactional public void checkDateIsRequired() throws Exception { int databaseSizeBeforeTest = entryRepository.findAll().size(); // set the field null entry.setDate(null); // Create the Entry, which fails. restEntryMockMvc .perform( post("/api/entrys") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(entry))) .andExpect(status().isBadRequest()); List<Entry> entrys = entryRepository.findAll(); assertThat(entrys).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void getAllEntrys() throws Exception { // Initialize the database entryRepository.saveAndFlush(entry); // Get all the entrys restEntryMockMvc .perform(get("/api/entrys")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.[*].id").value(hasItem(entry.getId().intValue()))) .andExpect(jsonPath("$.[*].date").value(hasItem(DEFAULT_DATE.toString()))) .andExpect(jsonPath("$.[*].exercise").value(hasItem(DEFAULT_EXERCISE))) .andExpect(jsonPath("$.[*].meals").value(hasItem(DEFAULT_MEALS))) .andExpect(jsonPath("$.[*].alcohol").value(hasItem(DEFAULT_ALCOHOL))) .andExpect(jsonPath("$.[*].notes").value(hasItem(DEFAULT_NOTES.toString()))); } @Test @Transactional public void getEntry() throws Exception { // Initialize the database entryRepository.saveAndFlush(entry); // Get the entry restEntryMockMvc .perform(get("/api/entrys/{id}", entry.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id").value(entry.getId().intValue())) .andExpect(jsonPath("$.date").value(DEFAULT_DATE.toString())) .andExpect(jsonPath("$.exercise").value(DEFAULT_EXERCISE)) .andExpect(jsonPath("$.meals").value(DEFAULT_MEALS)) .andExpect(jsonPath("$.alcohol").value(DEFAULT_ALCOHOL)) .andExpect(jsonPath("$.notes").value(DEFAULT_NOTES.toString())); } @Test @Transactional public void getNonExistingEntry() throws Exception { // Get the entry restEntryMockMvc .perform(get("/api/entrys/{id}", Long.MAX_VALUE)) .andExpect(status().isNotFound()); } @Test @Transactional public void updateEntry() throws Exception { // Initialize the database entryRepository.saveAndFlush(entry); int databaseSizeBeforeUpdate = entryRepository.findAll().size(); // Update the entry entry.setDate(UPDATED_DATE); entry.setExercise(UPDATED_EXERCISE); entry.setMeals(UPDATED_MEALS); entry.setAlcohol(UPDATED_ALCOHOL); entry.setNotes(UPDATED_NOTES); restEntryMockMvc .perform( put("/api/entrys") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(entry))) .andExpect(status().isOk()); // Validate the Entry in the database List<Entry> entrys = entryRepository.findAll(); assertThat(entrys).hasSize(databaseSizeBeforeUpdate); Entry testEntry = entrys.get(entrys.size() - 1); assertThat(testEntry.getDate()).isEqualTo(UPDATED_DATE); assertThat(testEntry.getExercise()).isEqualTo(UPDATED_EXERCISE); assertThat(testEntry.getMeals()).isEqualTo(UPDATED_MEALS); assertThat(testEntry.getAlcohol()).isEqualTo(UPDATED_ALCOHOL); assertThat(testEntry.getNotes()).isEqualTo(UPDATED_NOTES); } @Test @Transactional public void deleteEntry() throws Exception { // Initialize the database entryRepository.saveAndFlush(entry); int databaseSizeBeforeDelete = entryRepository.findAll().size(); // Get the entry restEntryMockMvc .perform(delete("/api/entrys/{id}", entry.getId()).accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<Entry> entrys = entryRepository.findAll(); assertThat(entrys).hasSize(databaseSizeBeforeDelete - 1); } }
private int findYear(long epochSecond, ZoneOffset offset) { // inline for performance long localSecond = epochSecond + offset.getTotalSeconds(); long localEpochDay = Math.floorDiv(localSecond, 86400); return LocalDate.ofEpochDay(localEpochDay).getYear(); }
/** * Test class for the Register_infoResource REST controller. * * @see Register_infoResource */ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) @WebAppConfiguration @IntegrationTest public class Register_infoResourceIntTest { private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME.withZone(ZoneId.of("Z")); private static final LocalDate DEFAULT_DATE_CHECKIN = LocalDate.ofEpochDay(0L); private static final LocalDate UPDATED_DATE_CHECKIN = LocalDate.now(ZoneId.systemDefault()); private static final LocalDate DEFAULT_DATE_CHECKOUT = LocalDate.ofEpochDay(0L); private static final LocalDate UPDATED_DATE_CHECKOUT = LocalDate.now(ZoneId.systemDefault()); private static final Integer DEFAULT_NUMBER_OF_ADULT = 0; private static final Integer UPDATED_NUMBER_OF_ADULT = 1; private static final Integer DEFAULT_NUMBER_OF_KID = 0; private static final Integer UPDATED_NUMBER_OF_KID = 1; private static final String DEFAULT_OTHER_REQUEST = "AAAAA"; private static final String UPDATED_OTHER_REQUEST = "BBBBB"; private static final BigDecimal DEFAULT_DEPOSIT_VALUE = new BigDecimal(0); private static final BigDecimal UPDATED_DEPOSIT_VALUE = new BigDecimal(1); private static final ZonedDateTime DEFAULT_CREATE_DATE = ZonedDateTime.ofInstant(Instant.ofEpochMilli(0L), ZoneId.systemDefault()); private static final ZonedDateTime UPDATED_CREATE_DATE = ZonedDateTime.now(ZoneId.systemDefault()).withNano(0); private static final String DEFAULT_CREATE_DATE_STR = dateTimeFormatter.format(DEFAULT_CREATE_DATE); private static final ZonedDateTime DEFAULT_LAST_MODIFIED_DATE = ZonedDateTime.ofInstant(Instant.ofEpochMilli(0L), ZoneId.systemDefault()); private static final ZonedDateTime UPDATED_LAST_MODIFIED_DATE = ZonedDateTime.now(ZoneId.systemDefault()).withNano(0); private static final String DEFAULT_LAST_MODIFIED_DATE_STR = dateTimeFormatter.format(DEFAULT_LAST_MODIFIED_DATE); @Inject private Register_infoRepository register_infoRepository; @Inject private Register_infoService register_infoService; @Inject private MappingJackson2HttpMessageConverter jacksonMessageConverter; @Inject private PageableHandlerMethodArgumentResolver pageableArgumentResolver; private MockMvc restRegister_infoMockMvc; private Register_info register_info; @PostConstruct public void setup() { MockitoAnnotations.initMocks(this); Register_infoResource register_infoResource = new Register_infoResource(); ReflectionTestUtils.setField( register_infoResource, "register_infoService", register_infoService); this.restRegister_infoMockMvc = MockMvcBuilders.standaloneSetup(register_infoResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setMessageConverters(jacksonMessageConverter) .build(); } @Before public void initTest() { register_info = new Register_info(); register_info.setDate_checkin(DEFAULT_DATE_CHECKIN); register_info.setDate_checkout(DEFAULT_DATE_CHECKOUT); register_info.setNumber_of_adult(DEFAULT_NUMBER_OF_ADULT); register_info.setNumber_of_kid(DEFAULT_NUMBER_OF_KID); register_info.setOther_request(DEFAULT_OTHER_REQUEST); register_info.setDeposit_value(DEFAULT_DEPOSIT_VALUE); register_info.setCreate_date(DEFAULT_CREATE_DATE); register_info.setLast_modified_date(DEFAULT_LAST_MODIFIED_DATE); } @Test @Transactional public void createRegister_info() throws Exception { int databaseSizeBeforeCreate = register_infoRepository.findAll().size(); // Create the Register_info restRegister_infoMockMvc .perform( post("/api/register_infos") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(register_info))) .andExpect(status().isCreated()); // Validate the Register_info in the database List<Register_info> register_infos = register_infoRepository.findAll(); assertThat(register_infos).hasSize(databaseSizeBeforeCreate + 1); Register_info testRegister_info = register_infos.get(register_infos.size() - 1); assertThat(testRegister_info.getDate_checkin()).isEqualTo(DEFAULT_DATE_CHECKIN); assertThat(testRegister_info.getDate_checkout()).isEqualTo(DEFAULT_DATE_CHECKOUT); assertThat(testRegister_info.getNumber_of_adult()).isEqualTo(DEFAULT_NUMBER_OF_ADULT); assertThat(testRegister_info.getNumber_of_kid()).isEqualTo(DEFAULT_NUMBER_OF_KID); assertThat(testRegister_info.getOther_request()).isEqualTo(DEFAULT_OTHER_REQUEST); assertThat(testRegister_info.getDeposit_value()).isEqualTo(DEFAULT_DEPOSIT_VALUE); assertThat(testRegister_info.getCreate_date()).isEqualTo(DEFAULT_CREATE_DATE); assertThat(testRegister_info.getLast_modified_date()).isEqualTo(DEFAULT_LAST_MODIFIED_DATE); } @Test @Transactional public void checkDate_checkinIsRequired() throws Exception { int databaseSizeBeforeTest = register_infoRepository.findAll().size(); // set the field null register_info.setDate_checkin(null); // Create the Register_info, which fails. restRegister_infoMockMvc .perform( post("/api/register_infos") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(register_info))) .andExpect(status().isBadRequest()); List<Register_info> register_infos = register_infoRepository.findAll(); assertThat(register_infos).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void checkDate_checkoutIsRequired() throws Exception { int databaseSizeBeforeTest = register_infoRepository.findAll().size(); // set the field null register_info.setDate_checkout(null); // Create the Register_info, which fails. restRegister_infoMockMvc .perform( post("/api/register_infos") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(register_info))) .andExpect(status().isBadRequest()); List<Register_info> register_infos = register_infoRepository.findAll(); assertThat(register_infos).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void checkNumber_of_adultIsRequired() throws Exception { int databaseSizeBeforeTest = register_infoRepository.findAll().size(); // set the field null register_info.setNumber_of_adult(null); // Create the Register_info, which fails. restRegister_infoMockMvc .perform( post("/api/register_infos") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(register_info))) .andExpect(status().isBadRequest()); List<Register_info> register_infos = register_infoRepository.findAll(); assertThat(register_infos).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void checkNumber_of_kidIsRequired() throws Exception { int databaseSizeBeforeTest = register_infoRepository.findAll().size(); // set the field null register_info.setNumber_of_kid(null); // Create the Register_info, which fails. restRegister_infoMockMvc .perform( post("/api/register_infos") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(register_info))) .andExpect(status().isBadRequest()); List<Register_info> register_infos = register_infoRepository.findAll(); assertThat(register_infos).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void checkDeposit_valueIsRequired() throws Exception { int databaseSizeBeforeTest = register_infoRepository.findAll().size(); // set the field null register_info.setDeposit_value(null); // Create the Register_info, which fails. restRegister_infoMockMvc .perform( post("/api/register_infos") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(register_info))) .andExpect(status().isBadRequest()); List<Register_info> register_infos = register_infoRepository.findAll(); assertThat(register_infos).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void checkCreate_dateIsRequired() throws Exception { int databaseSizeBeforeTest = register_infoRepository.findAll().size(); // set the field null register_info.setCreate_date(null); // Create the Register_info, which fails. restRegister_infoMockMvc .perform( post("/api/register_infos") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(register_info))) .andExpect(status().isBadRequest()); List<Register_info> register_infos = register_infoRepository.findAll(); assertThat(register_infos).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void getAllRegister_infos() throws Exception { // Initialize the database register_infoRepository.saveAndFlush(register_info); // Get all the register_infos restRegister_infoMockMvc .perform(get("/api/register_infos?sort=id,desc")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.[*].id").value(hasItem(register_info.getId().intValue()))) .andExpect(jsonPath("$.[*].date_checkin").value(hasItem(DEFAULT_DATE_CHECKIN.toString()))) .andExpect(jsonPath("$.[*].date_checkout").value(hasItem(DEFAULT_DATE_CHECKOUT.toString()))) .andExpect(jsonPath("$.[*].number_of_adult").value(hasItem(DEFAULT_NUMBER_OF_ADULT))) .andExpect(jsonPath("$.[*].number_of_kid").value(hasItem(DEFAULT_NUMBER_OF_KID))) .andExpect(jsonPath("$.[*].other_request").value(hasItem(DEFAULT_OTHER_REQUEST.toString()))) .andExpect(jsonPath("$.[*].deposit_value").value(hasItem(DEFAULT_DEPOSIT_VALUE.intValue()))) .andExpect(jsonPath("$.[*].create_date").value(hasItem(DEFAULT_CREATE_DATE_STR))) .andExpect( jsonPath("$.[*].last_modified_date").value(hasItem(DEFAULT_LAST_MODIFIED_DATE_STR))); } @Test @Transactional public void getRegister_info() throws Exception { // Initialize the database register_infoRepository.saveAndFlush(register_info); // Get the register_info restRegister_infoMockMvc .perform(get("/api/register_infos/{id}", register_info.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id").value(register_info.getId().intValue())) .andExpect(jsonPath("$.date_checkin").value(DEFAULT_DATE_CHECKIN.toString())) .andExpect(jsonPath("$.date_checkout").value(DEFAULT_DATE_CHECKOUT.toString())) .andExpect(jsonPath("$.number_of_adult").value(DEFAULT_NUMBER_OF_ADULT)) .andExpect(jsonPath("$.number_of_kid").value(DEFAULT_NUMBER_OF_KID)) .andExpect(jsonPath("$.other_request").value(DEFAULT_OTHER_REQUEST.toString())) .andExpect(jsonPath("$.deposit_value").value(DEFAULT_DEPOSIT_VALUE.intValue())) .andExpect(jsonPath("$.create_date").value(DEFAULT_CREATE_DATE_STR)) .andExpect(jsonPath("$.last_modified_date").value(DEFAULT_LAST_MODIFIED_DATE_STR)); } @Test @Transactional public void getNonExistingRegister_info() throws Exception { // Get the register_info restRegister_infoMockMvc .perform(get("/api/register_infos/{id}", Long.MAX_VALUE)) .andExpect(status().isNotFound()); } @Test @Transactional public void updateRegister_info() throws Exception { // Initialize the database register_infoRepository.saveAndFlush(register_info); int databaseSizeBeforeUpdate = register_infoRepository.findAll().size(); // Update the register_info register_info.setDate_checkin(UPDATED_DATE_CHECKIN); register_info.setDate_checkout(UPDATED_DATE_CHECKOUT); register_info.setNumber_of_adult(UPDATED_NUMBER_OF_ADULT); register_info.setNumber_of_kid(UPDATED_NUMBER_OF_KID); register_info.setOther_request(UPDATED_OTHER_REQUEST); register_info.setDeposit_value(UPDATED_DEPOSIT_VALUE); register_info.setCreate_date(UPDATED_CREATE_DATE); register_info.setLast_modified_date(UPDATED_LAST_MODIFIED_DATE); restRegister_infoMockMvc .perform( put("/api/register_infos") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(register_info))) .andExpect(status().isOk()); // Validate the Register_info in the database List<Register_info> register_infos = register_infoRepository.findAll(); assertThat(register_infos).hasSize(databaseSizeBeforeUpdate); Register_info testRegister_info = register_infos.get(register_infos.size() - 1); assertThat(testRegister_info.getDate_checkin()).isEqualTo(UPDATED_DATE_CHECKIN); assertThat(testRegister_info.getDate_checkout()).isEqualTo(UPDATED_DATE_CHECKOUT); assertThat(testRegister_info.getNumber_of_adult()).isEqualTo(UPDATED_NUMBER_OF_ADULT); assertThat(testRegister_info.getNumber_of_kid()).isEqualTo(UPDATED_NUMBER_OF_KID); assertThat(testRegister_info.getOther_request()).isEqualTo(UPDATED_OTHER_REQUEST); assertThat(testRegister_info.getDeposit_value()).isEqualTo(UPDATED_DEPOSIT_VALUE); assertThat(testRegister_info.getCreate_date()).isEqualTo(UPDATED_CREATE_DATE); assertThat(testRegister_info.getLast_modified_date()).isEqualTo(UPDATED_LAST_MODIFIED_DATE); } @Test @Transactional public void deleteRegister_info() throws Exception { // Initialize the database register_infoRepository.saveAndFlush(register_info); int databaseSizeBeforeDelete = register_infoRepository.findAll().size(); // Get the register_info restRegister_infoMockMvc .perform( delete("/api/register_infos/{id}", register_info.getId()) .accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<Register_info> register_infos = register_infoRepository.findAll(); assertThat(register_infos).hasSize(databaseSizeBeforeDelete - 1); } }
/** * Test class for the BloodPressureResource REST controller. * * @see BloodPressureResource */ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) @WebAppConfiguration @IntegrationTest public class BloodPressureResourceIntTest { private static final ZonedDateTime DEFAULT_TIMESTAMP = ZonedDateTime.of(LocalDate.ofEpochDay(0L).atStartOfDay(), ZoneId.of("UTC")); private static final ZonedDateTime UPDATED_TIMESTAMP = ZonedDateTime.now(ZoneId.of("UTC")); private static final String DEFAULT_TIMESTAMP_STR = DEFAULT_TIMESTAMP.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")); private static final Integer DEFAULT_SYSTOLIC = 1; private static final Integer UPDATED_SYSTOLIC = 2; private static final Integer DEFAULT_DIASTOLIC = 1; private static final Integer UPDATED_DIASTOLIC = 2; @Inject private BloodPressureRepository bloodPressureRepository; @Inject private BloodPressureSearchRepository bloodPressureSearchRepository; @Inject private MappingJackson2HttpMessageConverter jacksonMessageConverter; @Inject private PageableHandlerMethodArgumentResolver pageableArgumentResolver; @Inject private UserRepository userRepository; private MockMvc restBloodPressureMockMvc; private BloodPressure bloodPressure; @Autowired private WebApplicationContext context; @PostConstruct public void setup() { MockitoAnnotations.initMocks(this); BloodPressureResource bloodPressureResource = new BloodPressureResource(); ReflectionTestUtils.setField( bloodPressureResource, "bloodPressureSearchRepository", bloodPressureSearchRepository); ReflectionTestUtils.setField( bloodPressureResource, "bloodPressureRepository", bloodPressureRepository); this.restBloodPressureMockMvc = MockMvcBuilders.standaloneSetup(bloodPressureResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setMessageConverters(jacksonMessageConverter) .build(); } @Before public void initTest() { bloodPressure = new BloodPressure(); bloodPressure.setTimestamp(DEFAULT_TIMESTAMP); bloodPressure.setSystolic(DEFAULT_SYSTOLIC); bloodPressure.setDiastolic(DEFAULT_DIASTOLIC); } @Test @Transactional public void createBloodPressure() throws Exception { int databaseSizeBeforeCreate = bloodPressureRepository.findAll().size(); // Create the BloodPressure restBloodPressureMockMvc .perform( post("/api/bloodPressures") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(bloodPressure))) .andExpect(status().isCreated()); // Validate the BloodPressure in the database List<BloodPressure> bloodPressures = bloodPressureRepository.findAll(); assertThat(bloodPressures).hasSize(databaseSizeBeforeCreate + 1); BloodPressure testBloodPressure = bloodPressures.get(bloodPressures.size() - 1); assertThat(testBloodPressure.getTimestamp()).isEqualTo(DEFAULT_TIMESTAMP); assertThat(testBloodPressure.getSystolic()).isEqualTo(DEFAULT_SYSTOLIC); assertThat(testBloodPressure.getDiastolic()).isEqualTo(DEFAULT_DIASTOLIC); } @Test @Transactional public void getAllBloodPressures() throws Exception { // Initialize the database bloodPressureRepository.saveAndFlush(bloodPressure); // Get all the bloodPressures restBloodPressureMockMvc .perform(get("/api/bloodPressures?sort=id,desc")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.[*].id").value(hasItem(bloodPressure.getId().intValue()))) .andExpect(jsonPath("$.[*].timestamp").value(hasItem(DEFAULT_TIMESTAMP_STR))) .andExpect(jsonPath("$.[*].systolic").value(hasItem(DEFAULT_SYSTOLIC))) .andExpect(jsonPath("$.[*].diastolic").value(hasItem(DEFAULT_DIASTOLIC))); } @Test @Transactional public void getBloodPressure() throws Exception { // Initialize the database bloodPressureRepository.saveAndFlush(bloodPressure); // Get the bloodPressure restBloodPressureMockMvc .perform(get("/api/bloodPressures/{id}", bloodPressure.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id").value(bloodPressure.getId().intValue())) .andExpect(jsonPath("$.timestamp").value(DEFAULT_TIMESTAMP_STR)) .andExpect(jsonPath("$.systolic").value(DEFAULT_SYSTOLIC)) .andExpect(jsonPath("$.diastolic").value(DEFAULT_DIASTOLIC)); } @Test @Transactional public void getNonExistingBloodPressure() throws Exception { // Get the bloodPressure restBloodPressureMockMvc .perform(get("/api/bloodPressures/{id}", Long.MAX_VALUE)) .andExpect(status().isNotFound()); } @Test @Transactional public void updateBloodPressure() throws Exception { // Initialize the database bloodPressureRepository.saveAndFlush(bloodPressure); int databaseSizeBeforeUpdate = bloodPressureRepository.findAll().size(); // Update the bloodPressure bloodPressure.setTimestamp(UPDATED_TIMESTAMP); bloodPressure.setSystolic(UPDATED_SYSTOLIC); bloodPressure.setDiastolic(UPDATED_DIASTOLIC); restBloodPressureMockMvc .perform( put("/api/bloodPressures") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(bloodPressure))) .andExpect(status().isOk()); // Validate the BloodPressure in the database List<BloodPressure> bloodPressures = bloodPressureRepository.findAll(); assertThat(bloodPressures).hasSize(databaseSizeBeforeUpdate); BloodPressure testBloodPressure = bloodPressures.get(bloodPressures.size() - 1); assertThat(testBloodPressure.getTimestamp()).isEqualTo(UPDATED_TIMESTAMP); assertThat(testBloodPressure.getSystolic()).isEqualTo(UPDATED_SYSTOLIC); assertThat(testBloodPressure.getDiastolic()).isEqualTo(UPDATED_DIASTOLIC); } @Test @Transactional public void deleteBloodPressure() throws Exception { // Initialize the database bloodPressureRepository.saveAndFlush(bloodPressure); int databaseSizeBeforeDelete = bloodPressureRepository.findAll().size(); // Get the bloodPressure restBloodPressureMockMvc .perform( delete("/api/bloodPressures/{id}", bloodPressure.getId()) .accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<BloodPressure> bloodPressures = bloodPressureRepository.findAll(); assertThat(bloodPressures).hasSize(databaseSizeBeforeDelete - 1); } private void createBloodPressureByMonth( ZonedDateTime firstOfMonth, ZonedDateTime firstDayOfLastMonth) { User user = userRepository.findOneByLogin("user").get(); // this month bloodPressure = new BloodPressure(firstOfMonth, 120, 80, user); bloodPressureRepository.saveAndFlush(bloodPressure); bloodPressure = new BloodPressure(firstOfMonth.plusDays(10), 125, 75, user); bloodPressureRepository.saveAndFlush(bloodPressure); bloodPressure = new BloodPressure(firstOfMonth.plusDays(20), 100, 69, user); bloodPressureRepository.saveAndFlush(bloodPressure); // last month bloodPressure = new BloodPressure(firstDayOfLastMonth, 130, 90, user); bloodPressureRepository.saveAndFlush(bloodPressure); bloodPressure = new BloodPressure(firstDayOfLastMonth.plusDays(11), 135, 85, user); bloodPressureRepository.saveAndFlush(bloodPressure); bloodPressure = new BloodPressure(firstDayOfLastMonth.plusDays(23), 130, 75, user); bloodPressureRepository.saveAndFlush(bloodPressure); } @Test @Transactional public void getBloodPressureForLast30Days() throws Exception { ZonedDateTime now = ZonedDateTime.now(); ZonedDateTime firstOfMonth = now.withDayOfMonth(1); ZonedDateTime firstDayOfLastMonth = firstOfMonth.minusMonths(1); createBloodPressureByMonth(firstOfMonth, firstDayOfLastMonth); // create security-aware mockMvc restBloodPressureMockMvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build(); // Get all the blood pressure readings restBloodPressureMockMvc .perform(get("/api/bloodPressures").with(user("user").roles("USER"))) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$", hasSize(6))); // Get the blood pressure readings for the last 30 days restBloodPressureMockMvc .perform(get("/api/bp-by-days/{days}", 30).with(user("user").roles("USER"))) .andDo(print()) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.period").value("Last 30 Days")) .andExpect(jsonPath("$.readings.[*].systolic").value(hasItem(120))) .andExpect(jsonPath("$.readings.[*].diastolic").value(hasItem(75))); } }
/** * Test class for the ClasseTypeResource REST controller. * * @see ClasseTypeResource */ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) @WebAppConfiguration @IntegrationTest public class ClasseTypeResourceIntTest { private static final String DEFAULT_INTITULE = "AAAAA"; private static final String UPDATED_INTITULE = "BBBBB"; private static final LocalDate DEFAULT_DATE_CREATION = LocalDate.ofEpochDay(0L); private static final LocalDate UPDATED_DATE_CREATION = LocalDate.now(ZoneId.systemDefault()); @Inject private ClasseTypeRepository classeTypeRepository; @Inject private ClasseTypeSearchRepository classeTypeSearchRepository; @Inject private MappingJackson2HttpMessageConverter jacksonMessageConverter; @Inject private PageableHandlerMethodArgumentResolver pageableArgumentResolver; private MockMvc restClasseTypeMockMvc; private ClasseType classeType; @PostConstruct public void setup() { MockitoAnnotations.initMocks(this); ClasseTypeResource classeTypeResource = new ClasseTypeResource(); ReflectionTestUtils.setField( classeTypeResource, "classeTypeSearchRepository", classeTypeSearchRepository); ReflectionTestUtils.setField(classeTypeResource, "classeTypeRepository", classeTypeRepository); this.restClasseTypeMockMvc = MockMvcBuilders.standaloneSetup(classeTypeResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setMessageConverters(jacksonMessageConverter) .build(); } @Before public void initTest() { classeType = new ClasseType(); classeType.setIntitule(DEFAULT_INTITULE); classeType.setDateCreation(DEFAULT_DATE_CREATION); } @Test @Transactional public void createClasseType() throws Exception { int databaseSizeBeforeCreate = classeTypeRepository.findAll().size(); // Create the ClasseType restClasseTypeMockMvc .perform( post("/api/classeTypes") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(classeType))) .andExpect(status().isCreated()); // Validate the ClasseType in the database List<ClasseType> classeTypes = classeTypeRepository.findAll(); assertThat(classeTypes).hasSize(databaseSizeBeforeCreate + 1); ClasseType testClasseType = classeTypes.get(classeTypes.size() - 1); assertThat(testClasseType.getIntitule()).isEqualTo(DEFAULT_INTITULE); assertThat(testClasseType.getDateCreation()).isEqualTo(DEFAULT_DATE_CREATION); } @Test @Transactional public void checkIntituleIsRequired() throws Exception { int databaseSizeBeforeTest = classeTypeRepository.findAll().size(); // set the field null classeType.setIntitule(null); // Create the ClasseType, which fails. restClasseTypeMockMvc .perform( post("/api/classeTypes") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(classeType))) .andExpect(status().isBadRequest()); List<ClasseType> classeTypes = classeTypeRepository.findAll(); assertThat(classeTypes).hasSize(databaseSizeBeforeTest); } @Test @Transactional public void getAllClasseTypes() throws Exception { // Initialize the database classeTypeRepository.saveAndFlush(classeType); // Get all the classeTypes restClasseTypeMockMvc .perform(get("/api/classeTypes?sort=id,desc")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.[*].id").value(hasItem(classeType.getId().intValue()))) .andExpect(jsonPath("$.[*].intitule").value(hasItem(DEFAULT_INTITULE.toString()))) .andExpect(jsonPath("$.[*].dateCreation").value(hasItem(DEFAULT_DATE_CREATION.toString()))); } @Test @Transactional public void getClasseType() throws Exception { // Initialize the database classeTypeRepository.saveAndFlush(classeType); // Get the classeType restClasseTypeMockMvc .perform(get("/api/classeTypes/{id}", classeType.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id").value(classeType.getId().intValue())) .andExpect(jsonPath("$.intitule").value(DEFAULT_INTITULE.toString())) .andExpect(jsonPath("$.dateCreation").value(DEFAULT_DATE_CREATION.toString())); } @Test @Transactional public void getNonExistingClasseType() throws Exception { // Get the classeType restClasseTypeMockMvc .perform(get("/api/classeTypes/{id}", Long.MAX_VALUE)) .andExpect(status().isNotFound()); } @Test @Transactional public void updateClasseType() throws Exception { // Initialize the database classeTypeRepository.saveAndFlush(classeType); int databaseSizeBeforeUpdate = classeTypeRepository.findAll().size(); // Update the classeType classeType.setIntitule(UPDATED_INTITULE); classeType.setDateCreation(UPDATED_DATE_CREATION); restClasseTypeMockMvc .perform( put("/api/classeTypes") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(classeType))) .andExpect(status().isOk()); // Validate the ClasseType in the database List<ClasseType> classeTypes = classeTypeRepository.findAll(); assertThat(classeTypes).hasSize(databaseSizeBeforeUpdate); ClasseType testClasseType = classeTypes.get(classeTypes.size() - 1); assertThat(testClasseType.getIntitule()).isEqualTo(UPDATED_INTITULE); assertThat(testClasseType.getDateCreation()).isEqualTo(UPDATED_DATE_CREATION); } @Test @Transactional public void deleteClasseType() throws Exception { // Initialize the database classeTypeRepository.saveAndFlush(classeType); int databaseSizeBeforeDelete = classeTypeRepository.findAll().size(); // Get the classeType restClasseTypeMockMvc .perform( delete("/api/classeTypes/{id}", classeType.getId()) .accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<ClasseType> classeTypes = classeTypeRepository.findAll(); assertThat(classeTypes).hasSize(databaseSizeBeforeDelete - 1); } }