Skip to content

Commit

Permalink
Complement refactoring with adaption of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
georg-schwarz committed Jan 16, 2024
1 parent bf53b85 commit 1812343
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,6 @@ describe('Validation of BlockDefinition', () => {
);
});

it('should diagnose error on block as input for multiple pipes', async () => {
const text = readJvTestAsset(
'block-definition/invalid-block-as-multiple-pipe-inputs.jv',
);

await parseAndValidateBlock(text);

expect(validationAcceptorMock).toHaveBeenCalledTimes(2);
expect(validationAcceptorMock).toHaveBeenNthCalledWith(
2,
'error',
'At most one pipe can be connected to the input of a TestTableLoader',
expect.any(Object),
);
});

it('should have no error on valid block definition', async () => {
const text = readJvTestAsset('block-definition/valid-block-definition.jv');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,27 @@ describe('Validation of CompositeBlocktypeDefinition', () => {

expect(validationAcceptorMock).toHaveBeenCalledTimes(0);
});

it('should diagnose error on block as input for multiple pipes', async () => {
const text = readJvTestAsset(
'composite-blocktype-definition/invalid-block-as-multiple-pipe-inputs.jv',
);

await parseAndValidateBlocktype(text);

// first 2 errors for multiple pipelines in test file
expect(validationAcceptorMock).toHaveBeenCalledTimes(4);
expect(validationAcceptorMock).toHaveBeenNthCalledWith(
3,
'error',
'At most one pipe can be connected to the input of a block. Currently, the following 2 blocks are connected via pipes: "BlockFrom1", "BlockFrom2"',
expect.any(Object),
);
expect(validationAcceptorMock).toHaveBeenNthCalledWith(
4,
'error',
'At most one pipe can be connected to the input of a block. Currently, the following 2 blocks are connected via pipes: "BlockFrom1", "BlockFrom2"',
expect.any(Object),
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,20 @@ describe('Validation of PipelineDefinition', () => {

expect(validationAcceptorMock).toHaveBeenCalledTimes(0);
});

it('should diagnose error on block as input for multiple pipes', async () => {
const text = readJvTestAsset(
'pipeline-definition/invalid-block-as-multiple-pipe-inputs.jv',
);

await parseAndValidatePipeline(text);

expect(validationAcceptorMock).toHaveBeenCalledTimes(2);
expect(validationAcceptorMock).toHaveBeenNthCalledWith(
2,
'error',
'At most one pipe can be connected to the input of a block. Currently, the following 2 blocks are connected via pipes: "BlockFrom1", "BlockFrom2"',
expect.any(Object),
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg
//
// SPDX-License-Identifier: AGPL-3.0-only

composite blocktype TestBlockType {
input inPort oftype None;
output outPort oftype None;

block BlockTo oftype TestTableLoader { }

block BlockFrom1 oftype TestFileExtractor { }

block BlockFrom2 oftype TestFileExtractor { }

inPort -> BlockFrom1 -> BlockTo -> outPort;
inPort -> BlockFrom2 -> BlockTo -> outPort;
}

builtin blocktype TestFileExtractor {
input inPort oftype None;
output outPort oftype Table;
}

builtin blocktype TestTableLoader {
input inPort oftype Table;
output outPort oftype None;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@
composite blocktype TestBlock {

input inputName oftype None;
output outputName oftype Sheet;
output outputName oftype TextFile;

block FileExtractor oftype HttpExtractor { url: 'url'; }
block FileTextInterpreter oftype TextFileInterpreter {}

block FileCSVInterpreter oftype CSVInterpreter {
}
block FileTextInterpreter1 oftype TextFileInterpreter {}
block FileTextInterpreter2 oftype TextFileInterpreter {}

inputName
->FileExtractor
->FileTextInterpreter
->FileCSVInterpreter
->FileTextInterpreter1
->outputName;

inputName
->FileExtractor
->FileTextInterpreter
->FileCSVInterpreter
->FileTextInterpreter2
->outputName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// SPDX-License-Identifier: AGPL-3.0-only

pipeline Pipeline {
block BlockTo oftype TestTableLoader {
}
block BlockTo oftype TestTableLoader { }

block BlockFrom oftype TestFileExtractor {
}
block BlockFrom1 oftype TestFileExtractor { }

BlockFrom -> BlockTo;
block BlockFrom2 oftype TestFileExtractor { }

BlockFrom -> BlockTo;
BlockFrom1 -> BlockTo;

BlockFrom2 -> BlockTo;
}

builtin blocktype TestFileExtractor {
Expand Down

0 comments on commit 1812343

Please sign in to comment.