Skip to content

Commit

Permalink
feat(subscribe): add possibility to filter tasks by tenant
Browse files Browse the repository at this point in the history
Related to CAM-9415
  • Loading branch information
yanavasileva committed Oct 15, 2018
1 parent 6f5bdc8 commit 74e9233
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/Client.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ The currently supported options are:
| processDefinitionIdIn | A value which allows to filter tasks based on process definition ids | string | | |
| processDefinitionKey | A value which allows to filter tasks based on process definition key | string | | |
| processDefinitionKeyIn | A value which allows to filter tasks based on process definition keys | string | | |
| withoutTenantId | A value which allows to filter tasks based on tenant ids | string | | |
| tenantIdIn | A value which allows to filter tasks without tenant id | boolean | | |


### About topic subscriptions
Expand Down
12 changes: 11 additions & 1 deletion lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ class Client extends events {
processDefinitionId,
processDefinitionIdIn,
processDefinitionKey,
processDefinitionKeyIn
processDefinitionKeyIn,
tenantIdIn,
withoutTenantId
}
]) => {
let topic = { topicName, lockDuration };
Expand Down Expand Up @@ -183,6 +185,14 @@ class Client extends events {
topic.processDefinitionKeyIn = processDefinitionKeyIn;
}

if (!isUndefinedOrNull(tenantIdIn)) {
topic.tenantIdIn = tenantIdIn;
}

if (!isUndefinedOrNull(withoutTenantId)) {
topic.withoutTenantId = withoutTenantId;
}

return topic;
}
);
Expand Down
28 changes: 27 additions & 1 deletion lib/Client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ describe("Client", () => {
processDefinitionId: "processId",
processDefinitionIdIn: ["processId", "processId2"],
processDefinitionKey: "processKey",
processDefinitionKeyIn: ["processKey", "processKey2"]
processDefinitionKeyIn: ["processKey", "processKey2"],
tenantIdIn: ["tenantId"],
withoutTenantId: true
};
});

Expand Down Expand Up @@ -224,6 +226,30 @@ describe("Client", () => {
);
});

test("should subscribe to topic based on tenantIdIn ", () => {
// given
const footopicSubscription = client.subscribe(
"foo",
customConfig,
fooWork
);
// then
expect(footopicSubscription.tenantIdIn).toBe(customConfig.tenantIdIn);
});

test("should subscribe to topic based on withoutTenantId ", () => {
// given
const footopicSubscription = client.subscribe(
"foo",
customConfig,
fooWork
);
// then
expect(footopicSubscription.withoutTenantId).toBe(
customConfig.withoutTenantId
);
});

test("should call the API with the custom configs", () => {
// given
const fetchAnLockSpy = jest.spyOn(client.engineService, "fetchAndLock");
Expand Down
4 changes: 4 additions & 0 deletions lib/__snapshots__/Client.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ Array [
"processKey",
"processKey2",
],
"tenantIdIn": Array [
"tenantId",
],
"topicName": "foo",
"variables": Array [
"fooVariable",
"barVariable",
],
"withoutTenantId": true,
},
],
},
Expand Down

0 comments on commit 74e9233

Please sign in to comment.