diff options
author | ToineSiebelink <toine.siebelink@est.tech> | 2024-04-09 18:39:51 +0100 |
---|---|---|
committer | ToineSiebelink <toine.siebelink@est.tech> | 2024-04-10 11:47:06 +0100 |
commit | 693cfdd2467d01bf9a90f588ba827454a7b20f33 (patch) | |
tree | 2d9a3e3e587d4b5e7909c4748e1c105b5f1a2483 /cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy | |
parent | 868ff64f0f1873518b1a2225e5c35fa89fdc6d33 (diff) |
Introduce and handle Operation Too Large Exception for batch operations
Issue-ID: CPS-2164
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Change-Id: Iec05d2013be4f971309f0e75d84dc5d0936eb8ef
Diffstat (limited to 'cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy')
-rw-r--r-- | cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy index bdd0e716d..aef37c91e 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy @@ -27,6 +27,7 @@ import org.onap.cps.ncmp.api.models.DataOperationDefinition import org.onap.cps.ncmp.api.models.DataOperationRequest import org.onap.cps.ncmp.api.models.CmResourceAddress import org.onap.cps.ncmp.rest.exceptions.OperationNotSupportedException +import org.onap.cps.ncmp.rest.exceptions.PayloadTooLargeException import org.onap.cps.ncmp.rest.executor.CpsNcmpTaskExecutor import spock.lang.Specification import spock.util.concurrent.PollingConditions @@ -110,9 +111,7 @@ class NcmpDatastoreRequestHandlerSpec extends Specification { } def 'Attempt to execute async data operation request with error #scenario'() { - given: 'notification feature is turned on' - objectUnderTest.notificationFeatureEnabled = true - and: 'a data operation definition with datastore: #datastore' + given: 'a data operation definition with datastore: #datastore' def dataOperationDefinition = new DataOperationDefinition(operation: 'read', datastore: datastore) when: 'data operation request is executed' def dataOperationRequest = new DataOperationRequest(dataOperationDefinitions: [dataOperationDefinition]) @@ -127,11 +126,9 @@ class NcmpDatastoreRequestHandlerSpec extends Specification { } def 'Attempt to execute async data operation request with #scenario operation: #operation.'() { - given: 'notification feature is turned on' - objectUnderTest.notificationFeatureEnabled = true - and: 'a data operation definition with operation: #operation' + given: 'a data operation definition with operation: #operation' def dataOperationDefinition = new DataOperationDefinition(operation: operation, datastore: 'ncmp-datastore:passthrough-running') - when: 'bulk request is executed' + when: 'data operation request is executed' objectUnderTest.executeRequest('someTopic', new DataOperationRequest(dataOperationDefinitions:[dataOperationDefinition]), NO_AUTH_HEADER) then: 'the expected type of exception is thrown' thrown(expectedException) @@ -144,4 +141,16 @@ class NcmpDatastoreRequestHandlerSpec extends Specification { 'unsupported' | 'delete' || OperationNotSupportedException } + def 'Attempt to execute async data operation request with too many cm handles.'() { + given: 'a data operation definition with too many cm handles' + def cmHandleIds = new String[51] + def dataOperationDefinition = new DataOperationDefinition(operationId: 'abc', operation: 'read', datastore: 'ncmp-datastore:passthrough-running', cmHandleIds: cmHandleIds) + when: 'data operation request is executed' + objectUnderTest.executeRequest('someTopic', new DataOperationRequest(dataOperationDefinitions:[dataOperationDefinition]), NO_AUTH_HEADER) + then: 'a payload too large exception is thrown' + def exceptionThrown = thrown(PayloadTooLargeException) + and: 'the error message contains the offending number of cm handles' + assert exceptionThrown.message == "Operation 'abc' affects too many (51) cm handles" + } + } |