@@ -137,6 +137,22 @@ cds.env.requires.Namespace = {
137137 } ,
138138} ;
139139
140+ cds . env . requires [ "sapafcsdk.scheduling.ProviderService" ] = {
141+ impl : path . join ( basePath , "srv/service/standard-service.js" ) ,
142+ outbox : {
143+ kind : "persistent-outbox" ,
144+ namespace : "namespaceA" ,
145+ events : {
146+ main : {
147+ priority : "high" ,
148+ } ,
149+ timeBucketAction : {
150+ cron : "*/5 * * * *" ,
151+ } ,
152+ } ,
153+ } ,
154+ } ;
155+
140156const project = __dirname + "/asset/outboxProject" ; // The project's root folder
141157cds . test ( project ) ;
142158
@@ -971,7 +987,7 @@ describe("event-queue outbox", () => {
971987 it ( "insert periodic event for CAP service" , async ( ) => {
972988 await checkAndInsertPeriodicEvents ( context ) ;
973989 const [ periodicEvent ] = await testHelper . selectEventQueueAndReturn ( tx , {
974- expectedLength : 3 ,
990+ expectedLength : 4 ,
975991 additionalColumns : [ "type" , "subType" ] ,
976992 } ) ;
977993 expect ( periodicEvent . startAfter ) . toBeDefined ( ) ;
@@ -2037,6 +2053,19 @@ describe("event-queue outbox", () => {
20372053 await testHelper . selectEventQueueAndExpectDone ( tx , { expectedLength : 1 } ) ;
20382054 expect ( loggerMock . callsLengths ( ) . error ) . toEqual ( 2 ) ;
20392055 } ) ;
2056+
2057+ it ( "return null" , async ( ) => {
2058+ const service = await cds . connect . to ( "StandardService" ) ;
2059+ await service . send ( "returnStatusAsArray" , {
2060+ status : null ,
2061+ } ) ;
2062+ await commitAndOpenNew ( ) ;
2063+ await testHelper . selectEventQueueAndExpectOpen ( tx , { expectedLength : 1 } ) ;
2064+ await processEventQueue ( tx . context , "CAP_OUTBOX" , service . name ) ;
2065+ await commitAndOpenNew ( ) ;
2066+ await testHelper . selectEventQueueAndExpectDone ( tx , { expectedLength : 1 } ) ;
2067+ expect ( loggerMock . callsLengths ( ) . error ) . toEqual ( 2 ) ;
2068+ } ) ;
20402069 } ) ;
20412070
20422071 describe ( "as object" , ( ) => {
@@ -2138,6 +2167,24 @@ describe("event-queue outbox", () => {
21382167 expect ( scheduleEventSpy ) . toHaveBeenCalledTimes ( 0 ) ;
21392168 expect ( loggerMock . callsLengths ( ) . error ) . toEqual ( 0 ) ;
21402169 } ) ;
2170+
2171+ it ( "object without any valid field; just random properties" , async ( ) => {
2172+ const service = ( await cds . connect . to ( "StandardService" ) ) . tx ( context ) ;
2173+ await service . send ( "asObject" , {
2174+ returnData : true ,
2175+ abc : 123 ,
2176+ status : 3 ,
2177+ } ) ;
2178+ await commitAndOpenNew ( ) ;
2179+ await processEventQueue ( tx . context , "CAP_OUTBOX" , service . name ) ;
2180+ const [ event ] = await testHelper . selectEventQueueAndReturn ( tx , {
2181+ expectedLength : 1 ,
2182+ } ) ;
2183+ expect ( event . startAfter ) . toBeNull ( ) ;
2184+ expect ( event . status ) . toEqual ( EventProcessingStatus . Done ) ;
2185+ expect ( scheduleEventSpy ) . toHaveBeenCalledTimes ( 0 ) ;
2186+ expect ( loggerMock . callsLengths ( ) . error ) . toEqual ( 0 ) ;
2187+ } ) ;
21412188 } ) ;
21422189
21432190 describe ( "as Array Tuple" , ( ) => {
@@ -2194,6 +2241,22 @@ describe("event-queue outbox", () => {
21942241 expect ( scheduleEventSpy ) . toHaveBeenCalledTimes ( 1 ) ;
21952242 expect ( loggerMock . callsLengths ( ) . error ) . toEqual ( 0 ) ;
21962243 } ) ;
2244+
2245+ it ( "object without any valid field; just random properties" , async ( ) => {
2246+ const service = ( await cds . connect . to ( "StandardService" ) ) . tx ( context ) ;
2247+ await service . send ( "asArrayTuple" , {
2248+ returnData : true ,
2249+ abc : 123 ,
2250+ } ) ;
2251+ await commitAndOpenNew ( ) ;
2252+ await processEventQueue ( tx . context , "CAP_OUTBOX" , service . name ) ;
2253+ const [ event ] = await testHelper . selectEventQueueAndReturn ( tx , {
2254+ expectedLength : 1 ,
2255+ } ) ;
2256+ expect ( event . startAfter ) . toBeNull ( ) ;
2257+ expect ( scheduleEventSpy ) . toHaveBeenCalledTimes ( 0 ) ;
2258+ expect ( loggerMock . callsLengths ( ) . error ) . toEqual ( 0 ) ;
2259+ } ) ;
21972260 } ) ;
21982261
21992262 describe ( "as Array Object (ID)" , ( ) => {
@@ -2304,6 +2367,24 @@ describe("event-queue outbox", () => {
23042367 expect ( scheduleEventSpy ) . toHaveBeenCalledTimes ( 1 ) ;
23052368 expect ( loggerMock . callsLengths ( ) . error ) . toEqual ( 0 ) ;
23062369 } ) ;
2370+
2371+ it ( "object without any valid field; just random properties" , async ( ) => {
2372+ const service = ( await cds . connect . to ( "StandardService" ) ) . tx ( context ) ;
2373+ await service . send ( "asArrayWithId" , {
2374+ returnData : true ,
2375+ abc : 123 ,
2376+ status : EventProcessingStatus . Error ,
2377+ } ) ;
2378+ await commitAndOpenNew ( ) ;
2379+ await processEventQueue ( tx . context , "CAP_OUTBOX" , service . name ) ;
2380+ const [ event ] = await testHelper . selectEventQueueAndReturn ( tx , {
2381+ expectedLength : 1 ,
2382+ } ) ;
2383+ expect ( event . startAfter ) . toBeDefined ( ) ;
2384+ expect ( event . status ) . toEqual ( EventProcessingStatus . Done ) ; // because unknown props in return value
2385+ expect ( scheduleEventSpy ) . toHaveBeenCalledTimes ( 0 ) ;
2386+ expect ( loggerMock . callsLengths ( ) . error ) . toEqual ( 0 ) ;
2387+ } ) ;
23072388 } ) ;
23082389 } ) ;
23092390 } ) ;
0 commit comments