FeatureResource { private Feature update(@PathParam("group") String group, Feature feature) { return featureService.updateFeature(group, feature.getKey(), feature) .orElseThrow(() -> new RuntimeException("")); } @Inject  FeatureResource(
      FeatureService featureService,
      GroupService groupService,
      IdempotencyChecker idempotencyChecker,
      AccessControlSupport accessControlSupport,
      ServerConfiguration serviceConfiguration,
      Headers headers
  ); @POST @Path("/{group}") @PermitAll @Timed(name = "registerFeature") Response registerFeature(
      @Auth AuthPrincipal principal,
      Feature feature,
      @Context HttpHeaders httpHeaders
  ); @POST @Path("/{group}/{feature_key}") @PermitAll @Timed(name = "updateFeature") Response updateFeature(
      @Auth AuthPrincipal principal,
      @PathParam("group") String group,
      @PathParam("feature_key") String featureKey,
      Feature feature,
      @Context HttpHeaders httpHeaders
  ); @GET @Path("/{group}/{feature_key}") @PermitAll @Timed(name = "getFeatureByKey") Response getFeatureByKey(
      @Auth AuthPrincipal principal,
      @PathParam("group") String group,
      @PathParam("feature_key") String featureKey
  ); @GET @Path("/{group}") @PermitAll @Timed(name = "getFeatures") Response getFeatures(
      @Auth AuthPrincipal principal,
      @PathParam("group") String group
  ); @GET @Path("/{group}/feed") @PermitAll @Timed(name = "getFeaturesSince") Response getFeaturesSince(
      @Auth AuthPrincipal principal,
      @PathParam("group") String group,
      @QueryParam("since") long since
  ); @POST @Path("/{group}/{feature_key}/namespaces") @PermitAll @Timed(name = "addNamespaceFeature") Response addNamespaceFeature(
      @Auth AuthPrincipal principal,
      @PathParam("group") String group,
      @PathParam("feature_key") String featureKey,
      NamespaceFeature namespaceFeature
  ); @POST @Path("/{group}/{feature_key}/namespaces/{namespace}") @PermitAll @Timed(name = "updateNamespaceFeature") Response updateNamespaceFeature(
      @Auth AuthPrincipal principal,
      @PathParam("group") String group,
      @PathParam("feature_key") String featureKey,
      @PathParam("namespace") String namespace,
      NamespaceFeature namespaceFeature
  ); @DELETE @Path("/{group}/{feature_key}/namespaces/{namespace}") @PermitAll @Timed(name = "removeNamespaceFeature") Response removeNamespaceFeature(
      @Auth AuthPrincipal principal,
      @PathParam("group") String group,
      @PathParam("feature_key") String featureKey,
      @PathParam("namespace") String namespace
  );  }
@Test public void testUpdate() throws Exception { JerseyClient client = createClient(); String featureKey = "testUpdateFeatureKey"; Feature feature = buildTestFeature(seedGroupOneKey, featureKey); String featureJson = Protobuf3Support.toJsonString(feature); String url = createFeatureUrl() + "/" + seedGroupOneKey; Response register = client.target(url) .request() .property(HTTP_AUTHENTICATION_BASIC_USERNAME, seedServiceOne + "/service") .property(HTTP_AUTHENTICATION_BASIC_PASSWORD, basicPassword) .post(Entity.entity(featureJson, MediaType.APPLICATION_JSON_TYPE)); assertTrue(register.getStatus() == 201); String jsonRegister = register.readEntity(String.class); Feature.Builder builderRegister = Feature.newBuilder(); JsonFormat.parser().merge(jsonRegister, builderRegister); String id = builderRegister.getId(); String created = builderRegister.getCreated(); String updated = builderRegister.getUpdated(); Status state = builderRegister.getStatus(); assertNotNull(id); assertNotNull(updated); assertNotNull(created); assertEquals(Status.off, state); Feature update = builderRegister.build().toBuilder().setStatus(Status.on).build(); String featureUpdateJson = Protobuf3Support.toJsonString(update); Response responseUpdate = client.target(url + "/" + featureKey) .request() .property(HTTP_AUTHENTICATION_BASIC_USERNAME, seedMemberOne + "/member") .property(HTTP_AUTHENTICATION_BASIC_PASSWORD, basicPassword) .post(Entity.entity(featureUpdateJson, MediaType.APPLICATION_JSON_TYPE)); assertTrue(responseUpdate.getStatus() == 200); String jsonUpdateResult = responseUpdate.readEntity(String.class); Feature.Builder builderUpdated = Feature.newBuilder(); JsonFormat.parser().merge(jsonUpdateResult, builderUpdated); assertEquals(id, builderUpdated.getId()); assertNotEquals(updated, builderUpdated.getUpdated()); assertEquals(created, builderUpdated.getCreated()); assertEquals(Status.on, builderUpdated.getStatus()); Response responseGet = client.target(url + "/" + featureKey) .request() .property(HTTP_AUTHENTICATION_BASIC_USERNAME, seedServiceOne + "/service") .property(HTTP_AUTHENTICATION_BASIC_PASSWORD, basicPassword) .get(); String jsonResponseGet = responseGet.readEntity(String.class); Feature.Builder responseGetBuilder = Feature.newBuilder(); JsonFormat.parser().merge(jsonResponseGet, responseGetBuilder); Feature featResponseGet = responseGetBuilder.build(); assertEquals(id, featResponseGet.getId()); assertEquals(id, featResponseGet.getId()); assertNotEquals(updated, featResponseGet.getUpdated()); assertEquals(builderUpdated.getUpdated(), featResponseGet.getUpdated()); assertEquals(created, featResponseGet.getCreated()); assertEquals(Status.on, featResponseGet.getStatus()); }