@Test @Transactional public void deleteBuilding() throws Exception { // Initialize the database buildingRepository.saveAndFlush(building); int databaseSizeBeforeDelete = buildingRepository.findAll().size(); // Get the building restBuildingMockMvc .perform( delete("/api/buildings/{id}", building.getId()).accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<Building> buildings = buildingRepository.findAll(); assertThat(buildings).hasSize(databaseSizeBeforeDelete - 1); }
@Test @Transactional public void createBuilding() throws Exception { int databaseSizeBeforeCreate = buildingRepository.findAll().size(); // Create the Building restBuildingMockMvc .perform( post("/api/buildings") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(building))) .andExpect(status().isCreated()); // Validate the Building in the database List<Building> buildings = buildingRepository.findAll(); assertThat(buildings).hasSize(databaseSizeBeforeCreate + 1); Building testBuilding = buildings.get(buildings.size() - 1); assertThat(testBuilding.getName()).isEqualTo(DEFAULT_NAME); }
@Test @Transactional public void getAllBuildings() throws Exception { // Initialize the database buildingRepository.saveAndFlush(building); // Get all the buildings restBuildingMockMvc .perform(get("/api/buildings?sort=id,desc")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.[*].id").value(hasItem(building.getId().intValue()))) .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME.toString()))); }
@Test @Transactional public void updateBuilding() throws Exception { // Initialize the database buildingRepository.saveAndFlush(building); int databaseSizeBeforeUpdate = buildingRepository.findAll().size(); // Update the building building.setName(UPDATED_NAME); restBuildingMockMvc .perform( put("/api/buildings") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(building))) .andExpect(status().isOk()); // Validate the Building in the database List<Building> buildings = buildingRepository.findAll(); assertThat(buildings).hasSize(databaseSizeBeforeUpdate); Building testBuilding = buildings.get(buildings.size() - 1); assertThat(testBuilding.getName()).isEqualTo(UPDATED_NAME); }