From 7a59e815edfc2eb3406345327a4d9bd2e630e304 Mon Sep 17 00:00:00 2001 From: ananjaykumar2 Date: Wed, 22 Nov 2023 14:30:30 +0530 Subject: [PATCH 1/3] modified append subscription & subscription auditing flow --- .../server/apiserver/ApiServerVerticle.java | 156 +++++++++--------- .../subscription/SubscriptionService.java | 97 ++++++++--- .../server/apiserver/util/Constants.java | 13 +- .../subscription/SubscriptionServiceTest.java | 4 +- 4 files changed, 166 insertions(+), 104 deletions(-) diff --git a/src/main/java/iudx/resource/server/apiserver/ApiServerVerticle.java b/src/main/java/iudx/resource/server/apiserver/ApiServerVerticle.java index 42cd19f10..f6c84cc6d 100644 --- a/src/main/java/iudx/resource/server/apiserver/ApiServerVerticle.java +++ b/src/main/java/iudx/resource/server/apiserver/ApiServerVerticle.java @@ -1,27 +1,85 @@ package iudx.resource.server.apiserver; import static iudx.resource.server.apiserver.response.ResponseUtil.generateResponse; -import static iudx.resource.server.apiserver.util.Constants.*; +import static iudx.resource.server.apiserver.util.Constants.ADMIN; import static iudx.resource.server.apiserver.util.Constants.API; +import static iudx.resource.server.apiserver.util.Constants.API_ENDPOINT; +import static iudx.resource.server.apiserver.util.Constants.APPLICATION_JSON; +import static iudx.resource.server.apiserver.util.Constants.CONTENT_TYPE; +import static iudx.resource.server.apiserver.util.Constants.DID; +import static iudx.resource.server.apiserver.util.Constants.DRL; +import static iudx.resource.server.apiserver.util.Constants.ENCODED_CIPHER_TEXT; +import static iudx.resource.server.apiserver.util.Constants.ENCODED_KEY; +import static iudx.resource.server.apiserver.util.Constants.ENCRYPTED_DATA; +import static iudx.resource.server.apiserver.util.Constants.ENDT; import static iudx.resource.server.apiserver.util.Constants.ENTITY_QUERY; +import static iudx.resource.server.apiserver.util.Constants.HEADER_ACCEPT; +import static iudx.resource.server.apiserver.util.Constants.HEADER_ALLOW_ORIGIN; +import static iudx.resource.server.apiserver.util.Constants.HEADER_CONTENT_LENGTH; +import static iudx.resource.server.apiserver.util.Constants.HEADER_CONTENT_TYPE; +import static iudx.resource.server.apiserver.util.Constants.HEADER_HOST; +import static iudx.resource.server.apiserver.util.Constants.HEADER_OPTIONS; +import static iudx.resource.server.apiserver.util.Constants.HEADER_ORIGIN; +import static iudx.resource.server.apiserver.util.Constants.HEADER_PUBLIC_KEY; +import static iudx.resource.server.apiserver.util.Constants.HEADER_REFERER; +import static iudx.resource.server.apiserver.util.Constants.HEADER_RESPONSE_FILE_FORMAT; +import static iudx.resource.server.apiserver.util.Constants.HEADER_TOKEN; import static iudx.resource.server.apiserver.util.Constants.ID; import static iudx.resource.server.apiserver.util.Constants.IID; +import static iudx.resource.server.apiserver.util.Constants.IUDXQUERY_OPTIONS; +import static iudx.resource.server.apiserver.util.Constants.JSON_ALIAS; +import static iudx.resource.server.apiserver.util.Constants.JSON_CONSUMER; +import static iudx.resource.server.apiserver.util.Constants.JSON_COUNT; +import static iudx.resource.server.apiserver.util.Constants.JSON_ID; +import static iudx.resource.server.apiserver.util.Constants.JSON_INSTANCEID; +import static iudx.resource.server.apiserver.util.Constants.JSON_NAME; +import static iudx.resource.server.apiserver.util.Constants.JSON_SEARCH_TYPE; +import static iudx.resource.server.apiserver.util.Constants.JSON_TITLE; +import static iudx.resource.server.apiserver.util.Constants.JSON_TYPE; +import static iudx.resource.server.apiserver.util.Constants.LIMITPARAM; +import static iudx.resource.server.apiserver.util.Constants.MIME_APPLICATION_JSON; +import static iudx.resource.server.apiserver.util.Constants.MIME_TEXT_HTML; +import static iudx.resource.server.apiserver.util.Constants.MSG_INVALID_NAME; +import static iudx.resource.server.apiserver.util.Constants.MSG_SUB_TYPE_NOT_FOUND; +import static iudx.resource.server.apiserver.util.Constants.NO_CONTENT; +import static iudx.resource.server.apiserver.util.Constants.OFFSETPARAM; +import static iudx.resource.server.apiserver.util.Constants.RESET_PWD; +import static iudx.resource.server.apiserver.util.Constants.RESOURCE_GROUP; +import static iudx.resource.server.apiserver.util.Constants.RESPONSE_SIZE; +import static iudx.resource.server.apiserver.util.Constants.ROUTE_DOC; +import static iudx.resource.server.apiserver.util.Constants.ROUTE_STATIC_SPEC; +import static iudx.resource.server.apiserver.util.Constants.STARTT; +import static iudx.resource.server.apiserver.util.Constants.SUBSCRIPTION_ID; +import static iudx.resource.server.apiserver.util.Constants.SUB_TYPE; import static iudx.resource.server.apiserver.util.Constants.USER_ID; import static iudx.resource.server.apiserver.util.Util.errorResponse; import static iudx.resource.server.authenticator.Constants.ROLE; import static iudx.resource.server.cache.cachelmpl.CacheType.CATALOGUE_CACHE; -import static iudx.resource.server.common.Constants.*; +import static iudx.resource.server.common.Constants.CACHE_SERVICE_ADDRESS; +import static iudx.resource.server.common.Constants.PG_SERVICE_ADDRESS; import static iudx.resource.server.common.HttpStatusCode.BAD_REQUEST; import static iudx.resource.server.common.HttpStatusCode.NOT_FOUND; import static iudx.resource.server.common.HttpStatusCode.UNAUTHORIZED; -import static iudx.resource.server.common.ResponseUrn.*; +import static iudx.resource.server.common.ResponseUrn.BACKING_SERVICE_FORMAT_URN; +import static iudx.resource.server.common.ResponseUrn.INVALID_PARAM_URN; +import static iudx.resource.server.common.ResponseUrn.INVALID_TEMPORAL_PARAM_URN; +import static iudx.resource.server.common.ResponseUrn.MISSING_TOKEN_URN; +import static iudx.resource.server.common.ResponseUrn.RESOURCE_NOT_FOUND_URN; +import static iudx.resource.server.common.ResponseUrn.YET_NOT_IMPLEMENTED_URN; +import static iudx.resource.server.common.ResponseUrn.fromCode; import static iudx.resource.server.database.archives.Constants.ITEM_TYPES; -import static iudx.resource.server.databroker.util.Constants.ENTITIES; -import static iudx.resource.server.metering.util.Constants.*; +import static iudx.resource.server.metering.util.Constants.DELEGATOR_ID; +import static iudx.resource.server.metering.util.Constants.EPOCH_TIME; +import static iudx.resource.server.metering.util.Constants.ISO_TIME; +import static iudx.resource.server.metering.util.Constants.PROVIDER_ID; +import static iudx.resource.server.metering.util.Constants.TYPE_KEY; import io.netty.handler.codec.http.HttpConstants; import io.netty.handler.codec.http.QueryStringDecoder; -import io.vertx.core.*; +import io.vertx.core.AbstractVerticle; +import io.vertx.core.Future; +import io.vertx.core.MultiMap; +import io.vertx.core.Promise; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; @@ -81,6 +139,7 @@ *

