Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(1429): Supporting parameter notation and ceased URI parameters serialization #1493

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@ describe('CanvasForm', () => {
it('expression field', async () => {
const camelRoute = {
from: {
uri: 'timer:tutorial',
uri: 'timer',
parameters: {
timerName: 'tutorial',
},
steps: [
{
setHeader: {
Expand Down Expand Up @@ -433,7 +436,10 @@ describe('CanvasForm', () => {
it('dataformat field', async () => {
const camelRoute = {
from: {
uri: 'timer:tutorial',
uri: 'timer',
parameters: {
timerName: 'tutorial',
},
steps: [
{
marshal: {
Expand Down Expand Up @@ -523,7 +529,10 @@ describe('CanvasForm', () => {
it('loadbalancer field', async () => {
const camelRoute = {
from: {
uri: 'timer:tutorial',
uri: 'timer',
parameters: {
timerName: 'tutorial',
},
steps: [
{
loadBalance: {
Expand Down Expand Up @@ -648,7 +657,10 @@ describe('CanvasForm', () => {
it('expression field', async () => {
const camelRoute = {
from: {
uri: 'timer:tutorial',
uri: 'timer',
parameters: {
timerName: 'tutorial',
},
steps: [
{
setHeader: {
Expand Down Expand Up @@ -690,7 +702,10 @@ describe('CanvasForm', () => {
it('dataformat field', async () => {
const camelRoute = {
from: {
uri: 'timer:tutorial',
uri: 'timer',
parameters: {
timerName: 'tutorial',
},
steps: [
{
marshal: {
Expand Down Expand Up @@ -732,7 +747,10 @@ describe('CanvasForm', () => {
it('loadbalancer field', async () => {
const camelRoute = {
from: {
uri: 'timer:tutorial',
uri: 'timer',
parameters: {
timerName: 'tutorial',
},
steps: [
{
loadBalance: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ describe('CanvasFormBody', () => {
it('expression => main form', async () => {
const camelRoute = {
from: {
uri: 'timer:tutorial',
uri: 'timer',
parameters: {
timerName: 'tutorial',
},
steps: [
{
setHeader: {
Expand Down Expand Up @@ -113,7 +116,10 @@ describe('CanvasFormBody', () => {
it('main form => expression', async () => {
const camelRoute = {
from: {
uri: 'timer:tutorial',
uri: 'timer',
parameters: {
timerName: 'tutorial',
},
steps: [
{
setHeader: {
Expand Down Expand Up @@ -185,7 +191,10 @@ describe('CanvasFormBody', () => {
it('dataformat => main form', async () => {
const camelRoute = {
from: {
uri: 'timer:tutorial',
uri: 'timer',
parameters: {
timerName: 'tutorial',
},
steps: [
{
marshal: {
Expand Down Expand Up @@ -243,7 +252,10 @@ describe('CanvasFormBody', () => {
it('main form => dataformat', async () => {
const camelRoute = {
from: {
uri: 'timer:tutorial',
uri: 'timer',
parameters: {
timerName: 'tutorial',
},
steps: [
{
marshal: {
Expand Down Expand Up @@ -307,7 +319,10 @@ describe('CanvasFormBody', () => {
it('loadbalancer => main form', async () => {
const camelRoute = {
from: {
uri: 'timer:tutorial',
uri: 'timer',
parameters: {
timerName: 'tutorial',
},
steps: [
{
loadBalance: {
Expand Down Expand Up @@ -365,7 +380,10 @@ describe('CanvasFormBody', () => {
it('main form => loadbalancer', async () => {
const camelRoute = {
from: {
uri: 'timer:tutorial',
uri: 'timer',
parameters: {
timerName: 'tutorial',
},
steps: [
{
loadBalance: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ exports[`CanvasSideBar displays selected node information 1`] = `
uri: timer
parameters:
period: "1000"
timerName: template
steps:
- log:
id: log-1234
Expand Down
9 changes: 6 additions & 3 deletions packages/ui/src/hooks/entities.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ describe('useEntities', () => {
id: route-1234
from:
id: from-1234
uri: timer:template
uri: timer
parameters:
period: "1000"
timerName: template
steps:
- log:
id: log-1234
Expand Down Expand Up @@ -171,9 +172,10 @@ describe('useEntities', () => {
id: route-1234
from:
id: from-1234
uri: timer:template
uri: timer
parameters:
period: "1000"
timerName: template
# This comment won't be stored
steps:
- log:
Expand Down Expand Up @@ -213,9 +215,10 @@ describe('useEntities', () => {
id: route-1234
from:
id: from-1234
uri: timer:template
uri: timer
parameters:
period: "1000"
timerName: template
steps:
- log:
id: log-1234
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@ exports[`createCamelResource should create an empty KameletResource if no args i
"id": "from-1234",
"parameters": {
"period": "{{period}}",
"timerName": "user",
},
"steps": [
{
"to": "https://random-data-api.com/api/v2/users",
"to": {
"parameters": {
"httpUri": "random-data-api.com/api/v2/users",
},
"uri": "https",
},
},
{
"to": "kamelet:sink",
},
],
"uri": "timer:user",
"uri": "timer",
},
"id": "kamelet-1234",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ exports[`CamelRouteResource toJSON should return JSON 1`] = `
{
"route": {
"from": {
"parameters": {
"timerName": "tutorial",
},
"steps": [
{
"set-header": {
Expand Down Expand Up @@ -58,7 +61,7 @@ exports[`CamelRouteResource toJSON should return JSON 1`] = `
},
},
],
"uri": "timer:tutorial",
"uri": "timer",
},
"id": "route-8888",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,22 @@ exports[`KameletResource should convert to JSON 1`] = `
"id": "from-1234",
"parameters": {
"period": "{{period}}",
"timerName": "user",
},
"steps": [
{
"to": "https://random-data-api.com/api/v2/users",
"to": {
"parameters": {
"httpUri": "random-data-api.com/api/v2/users",
},
"uri": "https",
},
},
{
"to": "kamelet:sink",
},
],
"uri": "timer:user",
"uri": "timer",
},
},
"types": {
Expand Down Expand Up @@ -105,16 +111,22 @@ exports[`KameletResource should create a new KameletResource 1`] = `
"id": "from-1234",
"parameters": {
"period": "{{period}}",
"timerName": "user",
},
"steps": [
{
"to": "https://random-data-api.com/api/v2/users",
"to": {
"parameters": {
"httpUri": "random-data-api.com/api/v2/users",
},
"uri": "https",
},
},
{
"to": "kamelet:sink",
},
],
"uri": "timer:user",
"uri": "timer",
},
},
"types": {
Expand Down Expand Up @@ -169,16 +181,22 @@ exports[`KameletResource should get the visual entities (Camel Route Visual Enti
"id": "from-1234",
"parameters": {
"period": "{{period}}",
"timerName": "user",
},
"steps": [
{
"to": "https://random-data-api.com/api/v2/users",
"to": {
"parameters": {
"httpUri": "random-data-api.com/api/v2/users",
},
"uri": "https",
},
},
{
"to": "kamelet:sink",
},
],
"uri": "timer:user",
"uri": "timer",
},
"id": "kamelet-1234",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ describe('AbstractCamelVisualEntity', () => {

describe('updateModel', () => {
it('should update the model with the new value', () => {
const newUri = 'timer:MyTimer';
const newUri = 'timer';
abstractVisualEntity.updateModel('from', { uri: newUri });

expect(abstractVisualEntity.route.from.uri).toEqual(newUri);
});

it('should delegate the serialization to the `CamelComponentSchemaService`', () => {
const newUri = 'timer:MyTimer';
const spy = jest.spyOn(CamelComponentSchemaService, 'getUriSerializedDefinition');
const newUri = 'timer';
const spy = jest.spyOn(CamelComponentSchemaService, 'getMultiValueSerializedDefinition');
abstractVisualEntity.updateModel('from', { uri: newUri });

expect(spy).toHaveBeenCalledWith('from', { uri: newUri });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ export abstract class AbstractCamelVisualEntity<T extends object> implements Bas

updateModel(path: string | undefined, value: unknown): void {
if (!path) return;
let updatedValue = CamelComponentSchemaService.getUriSerializedDefinition(path, value);
updatedValue = CamelComponentSchemaService.getMultiValueSerializedDefinition(path, updatedValue);
const updatedValue = CamelComponentSchemaService.getMultiValueSerializedDefinition(path, value);

setValue(this.route, path, updatedValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('Camel Route', () => {

camelEntity.getComponentSchema('from.uri');

expect(spy).toHaveBeenCalledWith('from.uri', 'timer:tutorial');
expect(spy).toHaveBeenCalledWith('from.uri', 'timer');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('KameletVisualEntity', () => {
}
}
const kamelet = new KameletVisualEntityTest(kameletDef);
expect(kamelet.getRootUri()).toEqual('timer:tutorial');
expect(kamelet.getRootUri()).toEqual('timer');
});

describe('toVizNode', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ describe('BaseNodeMapper', () => {
path = 'from';
componentLookup = {
processorName: 'from' as keyof ProcessorDefinition,
componentName: 'timer:timerName',
componentName: 'timer',
};
entityDefinition = { uri: 'timer:timerName', steps: [] };
entityDefinition = { uri: 'timer', parameters: { timerName: 'timerName' }, steps: [] };
});

describe('getVizNodeFromProcessor', () => {
Expand All @@ -31,14 +31,17 @@ describe('BaseNodeMapper', () => {
path,
icon: expect.any(String),
processorName: 'from',
componentName: 'timer:timerName',
componentName: 'timer',
});
});

it('should return a VisualizationNode with children', () => {
const routeDefinition: RouteDefinition = {
from: {
uri: 'timer:timerName',
uri: 'timer',
parameters: {
timerName: 'timerName',
},
steps: [{ log: 'logName' }, { to: 'direct:anotherRoute' }],
},
};
Expand All @@ -52,7 +55,10 @@ describe('BaseNodeMapper', () => {
it('should return a VisualizationNode with special children', () => {
const routeDefinition: RouteDefinition = {
from: {
uri: 'timer:timerName',
uri: 'timer',
parameters: {
timerName: 'timerName',
},
steps: [
{
doTry: {
Expand Down
Loading