use of org.rembx.jeeshop.order.model.Order in project jeeshop by remibantos.
the class OrdersCT method findAll_whenClientHasUserRoleOnlyAndByStatus_shouldReturnOrdersWithMatchingStatus.
@Test
public void findAll_whenClientHasUserRoleOnlyAndByStatus_shouldReturnOrdersWithMatchingStatus() {
when(sessionContextMock.isUserInRole(JeeshopRoles.USER)).thenReturn(true);
when(sessionContextMock.isUserInRole(JeeshopRoles.ADMIN)).thenReturn(false);
when(sessionContextMock.getUserPrincipal()).thenReturn(new BasicUserPrincipal(testOrder.firstOrdersUser().getLogin()));
List<Order> orders = service.findAll(sessionContextMock, null, 0, 1, null, null, OrderStatus.PAYMENT_VALIDATED, null, null);
assertThat(orders).isNotEmpty();
assertThat(orders).containsExactly(testOrder.firstOrder());
}
use of org.rembx.jeeshop.order.model.Order in project jeeshop by remibantos.
the class OrdersCT method modifyUnknownCatalog_ShouldThrowNotFoundException.
@Test
public void modifyUnknownCatalog_ShouldThrowNotFoundException() {
Order detachedOrder = new Order();
detachedOrder.setId(9999L);
try {
service.modify(detachedOrder);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
use of org.rembx.jeeshop.order.model.Order in project jeeshop by remibantos.
the class OrdersCT method findAll_whenClientHasUserRoleOnlyAndwithPagination_shouldReturnNoneEmptyListPaginated.
@Test
public void findAll_whenClientHasUserRoleOnlyAndwithPagination_shouldReturnNoneEmptyListPaginated() {
when(sessionContextMock.isUserInRole(JeeshopRoles.USER)).thenReturn(true);
when(sessionContextMock.isUserInRole(JeeshopRoles.ADMIN)).thenReturn(false);
when(sessionContextMock.getUserPrincipal()).thenReturn(new BasicUserPrincipal(testOrder.firstOrdersUser().getLogin()));
List<Order> orders = service.findAll(sessionContextMock, null, 0, 1, null, null, null, null, null);
assertThat(orders).isNotEmpty();
assertThat(orders).containsExactly(testOrder.firstOrder());
}
use of org.rembx.jeeshop.order.model.Order in project jeeshop by remibantos.
the class OrdersCT method find_withEnhanceResult_shouldReturnEnhancedOrder.
@Test
public void find_withEnhanceResult_shouldReturnEnhancedOrder() throws Exception {
Order enhancedOrder = service.find(sessionContextMock, 1L, true);
assertThat(enhancedOrder).isEqualTo(testOrder.firstOrder());
assertThatOrderIsEnhanced(enhancedOrder);
}
use of org.rembx.jeeshop.order.model.Order in project jeeshop by remibantos.
the class OrdersCT method create_shouldThrowBadRequestWhenParametersHaveId.
@Test
public void create_shouldThrowBadRequestWhenParametersHaveId() throws Exception {
Address address = new Address("7 Rue des arbres", "Paris", "92800", "John", "Doe", "M.", null, "USA");
address.setId(777L);
OrderItem orderItemWithId = new OrderItem();
orderItemWithId.setId(777L);
Set<OrderItem> orderItems = Collections.singleton(orderItemWithId);
try {
Order order = new Order(null, address, new Address("7 Rue des arbres", "Paris", "92800", "John", "Doe", "M.", null, "USA"));
service.create(sessionContextMock, order, null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.BAD_REQUEST);
}
try {
Order order = new Order(null, new Address("7 Rue des arbres", "Paris", "92800", "John", "Doe", "M.", null, "USA"), address);
service.create(sessionContextMock, order, null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.BAD_REQUEST);
}
try {
Order order = new Order(orderItems, new Address("7 Rue des arbres", "Paris", "92800", "John", "Doe", "M.", null, "USA"), address);
service.create(sessionContextMock, order, null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.BAD_REQUEST);
}
}
Aggregations