@Test
public void createADeliveryThatAlreadyExist(){

    final DbProduct product = new DbProduct();
    product.setName("product1");
    
    Delivery delivery = new Delivery();
    delivery.setCommercialName("delivery1");
    delivery.setCommercialVersion("1.0.0");        
    delivery.setVersion("1.0.0-1");
    delivery.setJenkinsBuildUrl("http://localhost:8080/job/20");
    product.getDeliveries().add(delivery);
    // creating a dummy product in storage with delivery
    when(repositoryHandler.getProduct(product.getName())).thenReturn(product);
    client().addFilter(new HTTPBasicAuthFilter(GrapesTestUtils.USER_4TEST, GrapesTestUtils.PASSWORD_4TEST));
    WebResource resource = client().resource("/" + ServerAPI.PRODUCT_RESOURCE + "/" + product.getName() + ServerAPI.GET_DELIVERIES);
    ClientResponse response = resource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, delivery);
    
    // checks
    assertNotNull(response);
    assertEquals(HttpStatus.CONFLICT_409, response.getStatus());
}