@Test public void testPUTWithCustomerIdInvalidVisibility() throws PersistenceException { final String PERSISTED_CUSTOMER = "customerA"; final String UPDATED_CUSTOMER = "customerB"; request.setId(URL_ID); SimpleObject persistedSimpleObject = new SimpleObject(); persistedSimpleObject.setCustomerId(PERSISTED_CUSTOMER); SimpleObject updatedSimpleObject = new SimpleObject(); updatedSimpleObject.setCustomerId(UPDATED_CUSTOMER); request.setDataObject(updatedSimpleObject); doReturn(persistedSimpleObject).when(mockObjectPersister).retrieve(anyString()); doAnswer(new Answer() { private int visibilityCallCount = 0; @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { boolean returnValue = visibilityCallCount == 0; visibilityCallCount++; return returnValue; } }).when(mockVisibilityFilter).isVisible(any(), any()); DataObjectResponse<SimpleObject> response = processor.handlePUT(request); Assert.assertTrue(response.isError()); Assert.assertEquals(response.getErrorResponse().getTitle(), "UnauthorizedException"); verify(mockVisibilityFilter, times(2)).isVisible(any(), any()); }
@Override public DataObjectResponse<T> handlePUT(DataObjectRequest<T> request) { return handlePUT(request, null); }
DataObjectRequestProcessor implements RequestProcessor<DataObjectResponse<T>, DataObjectRequest<T>> { @Override public DataObjectResponse<T> handlePUT(DataObjectRequest<T> request) { return handlePUT(request, null); } }
DataObjectRequestProcessor implements RequestProcessor<DataObjectResponse<T>, DataObjectRequest<T>> { @Override public DataObjectResponse<T> handlePUT(DataObjectRequest<T> request) { return handlePUT(request, null); } DataObjectRequestProcessor(ObjectPersister<T> objectPersister, DataObjectValidator<T, DataObjectRequest<T>> validator);  DataObjectRequestProcessor(ObjectPersister<T> objectPersister); }
DataObjectRequestProcessor implements RequestProcessor<DataObjectResponse<T>, DataObjectRequest<T>> { @Override public DataObjectResponse<T> handlePUT(DataObjectRequest<T> request) { return handlePUT(request, null); } DataObjectRequestProcessor(ObjectPersister<T> objectPersister, DataObjectValidator<T, DataObjectRequest<T>> validator);  DataObjectRequestProcessor(ObjectPersister<T> objectPersister); @Override DataObjectResponse<T> handleGET(DataObjectRequest<T> request); @Override DataObjectResponse<T> handlePOST(DataObjectRequest<T> request); @Override DataObjectResponse<T> handlePUT(DataObjectRequest<T> request); DataObjectResponse<T> handlePUT(DataObjectRequest<T> request, T previouslyRetrievedObject); @Override DataObjectResponse<T> handleDELETE(DataObjectRequest<T> request); DataObjectRequestProcessor<T> setVisibilityFilterMap(
        VisibilityFilterMap<T, DataObjectRequest<T>> map); DataObjectRequestProcessor<T> setVisibilityFilter(VisibilityMethod method,
        VisibilityFilter<T, DataObjectRequest<T>> filter); RequestValidator<DataObjectRequest<T>> getRequestValidator(); void setRequestValidator(RequestValidator<DataObjectRequest<T>> requestValidator); ObjectPersister<T> getObjectPersister(); }
DataObjectRequestProcessor implements RequestProcessor<DataObjectResponse<T>, DataObjectRequest<T>> { @Override public DataObjectResponse<T> handlePUT(DataObjectRequest<T> request) { return handlePUT(request, null); } DataObjectRequestProcessor(ObjectPersister<T> objectPersister, DataObjectValidator<T, DataObjectRequest<T>> validator);  DataObjectRequestProcessor(ObjectPersister<T> objectPersister); @Override DataObjectResponse<T> handleGET(DataObjectRequest<T> request); @Override DataObjectResponse<T> handlePOST(DataObjectRequest<T> request); @Override DataObjectResponse<T> handlePUT(DataObjectRequest<T> request); DataObjectResponse<T> handlePUT(DataObjectRequest<T> request, T previouslyRetrievedObject); @Override DataObjectResponse<T> handleDELETE(DataObjectRequest<T> request); DataObjectRequestProcessor<T> setVisibilityFilterMap(
        VisibilityFilterMap<T, DataObjectRequest<T>> map); DataObjectRequestProcessor<T> setVisibilityFilter(VisibilityMethod method,
        VisibilityFilter<T, DataObjectRequest<T>> filter); RequestValidator<DataObjectRequest<T>> getRequestValidator(); void setRequestValidator(RequestValidator<DataObjectRequest<T>> requestValidator); ObjectPersister<T> getObjectPersister(); static final String OBJECT_NOT_FOUND_EXCEPTION; static final String AUTHORIZATION_EXCEPTION; static final String UNABLE_TO_CREATE_EXCEPTION; static final String UNABLE_TO_UPDATE_EXCEPTION; static final String UNABLE_TO_DELETE_EXCEPTION; }