-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test log transformation to hierarchy
- Loading branch information
Showing
1 changed file
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import { describe, expect, test } from "@jest/globals"; | ||
import { createLogHierarchy } from "./logHierarchy"; | ||
|
||
describe("transform log data to hierarchy", () => { | ||
test("constraint pass", () => { | ||
const data = [ | ||
{ | ||
tid: "o1", | ||
message: "validate set constraint ModelA.TopicA.ClassA.ConstraintName...", | ||
type: "Info", | ||
}, | ||
]; | ||
|
||
const expected = [ | ||
{ | ||
message: "ModelA", | ||
type: "Info", | ||
values: [ | ||
{ | ||
message: "TopicA.ClassA", | ||
type: "Info", | ||
values: [{ message: "Set Constraint ConstraintName", type: "Info" }], | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
const hierarchy = createLogHierarchy(data); | ||
|
||
expect(hierarchy).toStrictEqual(expected); | ||
}); | ||
|
||
test("constraint fail", () => { | ||
const data = [ | ||
{ | ||
tid: "o1", | ||
message: "validate existence constraint ModelA.TopicA.ClassA.ConstraintName...", | ||
type: "Info", | ||
}, | ||
{ | ||
tid: "o2", | ||
message: "Some other message", | ||
type: "Info", | ||
}, | ||
{ | ||
tid: "o3", | ||
message: | ||
"Existence constraint ModelA.TopicA.ClassA.ConstraintName is violated! The value of the attribute Test of t1 was not found in the condition class.", | ||
type: "Error", | ||
}, | ||
]; | ||
|
||
const expected = [ | ||
{ | ||
message: "ModelA", | ||
type: "Error", | ||
values: [ | ||
{ | ||
message: "TopicA.ClassA", | ||
type: "Error", | ||
values: [ | ||
{ | ||
message: | ||
"Existence constraint ConstraintName is violated! The value of the attribute Test of t1 was not found in the condition class.", | ||
type: "Error", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
const hierarchy = createLogHierarchy(data); | ||
|
||
expect(hierarchy).toStrictEqual(expected); | ||
}); | ||
|
||
test("mixed log types", () => { | ||
const data = [ | ||
{ | ||
tid: "o1", | ||
message: "validate data...", | ||
type: "Info", | ||
}, | ||
{ | ||
tid: "o2", | ||
message: "lookup model <Base> 2.3 in repository <http://models.geo.admin.ch/>", | ||
type: "Info", | ||
}, | ||
{ | ||
tid: "o3", | ||
message: "validate mandatory constraint ModelA.TopicA.ClassA.ConstraintName...", | ||
type: "Info", | ||
}, | ||
{ | ||
tid: "o4", | ||
message: | ||
"MandatoryConstraint ModelA.TopicA.ClassA.ConstraintName of ModelA.TopicA.ClassA is not yet implemented.", | ||
type: "Warning", | ||
}, | ||
{ | ||
tid: "o5", | ||
message: "validate mandatory constraint ModelA.TopicA.ClassA.Constraint1...", | ||
type: "Info", | ||
}, | ||
{ | ||
tid: "o6", | ||
message: "validate mandatory constraint ModelA.TopicA.ClassA.Constraint2...", | ||
type: "Info", | ||
}, | ||
{ | ||
tid: "o7", | ||
message: "Custom message for constraint. ModelA.TopicA.ClassA.Constraint1 (MANDATORY CONSTRAINT DEFINED(Abc);)", | ||
type: "Error", | ||
}, | ||
]; | ||
|
||
const expected = [ | ||
{ | ||
message: "ModelA", | ||
type: "Error", | ||
values: [ | ||
{ | ||
message: "TopicA.ClassA", | ||
type: "Error", | ||
values: [ | ||
{ | ||
message: "MandatoryConstraint ConstraintName of ModelA.TopicA.ClassA is not yet implemented.", | ||
type: "Warning", | ||
}, | ||
{ message: "Custom message for constraint.", type: "Error" }, | ||
{ message: "Mandatory Constraint Constraint2", type: "Info" }, | ||
], | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
const hierarchy = createLogHierarchy(data); | ||
|
||
expect(hierarchy).toStrictEqual(expected); | ||
}); | ||
}); |