### Question:
PolicyV1Filter implements Filter { @Override public Promise<ResourceResponse, ResourceException> filterUpdate(Context context, UpdateRequest request, RequestHandler next) { try { final JsonValue jsonValue = request.getContent(); final Subject callingSubject = contextHelper.getSubject(context); final String realm = contextHelper.getRealm(context); retrieveResourceType(jsonValue, callingSubject, realm); } catch (EntitlementException eE) { debug.error("Error filtering policy create CREST request", eE); return resourceErrorHandler.handleError(context, request, eE).asPromise(); } catch (ResourceException rE) { debug.error("Error filtering policy create CREST request", rE); return rE.asPromise(); } return transform(next.handleUpdate(context, request)); } @Inject  PolicyV1Filter(final ApplicationServiceFactory applicationServiceFactory,
                          final ExceptionMappingHandler<EntitlementException, ResourceException> resourceErrorHandler,
                          final ContextHelper contextHelper,
                          @Named("frRest") final Debug debug); @Override Promise<ActionResponse, ResourceException> filterAction(Context context, ActionRequest request,
            RequestHandler next); @Override Promise<ResourceResponse, ResourceException> filterCreate(Context context, CreateRequest request,
            RequestHandler next); @Override Promise<ResourceResponse, ResourceException> filterUpdate(Context context, UpdateRequest request,
            RequestHandler next); @Override Promise<ResourceResponse, ResourceException> filterDelete(Context context, DeleteRequest request,
            RequestHandler next); @Override Promise<QueryResponse, ResourceException> filterQuery(final Context context,
            final QueryRequest request, final QueryResourceHandler handler, final RequestHandler next); @Override Promise<ResourceResponse, ResourceException> filterRead(Context context, ReadRequest request,
            RequestHandler next); @Override Promise<ResourceResponse, ResourceException> filterPatch(Context context, PatchRequest request,
            RequestHandler next);  }### Answer:
@Test public void resourceTypeAssociationOnUpdate() throws Exception { given(contextHelper.getRealm(context)).willReturn("/abc"); given(contextHelper.getSubject(context)).willReturn(subject); UpdateRequest updateRequest = mock(UpdateRequest.class); JsonValue jsonValue = json(object(field("applicationName", "testApp"))); given(updateRequest.getContent()).willReturn(jsonValue); given(applicationServiceFactory.create(subject, "/abc")).willReturn(applicationService); Application application = mock(Application.class); given(applicationService.getApplication("testApp")).willReturn(application); Set<String> resourceTypeUUIDs = new HashSet<>(CollectionUtils.asSet("abc-def-hij")); given(application.getResourceTypeUuids()).willReturn(resourceTypeUUIDs); Promise<ResourceResponse, ResourceException> promise = filter.filterUpdate(context, updateRequest, requestHandler); assertThat(promise).succeeded(); verify(applicationServiceFactory).create(subject, "/abc"); verify(applicationService).getApplication("testApp"); assertThat(jsonValue.get("resourceTypeUuid").asString()).isEqualTo("abc-def-hij"); assertThat(promise.get().getContent().contains("resourceTypeUuid")).isFalse(); }