The API Server verticle implements the IUDX Resource Server APIs. It handles the API requests * from the clients and interacts with the associated Service to respond. * + * @version 1.0 * @see io.vertx.core.Vertx * @see io.vertx.core.AbstractVerticle * @see io.vertx.core.http.HttpServer @@ -88,14 +147,15 @@ * @see io.vertx.servicediscovery.ServiceDiscovery * @see io.vertx.servicediscovery.types.EventBusService * @see io.vertx.spi.cluster.hazelcast.HazelcastClusterManager - * @version 1.0 * @since 2020-05-31 */ public class ApiServerVerticle extends AbstractVerticle { private static final Logger LOGGER = LogManager.getLogger(ApiServerVerticle.class); - /** Service addresses */ + /** + * Service addresses + */ private static final String DATABASE_SERVICE_ADDRESS = "iudx.rs.database.service"; private static final String BROKER_SERVICE_ADDRESS = "iudx.rs.broker.service"; @@ -768,7 +828,7 @@ public void handlePostEntitiesQuery(RoutingContext routingContext) { /** * Execute a count query in DB * - * @param json valid json query + * @param json valid json query * @param response HttpServerResponse */ private void executeCountQuery( @@ -813,7 +873,7 @@ private void executeCountQuery( /** * Execute a search query in DB * - * @param json valid json query + * @param json valid json query * @param response HttpServerResponse */ private void executeSearchQuery( @@ -1024,18 +1084,8 @@ private void handleSubscriptions(RoutingContext routingContext) { subHandler -> { if (subHandler.succeeded()) { LOGGER.info("Success: Handle Subscription request;"); - JsonObject object =subHandler.result().getJsonArray("results").getJsonObject(0); routingContext.data().put(RESPONSE_SIZE, 0); - - JsonObject message = - new JsonObject() - .put(JSON_EVENT_TYPE, EVENTTYPE_CREATED) - .put(USER_ID, jsonObj.getString(USER_ID)) - .put(SUBSCRIPTION_ID, object.getString(ID)) - .put(SUB_TYPE, subscriptionType) - .put("resource", jsonObj.getJsonArray(ENTITIES).getString(0)); - - Future.future(fu -> updateAuditTable(message)); + Future.future(fu -> updateAuditTable(routingContext)); handleSuccessResponse( response, ResponseType.Created.getCode(), subHandler.result().toString()); } else { @@ -1081,23 +1131,24 @@ private void appendSubscription(RoutingContext routingContext) { JsonObject jsonObj = requestJson.copy(); jsonObj.put(USER_ID, authInfo.getString(USER_ID)); Future subsReq = - subsService.appendSubscription(jsonObj, databroker, postgresService, authInfo); + subsService.appendSubscription(jsonObj, databroker, postgresService, authInfo, + cacheService); subsReq.onComplete( subsRequestHandler -> { if (subsRequestHandler.succeeded()) { LOGGER.debug("Success: Appending subscription"); routingContext.data().put(RESPONSE_SIZE, 0); - JsonObject message = + /*JsonObject message = new JsonObject() .put("resource", jsonObj.getJsonArray(ENTITIES).getString(0)) .put(SUBSCRIPTION_ID, jsonObj.getString(SUBSCRIPTION_ID)) .put(SUB_TYPE, jsonObj.getString(SUB_TYPE)) .put(USER_ID, jsonObj.getString(USER_ID)) .put(SUBSCRIPTION_ID, subsId) - .put(JSON_EVENT_TYPE, EVENTTYPE_APPEND); + .put(JSON_EVENT_TYPE, EVENTTYPE_APPEND);*/ - Future.future(fu -> updateAuditTable(message)); + Future.future(fu -> updateAuditTable(routingContext)); handleSuccessResponse( response, ResponseType.Created.getCode(), @@ -1147,17 +1198,7 @@ private void updateSubscription(RoutingContext routingContext) { if (subsRequestHandler.succeeded()) { LOGGER.info("result : " + subsRequestHandler.result()); routingContext.data().put(RESPONSE_SIZE, 0); - - JsonObject message = - new JsonObject() - .put("resource", jsonObj.getJsonArray(ENTITIES).getString(0)) - .put(SUB_TYPE, subscriptionType) - .put(SUBSCRIPTION_ID, jsonObj.getString(SUBSCRIPTION_ID)) - .put(USER_ID, jsonObj.getString(USER_ID)) - .put(SUBSCRIPTION_ID, subsId) - .put(JSON_EVENT_TYPE, EVENTTYPE_UPDATE); - - Future.future(fu -> updateAuditTable(message)); + Future.future(fu -> updateAuditTable(routingContext)); handleSuccessResponse( response, ResponseType.Created.getCode(), subsRequestHandler.result().toString()); } else { @@ -1294,15 +1335,7 @@ private void deleteSubscription(RoutingContext routingContext) { subHandler -> { if (subHandler.succeeded()) { routingContext.data().put(RESPONSE_SIZE, 0); - - JsonObject message = - new JsonObject() - .put(SUBSCRIPTION_ID, jsonObj.getString(SUBSCRIPTION_ID)) - .put(USER_ID, jsonObj.getString(USER_ID)) - .put(SUB_TYPE, jsonObj.getString(SUB_TYPE)) - .put(JSON_EVENT_TYPE, EVENTTYPE_DELETED); - - Future.future(fu -> updateAuditTable(message)); + Future.future(fu -> updateAuditTable(routingContext)); handleSuccessResponse( response, ResponseType.Ok.getCode(), subHandler.result().toString()); } else { @@ -1421,7 +1454,7 @@ public void getAdapterDetails(RoutingContext routingContext) { * publish heartbeat details to Rabbit MQ. * * @param routingContext routingContext Note: This is too frequent an operation to have info or - * error level logs + * error level logs */ public void publishHeartbeat(RoutingContext routingContext) { LOGGER.trace("Info: publishHeartbeat method starts;"); @@ -1544,9 +1577,9 @@ private void getAllAdaptersForUsers(RoutingContext routingContext) { /** * handle HTTP response. * - * @param response HttpServerResponse object + * @param response HttpServerResponse object * @param statusCode Http status code for response - * @param result String of response + * @param result String of response */ private void handleSuccessResponse(HttpServerResponse response, int statusCode, String result) { response.putHeader(CONTENT_TYPE, APPLICATION_JSON).setStatusCode(statusCode).end(result); @@ -1593,7 +1626,7 @@ private void handleResponse( * part of the parameter. * * @param routingContext RoutingContext Object - * @param response HttpServerResponse + * @param response HttpServerResponse * @return Optional Optional of Map */ private Optional getQueryParams( @@ -1688,31 +1721,6 @@ private Future updateAuditTable(RoutingContext context) { return promise.future(); } - /** - * Sends the message from Subscription APIs to Auditing Server by sending messages to RMQ Exchange - * named auditing and by adding origin field in the message for subscription related further - * processing in the auditing server - * - * @param message JsonObject message to be sent to the exchange - * @return Future object - */ - private Future updateAuditTable(JsonObject message) { - message.put(ORIGIN, ORIGIN_SERVER_SUBSCRIPTION); - Promise promise = Promise.promise(); - meteringService.insertMeteringValuesInRmq( - message, - handler -> { - if (handler.succeeded()) { - LOGGER.info("message published in RMQ."); - promise.complete(); - } else { - LOGGER.error("failed to publish message in RMQ."); - promise.complete(); - } - }); - return promise.future(); - } - private Future getEntityName(JsonObject request) { Promise promise = Promise.promise(); String getEntityNameQuery = ENTITY_QUERY.replace("$0", request.getString(SUBSCRIPTION_ID)); diff --git a/src/main/java/iudx/resource/server/apiserver/subscription/SubscriptionService.java b/src/main/java/iudx/resource/server/apiserver/subscription/SubscriptionService.java index 971e88c70..8ea4fe45a 100644 --- a/src/main/java/iudx/resource/server/apiserver/subscription/SubscriptionService.java +++ b/src/main/java/iudx/resource/server/apiserver/subscription/SubscriptionService.java @@ -2,8 +2,11 @@ import static iudx.resource.server.apiserver.util.Constants.*; import static iudx.resource.server.apiserver.util.Constants.SUBSCRIPTION_ID; +import static iudx.resource.server.authenticator.Constants.ROLE; import static iudx.resource.server.cache.cachelmpl.CacheType.CATALOGUE_CACHE; import static iudx.resource.server.databroker.util.Constants.*; +import static iudx.resource.server.metering.util.Constants.DELEGATOR_ID; +import static iudx.resource.server.metering.util.Constants.PROVIDER_ID; import static org.junit.jupiter.api.Assertions.assertNotNull; import io.vertx.core.Future; @@ -82,6 +85,18 @@ public Future createSubscription( .onSuccess( cacheResult -> { LOGGER.debug("cacheResult: " + cacheResult); + + String role = authInfo.getString(ROLE); + String drl = authInfo.getString(DRL); + String delegatorId; + if (role.equalsIgnoreCase("delegate") && drl != null) { + delegatorId = authInfo.getString(DID); + } else { + delegatorId = authInfo.getString("userid"); + } + String type = + cacheResult.containsKey(RESOURCE_GROUP) ? "RESOURCE" : + "RESOURCE_GROUP"; StringBuilder query = new StringBuilder( CREATE_SUB_SQL @@ -92,7 +107,11 @@ public Future createSubscription( .replace("$5", authInfo.getString("expiry")) .replace("$6", cacheResult.getString("name")) .replace("$7", cacheResult.toString()) - .replace("$8", authInfo.getString("userid"))); + .replace("$8", authInfo.getString("userid")) + .replace("$9", cacheResult.getString(RESOURCE_GROUP)) + .replace("$a", cacheResult.getString("provider")) + .replace("$b", delegatorId) + .replace("$c", type)); LOGGER.debug("query: " + query); pgService.executeQuery( @@ -301,7 +320,8 @@ public Future appendSubscription( JsonObject json, DataBrokerService databroker, PostgresService pgService, - JsonObject authInfo) { + JsonObject authInfo, + CacheService cacheService) { LOGGER.info("appendSubscription() method started"); Promise promise = Promise.promise(); SubsType subType = SubsType.valueOf(json.getString(SUB_TYPE)); @@ -316,34 +336,65 @@ public Future appendSubscription( if (handler.succeeded()) { JsonObject response = handler.result(); JsonObject brokerSubResult = response.getJsonArray("results").getJsonObject(0); - StringBuilder query = - new StringBuilder( - APPEND_SUB_SQL - .replace("$1", json.getString(SUBSCRIPTION_ID)) - .replace("$2", subType.type) - .replace("$3", json.getString(SUBSCRIPTION_ID)) - .replace("$4", json.getJsonArray("entities").getString(0)) - .replace("$5", authInfo.getString("expiry"))); + JsonObject cacheJson = + new JsonObject() + .put("key", json.getJsonArray("entities").getString(0)) + .put("type", CATALOGUE_CACHE); + cacheService + .get(cacheJson).onSuccess( + cacheResult -> { + String role = authInfo.getString(ROLE); + String drl = authInfo.getString(DRL); + String delegatorId; + if (role.equalsIgnoreCase("delegate") && drl != null) { + delegatorId = authInfo.getString(DID); + } else { + delegatorId = authInfo.getString("userid"); + } + String type = + cacheResult.containsKey(RESOURCE_GROUP) ? "RESOURCE" : "RESOURCE_GROUP"; - LOGGER.debug(query); - pgService.executeQuery( - query.toString(), - pgHandler -> { - if (pgHandler.succeeded()) { - promise.complete(brokerSubResult); - } else { - // TODO : rollback mechanism in case of pg error [to unbind/delete created - // sub] - JsonObject res = new JsonObject(pgHandler.cause().getMessage()); - promise.fail(generateResponse(res).toString()); - } - }); + StringBuilder query = + new StringBuilder( + APPEND_SUB_SQL + .replace("$1", json.getString(SUBSCRIPTION_ID)) + .replace("$2", subType.type) + .replace("$3", json.getString(SUBSCRIPTION_ID)) + .replace("$4", json.getJsonArray("entities").getString(0)) + .replace("$5", authInfo.getString("expiry")) + .replace("$6", cacheResult.getString("name")) + .replace("$7", cacheResult.toString()) + .replace("$8", authInfo.getString("userid")) + .replace("$9", cacheResult.getString(RESOURCE_GROUP)) + .replace("$a", cacheResult.getString("provider")) + .replace("$b", delegatorId) + .replace("$c", type)); + LOGGER.debug(query); + pgService.executeQuery( + query.toString(), + pgHandler -> { + if (pgHandler.succeeded()) { + promise.complete(brokerSubResult); + } else { + // TODO : rollback mechanism in case of pg error [to unbind/delete created + // sub] + JsonObject res = new JsonObject(pgHandler.cause().getMessage()); + promise.fail(generateResponse(res).toString()); + } + }); + + }) + .onFailure( + failed -> LOGGER.error(failed.getCause() + )); } else { JsonObject res = new JsonObject(handler.cause().getMessage()); promise.fail(generateResponse(res).toString()); } }); + return promise.future(); + } private JsonObject generateResponse(JsonObject response) { diff --git a/src/main/java/iudx/resource/server/apiserver/util/Constants.java b/src/main/java/iudx/resource/server/apiserver/util/Constants.java index 6686e26ea..4a7f1c638 100644 --- a/src/main/java/iudx/resource/server/apiserver/util/Constants.java +++ b/src/main/java/iudx/resource/server/apiserver/util/Constants.java @@ -280,16 +280,19 @@ public class Constants { // subscriptions queries public static final String CREATE_SUB_SQL = - "INSERT INTO " - + "subscriptions(_id,_type,queue_name,entity,expiry,dataset_name,dataset_json,user_id) " - + "VALUES('$1','$2','$3','$4','$5','$6','$7','$8')"; + "INSERT INTO subscriptions" + + "(_id,_type,queue_name,entity,expiry,dataset_name,dataset_json,user_id," + + "resource_group,provider_id,delegator_id,item_type) " + + "VALUES('$1','$2','$3','$4','$5','$6','$7','$8','$9','$a','$b','$c')"; public static final String UPDATE_SUB_SQL = "UPDATE subscriptions SET expiry='$1' where queue_name='$2' and entity='$3'"; public static final String APPEND_SUB_SQL = - "INSERT INTO subscriptions(_id,_type,queue_name,entity,expiry) " - + "VALUES('$1','$2','$3','$4','$5') ON CONFLICT(queue_name,entity) DO NOTHING"; + "INSERT INTO subscriptions(_id,_type,queue_name,entity,expiry,dataset_name,dataset_json,user_id," + + "resource_group,provider_id,delegator_id,item_type) " + + "VALUES('$1','$2','$3','$4','$5','$6','$7','$8','$9','$a','$b','$c') " + + "ON CONFLICT(queue_name,entity) DO NOTHING"; public static final String DELETE_SUB_SQL = "DELETE FROM subscriptions where queue_name='$1'"; diff --git a/src/test/java/iudx/resource/server/apiserver/subscription/SubscriptionServiceTest.java b/src/test/java/iudx/resource/server/apiserver/subscription/SubscriptionServiceTest.java index f5c6f3e9d..0d82be083 100644 --- a/src/test/java/iudx/resource/server/apiserver/subscription/SubscriptionServiceTest.java +++ b/src/test/java/iudx/resource/server/apiserver/subscription/SubscriptionServiceTest.java @@ -391,7 +391,7 @@ public AsyncResult answer(InvocationOnMock arg1) throws Throwable { } }).when(pgService).executeQuery(anyString(), any()); - service.appendSubscription(json, databroker, pgService, authInfo).onComplete(handler -> { + service.appendSubscription(json, databroker, pgService, authInfo,cacheService).onComplete(handler -> { if (handler.succeeded()) { assertEquals(json, handler.result()); vertxTestContext.completeNow(); @@ -420,7 +420,7 @@ public AsyncResult answer(InvocationOnMock arg0) throws Throwable { } }).when(jsonObjectFuture).onComplete(any()); - service.appendSubscription(json, databroker, pgService, authInfo).onComplete(handler -> { + service.appendSubscription(json, databroker, pgService, authInfo,cacheService).onComplete(handler -> { if (handler.failed()) { String throwable = "io.vertx.core.impl.NoStackTraceThrowable: "; String expected = throwable + "{\"type\":400,\"title\":\"Bad Request\",\"detail\":\"Dummy detail\"}"; From b86cd14abb3c3bbe0549ad324b1bbee6cb2f2cc4 Mon Sep 17 00:00:00 2001 From: ananjaykumar2 Date: Wed, 22 Nov 2023 16:55:22 +0530 Subject: [PATCH 2/3] fix junit for append subscription --- .../server/apiserver/subscription/SubscriptionServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/iudx/resource/server/apiserver/subscription/SubscriptionServiceTest.java b/src/test/java/iudx/resource/server/apiserver/subscription/SubscriptionServiceTest.java index 0d82be083..f59893032 100644 --- a/src/test/java/iudx/resource/server/apiserver/subscription/SubscriptionServiceTest.java +++ b/src/test/java/iudx/resource/server/apiserver/subscription/SubscriptionServiceTest.java @@ -390,7 +390,7 @@ public AsyncResult answer(InvocationOnMock arg1) throws Throwable { return null; } }).when(pgService).executeQuery(anyString(), any()); - + when(cacheService.get(any())).thenReturn(Future.succeededFuture(json)); service.appendSubscription(json, databroker, pgService, authInfo,cacheService).onComplete(handler -> { if (handler.succeeded()) { assertEquals(json, handler.result()); From b048421b21ca351dbcd768ec7963069dfb827eb3 Mon Sep 17 00:00:00 2001 From: ananjaykumar2 Date: Wed, 22 Nov 2023 22:45:23 +0530 Subject: [PATCH 3/3] alter subscriptions talbe for SDM --- .../migration/V5_5__alter-subscriptions-table-add-columns.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/main/resources/db/migration/V5_5__alter-subscriptions-table-add-columns.sql diff --git a/src/main/resources/db/migration/V5_5__alter-subscriptions-table-add-columns.sql b/src/main/resources/db/migration/V5_5__alter-subscriptions-table-add-columns.sql new file mode 100644 index 000000000..79e6410ef --- /dev/null +++ b/src/main/resources/db/migration/V5_5__alter-subscriptions-table-add-columns.sql @@ -0,0 +1,4 @@ +ALTER TABLE subscriptions ADD COLUMN resource_group uuid; +ALTER TABLE subscriptions ADD COLUMN delegator_id uuid; +ALTER TABLE subscriptions ADD COLUMN item_type item; +ALTER TABLE subscriptions ADD COLUMN provider_id uuid; \ No newline at end of file