use of lombok.SneakyThrows in project task-book by Lunigorn.
the class TaskControllerTests method taskDeleteByIdSucces.
@Test
@SneakyThrows({ Exception.class })
public void taskDeleteByIdSucces() {
// arrange
Task task = new Task();
String randomName = RandomStringUtils.randomAlphabetic(10);
task.setName(randomName);
tasks.save(task);
Task foundBeforeDelete = tasks.findOne(task.getId());
assertNotNull(foundBeforeDelete);
// act
mockMvc.perform(delete("/tasks/" + task.getId()).contentType(contentType)).andDo(print()).andExpect(status().is2xxSuccessful()).andExpect(jsonPath("$.id", is(task.getId().intValue()))).andExpect(jsonPath("$.name", is(task.getName())));
Task foundAfterDelete = tasks.findOne(task.getId());
assertNull(foundAfterDelete);
}
use of lombok.SneakyThrows in project task-book by Lunigorn.
the class TaskControllerTests method taskGetByIdSucces.
@Test
@SneakyThrows({ Exception.class })
public void taskGetByIdSucces() {
// arrange
Task task = new Task();
String randomName = RandomStringUtils.randomAlphabetic(10);
task.setName(randomName);
tasks.save(task);
// act
mockMvc.perform(get("/tasks/" + task.getId()).contentType(contentType)).andDo(print()).andExpect(status().is2xxSuccessful()).andExpect(jsonPath("$.id", is(task.getId().intValue()))).andExpect(jsonPath("$.name", is(task.getName())));
}
use of lombok.SneakyThrows in project task-book by Lunigorn.
the class TaskControllerTests method taskInsertSucces.
@Test
@SneakyThrows({ Exception.class })
public void taskInsertSucces() {
// arrange
String randomName = RandomStringUtils.randomAlphabetic(10);
// act
MvcResult result = mockMvc.perform(post("/tasks/").content("{\"name\":\"" + randomName + "\"}").contentType(contentType)).andDo(print()).andExpect(status().is2xxSuccessful()).andExpect(jsonPath("$.id", anything())).andExpect(jsonPath("$.name", is(randomName))).andReturn();
String responseText = result.getResponse().getContentAsString();
// assert returned task has id
Integer savedTaskId = JsonPath.read(responseText, "$.id");
assertNotNull(savedTaskId);
// assert returned task is saved in database
Task savedTask = tasks.findOne(savedTaskId.longValue());
assertEquals(savedTask.getName(), randomName);
}
use of lombok.SneakyThrows in project task-book by Lunigorn.
the class TaskControllerTests method taskInsertWithIdFail.
@Test
@SneakyThrows({ Exception.class })
public void taskInsertWithIdFail() {
// arrange
Integer randomId = new Random().nextInt();
String randomName = RandomStringUtils.randomAlphabetic(10);
Task foundByRandomId = tasks.findOne(randomId.longValue());
if (foundByRandomId != null)
assertNotEquals(randomName, foundByRandomId.getName());
// act
MvcResult result = mockMvc.perform(post("/tasks/").content("{\"id\":\"" + randomId + "\",\"name\":\"" + randomName + "\"}").contentType(contentType)).andDo(print()).andExpect(status().isBadRequest()).andReturn();
Task foundByRandomIdAfterError = tasks.findOne(randomId.longValue());
assertEquals(foundByRandomId, foundByRandomIdAfterError);
}
use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityServiceBeanTest method testGetVesselDetailsAndContactPartiesForFishingTrip.
@Test
@SneakyThrows
public void testGetVesselDetailsAndContactPartiesForFishingTrip() {
Map<String, List<String>> returnMap = new HashMap<>();
returnMap.put("code", new ArrayList<String>());
when(vesselTransportMeansDao.findLatestVesselByTripId("NOR-TRP-20160517234053706")).thenReturn(new VesselTransportMeansEntity());
when(mdrModuleServiceBean.getAcronymFromMdr("FLUX_VESSEL_ID_TYPE", "*", new ArrayList<String>(), 9999999, "code")).thenReturn(returnMap);
VesselDetailsDTO vesselDetailsDTO = fishingTripService.getVesselDetailsForFishingTrip("NOR-TRP-20160517234053706");
assertNotNull(vesselDetailsDTO);
}
Aggregations