@Test(expected = JpaObjectRetrievalFailureException.class) public void updateStorageUnknownInstance() { final QuoteStorageEditionVo vo = new QuoteStorageEditionVo(); vo.setSubscription(subscription); vo.setId(qsRepository.findByNameExpected("server1-root").getId()); vo.setName("server1-root-bis"); vo.setType("storage1"); vo.setQuoteInstance(-1); vo.setSize(1); sResource.update(vo); }
/** * test create service without a valid role. */ @Test(expected = JpaObjectRetrievalFailureException.class) public void testCreateNoRole() { final AuthorizationEditionVo authorization = new AuthorizationEditionVo(); authorization.setRole(-1); authorization.setPattern("any"); resource.create(authorization); }
/** * test update service without a valid role. */ @Test(expected = JpaObjectRetrievalFailureException.class) public void testUpdateNoRole() { final AuthorizationEditionVo authorization = new AuthorizationEditionVo(); authorization.setRole(-1); authorization.setPattern("pattern"); resource.update(authorizationId, authorization); }
@Test(expected = JpaObjectRetrievalFailureException.class) public void deleteAllExpectedFailed() { final SystemDialect systemDialect = repository.findAll().get(1); Assert.assertFalse(repository.findAll().isEmpty()); final List<Integer> list = new ArrayList<>(); list.add(systemDialect.getId()); list.add(-1); repository.deleteAllExpected(list); }
@Test public void should_getOne_retrieve_customers() throws InterruptedException { prepareTaskAs(() -> assertThat(catchExec(() -> repository.getOne(johnDoe.getId()))) .isInstanceOf(JpaObjectRetrievalFailureException.class), "Smith"); prepareTaskAs(() -> assertThat(repository.getOne(johnDoe.getId())).isEqualTo(johnDoe), "Doe"); prepareTaskAs(() -> assertThat(repository.getOne(aliceSmith.getId())).isEqualTo(aliceSmith), "Smith"); prepareTaskAs(() -> assertThat(catchExec(() -> repository.getOne(aliceSmith.getId()))) .isInstanceOf(JpaObjectRetrievalFailureException.class), "Doe"); waitForAssertions(); }
@Test(expected = JpaObjectRetrievalFailureException.class) public void deleteUnknown() { resource.delete(-1, false); }
@Test(expected = JpaObjectRetrievalFailureException.class) public void findStorageTypeNotExistsSubscription() { sResource.findType(-1, newUriInfo()); }
@Test(expected = JpaObjectRetrievalFailureException.class) public void findInstancePriceTermNotExistsSubscription() { iResource.findPriceTerm(-1, newUriInfo()); }
@Test(expected = JpaObjectRetrievalFailureException.class) public void findInstanceNotExistsSubscription() { iResource.findAll(-1, newUriInfo()); }
/** * Expected usage does not exist at all. */ @Test(expected = JpaObjectRetrievalFailureException.class) public void uploadInvalidUsage() throws IOException { iResource.upload(subscription, new ByteArrayInputStream("ANY;0.5;500;LINUX;any".getBytes("UTF-8")), new String[] { "name", "cpu", "ram", "os", "usage" }, "on-demand2", 1, "UTF-8"); }
/** * test {@link ContainerScopeResource#findById(int)} */ @Test(expected = JpaObjectRetrievalFailureException.class) public void findByIdInvalid() { Assert.assertNull(resource.findById(0)); }
@Override public Response toResponse(final JpaObjectRetrievalFailureException exception) { return toResponseNotFound(exception.getCause()); }
@DELETE @Path("jpaObjectRetrievalFailureException") public void throwJpaObjectRetrievalFailureException() { throw new JpaObjectRetrievalFailureException(new EntityNotFoundException("key")); }
/** * test find by id service. Id is not in database */ @Test(expected = JpaObjectRetrievalFailureException.class) public void testFindByIdNotFound() { resource.findById(-1); }
/** * test update service without a valid identifier. */ @Test(expected = JpaObjectRetrievalFailureException.class) public void testUpdateInvalidId() { resource.update(-1, null); }
@Test public void toResponse() { final JpaObjectRetrievalFailureException exception = new JpaObjectRetrievalFailureException(new EntityNotFoundException("key")); check(mock(new JpaObjectRetrievalFailureExceptionMapper()).toResponse(exception), 404, "{\"code\":\"entity\",\"message\":\"key\",\"parameters\":null,\"cause\":null}"); }
/** * Find one without expected result. */ @Test(expected = JpaObjectRetrievalFailureException.class) public void findOneExpectedError() { repository.findOneExpected(-1); }
/** * Find by name without expected result. */ @Test(expected = JpaObjectRetrievalFailureException.class) public void findByNameExpectedError() { roleRepository.findByNameExpected("any"); }
@Test(expected = JpaObjectRetrievalFailureException.class) public void deleteNoFetchError() { SystemDialect systemDialect = repository.findAll().get(1); repository.deleteNoFetch(systemDialect.getId()); repository.deleteNoFetch(systemDialect.getId()); }
@Test(expected = JpaObjectRetrievalFailureException.class) public void existExpectedFail() { repository.existExpected(-1); }
@Test public void testUploadInvalidSubscription() throws Exception { thrown.expect(JpaObjectRetrievalFailureException.class); resource.upload(new StringInputStream("id;"), ENCODING, -1, UploadMode.VALIDATION); }
@Test(expected = JpaObjectRetrievalFailureException.class) public void should_not_getOne_member_of_Doe_family_with_method_query() { assertThat(repository.getOne(johnDoe.getId())).isNull(); }