ComposantsComponents

ComposantsComponents › Logs & ErreursLogs & Errors

tAssert

tAssert

Logs & ErreursLogs & Errors

Vérifie une condition Java et envoie le résultat, Ok ou Failed, aux tAssertCatcher du job. Il n'arrête rien : que la condition soit vraie ou fausse, le job continue et se termine avec le code 0. Sans tAssertCatcher dans le job, il ne fait rien du tout. À choisir pour contrôler un résultat (nombre de lignes, total, fichier produit) et en garder la trace. Checks a Java condition and sends the result, Ok or Failed, to the tAssertCatcher components of the job. It stops nothing: whether the condition is true or false, the job goes on and ends with code 0. Without a tAssertCatcher in the job, it does nothing at all. Choose it to check a result (row count, total, produced file) and keep a record of it.

EntréeInput

Aucune : il peut commencer un sous-job. Sinon un lien Main (une vérification par ligne) ou Iterate (une par itération). None: it can start a subjob. Otherwise one Main link (one check per row) or Iterate link (one per iteration).

SortieOutput

Le résultat ne sort pas par un lien : il arrive dans le tAssertCatcher. Le composant n'a pas de schéma ; placez-le en fin de flux. The result does not leave through a link: it arrives in the tAssertCatcher. The component has no schema; place it at the end of a flow.

DéclencheursTriggers

On Subjob Ok On Subjob Error On Component Ok On Component Error Run if

En entrée comme en sortie. Une condition fausse n'est pas une erreur : c'est On Component Ok qui est suivi. As input and as output. A false condition is not an error: On Component Ok is the one followed.

UtilisationUsage

Après un traitementAfter a processing

row1 (Main) OnSubjobOk row2 (Main) tFileInputDelimited_1 tDBOutput_1 tAssert_1 tAssertCatcher_1 tLogRow_1

L'expression lit une variable globale du traitement, par exemple ((Integer) globalMap.get("tDBOutput_1_NB_LINE")) > 0. Le tAssertCatcher est posé à part, sans lien avec le reste. The expression reads a global variable of the processing, for example ((Integer) globalMap.get("tDBOutput_1_NB_LINE")) > 0. The tAssertCatcher is placed apart, with no link to the rest.

Sur chaque ligneOn each row

row1 (Main) row2 (Main) tFixedFlowInput_1 tAssert_1 tAssertCatcher_1 tFileOutputDelimited_1

L'expression et la description peuvent lire la ligne reçue : row1.amount > 0. Le tAssertCatcher reçoit un message par ligne, vraie ou fausse. The expression and the description can read the received row: row1.amount > 0. The tAssertCatcher receives one message per row, true or false.

  1. Déposez le tAssert depuis la famille Logs & Erreurs et reliez-le après ce qu'il doit vérifier (On Subjob Ok, On Component Ok, ou un lien Main). Drop the tAssert from the Logs & Errors family and connect it after what it must check (On Subjob Ok, On Component Ok, or a Main link).
  2. Écrivez l'Expression : une expression Java de type boolean, sans point-virgule. Donnez une Description entre guillemets, qui dira dans le journal ce qui a été vérifié. Write the expression: a Java expression of type boolean, without a semicolon. Give a description in quotes, which will tell in the log what was checked.
  3. Déposez un tAssertCatcher dans le même job et reliez-le à une sortie (tLogRow, fichier, table). Sans lui, le tAssert ne génère aucun code. Drop a tAssertCatcher in the same job and connect it to an output (tLogRow, file, table). Without it, the tAssert generates no code.

Paramètres simplesBasic settings

Les libellés sont ceux de l'onglet Composant (en anglais, ils sont écrits en minuscules) ; le nom technique, en gris, est celui du paramètre dans le fichier du job. Le composant n'a pas de paramètres avancés propres, seulement la case Statistiques du tStatCatcher commune à tous les composants (voir tStatCatcher). Labels are those of the Component tab (written in lower case in English); the technical name, in grey, is the parameter name in the job file. The component has no advanced settings of its own, only the tStatCatcher Statistics box shared by all components (see tStatCatcher).

ParamètreSetting DéfautDefault VisibleShown Description
DescriptiondescriptionDESCRIPTION "" ToujoursAlways Expression Java de type String, recopiée dans la colonne description du tAssertCatcher. Elle peut lire la ligne reçue ou une variable : "Amount of " + row1.name. Gardez au moins "" : un champ tout à fait vide empêche le job de compiler (voir Pièges). Java expression of type String, copied to the description column of the tAssertCatcher. It can read the received row or a variable: "Amount of " + row1.name. Keep at least "": a completely empty field prevents the job from compiling (see Pitfalls).
ExpressionexpressionEXPRESSION videempty ToujoursAlways Obligatoire. Expression Java de type boolean, recopiée telle quelle dans un if (…) : pas de point-virgule. Vraie : statut Ok. Fausse : statut Failed. Elle est évaluée à chaque passage (une fois, ou une fois par ligne ou par itération). Required. Java expression of type boolean, copied as is into an if (…): no semicolon. True: status Ok. False: status Failed. It is evaluated at each pass (once, or once per row or per iteration).

Ce que le composant envoieWhat the component sends

Expression status substatus
vraietrueOk--
faussefalseFailedTest logically failed

La colonne origin reçoit le nom du composant (tAssert_1) et description la Description. Les autres colonnes sont décrites sur la page du tAssertCatcher. The origin column receives the name of the component (tAssert_1) and description the description. The other columns are described on the tAssertCatcher page.

Le code généréThe generated code

Pour chaque tAssertCatcher du job dont la case Capturer les tAssert est cochée, le message est ajouté puis le sous-job du tAssertCatcher est exécuté aussitôt : For each tAssertCatcher of the job whose Catch tAssert box is checked, the message is added, then the subjob of the tAssertCatcher is run at once:

if(((Integer) globalMap.get("count")) > 0) {
	tAssertCatcher_1.addMessage(pid, projectName, jobName, "java",
		"tAssert_1", "Ok", "--", "At least one row");
	tAssertCatcher_1Process(globalMap);
}else {
	tAssertCatcher_1.addMessage(pid, projectName, jobName, "java",
		"tAssert_1", "Failed", "Test logically failed", "At least one row");
	tAssertCatcher_1Process(globalMap);
}

Le composant n'a pas de variable globale (RETURNS vide) : le résultat n'est lisible que par le tAssertCatcher. The component has no global variable (empty RETURNS): the result can only be read through the tAssertCatcher.

ExemplesExamples

Sorties copiées depuis une exécution de chaque job. Le tAssertCatcher est relié à un tLogRow en mode Table. Les colonnes moment (date et heure) et pid (identifiant tiré au hasard à chaque exécution) changent d'une exécution à l'autre ; project et job sont ceux du job d'essai. Outputs copied from a run of each job. The tAssertCatcher is connected to a tLogRow in Table mode. The moment (date and time) and pid (identifier drawn at random for each run) columns change from one run to the next; project and job are those of the test job.

Une condition vraie, une fausseOne true condition, one false

OnSubjobOk OnSubjobOk OnSubjobOk row1 (Main) tJava_1 tAssert_1 tAssert_2 tJava_2 tAssertCatcher_1 tLogRow_1

tJava_1 range 3 dans la variable count ; tJava_2 écrit End of job. tJava_1 stores 3 in the count variable; tJava_2 writes End of job.

// tJava_1
globalMap.put("count", 3);
System.out.println("Loaded 3 rows");
// tAssert_1 — description: "At least one row"
((Integer) globalMap.get("count")) > 0
// tAssert_2 — description: "At most 2 rows"
((Integer) globalMap.get("count")) <= 2
Loaded 3 rows
.-------------------+------+-------+------------+--------+---------+------+---------+----------------.
|                                             tLogRow_1                                              |
|=------------------+------+-------+------------+--------+---------+------+---------+---------------=|
|moment             |pid   |project|job         |language|origin   |status|substatus|description     |
|=------------------+------+-------+------------+--------+---------+------+---------+---------------=|
|2026-11-18 14:32:16|DEjWwy|DEMO   |JOB_DocLB_A1|java    |tAssert_1|Ok    |--       |At least one row|
'-------------------+------+-------+------------+--------+---------+------+---------+----------------'

.-------------------+------+-------+------------+--------+---------+------+---------------------+--------------.
|                                                  tLogRow_1                                                   |
|=------------------+------+-------+------------+--------+---------+------+---------------------+-------------=|
|moment             |pid   |project|job         |language|origin   |status|substatus            |description   |
|=------------------+------+-------+------------+--------+---------+------+---------------------+-------------=|
|2026-11-18 14:32:16|DEjWwy|DEMO   |JOB_DocLB_A1|java    |tAssert_2|Failed|Test logically failed|At most 2 rows|
'-------------------+------+-------+------------+--------+---------+------+---------------------+--------------'

End of job

Chaque tAssert produit son message au moment où il s'exécute : d'où deux tableaux, un par message. Après le Failed, le job continue (tJava_2 s'exécute) et se termine avec le code 0. Each tAssert produces its message when it runs: hence two tables, one per message. After the Failed, the job goes on (tJava_2 runs) and ends with code 0.

Dans un flux : une vérification par ligneIn a flow: one check per row

row1 (Main) tFixedFlowInput_1 tAssert_1

Trois lignes name, amount : pen 12, ink -3, paper 40. Expression : row1.amount > 0 ; Description : "Amount of " + row1.name. Three name, amount rows: pen 12, ink -3, paper 40. expression: row1.amount > 0; description: "Amount of " + row1.name.

.-------------------+------+-------+------------+--------+---------+------+---------+-------------.
|                                            tLogRow_1                                            |
|=------------------+------+-------+------------+--------+---------+------+---------+------------=|
|moment             |pid   |project|job         |language|origin   |status|substatus|description  |
|=------------------+------+-------+------------+--------+---------+------+---------+------------=|
|2026-11-18 14:32:25|ief7BA|DEMO   |JOB_DocLB_A4|java    |tAssert_1|Ok    |--       |Amount of pen|
'-------------------+------+-------+------------+--------+---------+------+---------+-------------'

.-------------------+------+-------+------------+--------+---------+------+---------------------+-------------.
|                                                  tLogRow_1                                                  |
|=------------------+------+-------+------------+--------+---------+------+---------------------+------------=|
|moment             |pid   |project|job         |language|origin   |status|substatus            |description  |
|=------------------+------+-------+------------+--------+---------+------+---------------------+------------=|
|2026-11-18 14:32:25|ief7BA|DEMO   |JOB_DocLB_A4|java    |tAssert_1|Failed|Test logically failed|Amount of ink|
'-------------------+------+-------+------------+--------+---------+------+---------------------+-------------'

.-------------------+------+-------+------------+--------+---------+------+---------+---------------.
|                                             tLogRow_1                                             |
|=------------------+------+-------+------------+--------+---------+------+---------+--------------=|
|moment             |pid   |project|job         |language|origin   |status|substatus|description    |
|=------------------+------+-------+------------+--------+---------+------+---------+--------------=|
|2026-11-18 14:32:25|ief7BA|DEMO   |JOB_DocLB_A4|java    |tAssert_1|Ok    |--       |Amount of paper|
'-------------------+------+-------+------------+--------+---------+------+---------+---------------'

Un message par ligne, les lignes correctes comprises. Sur un grand flux, cela fait autant de lignes dans le journal que dans le flux : filtrez plutôt la sortie du tAssertCatcher sur status, ou vérifiez un total après le flux. One message per row, the correct rows included. On a large flow, this gives as many log rows as flow rows: rather filter the tAssertCatcher output on status, or check a total after the flow.

Sans tAssertCatcherWithout a tAssertCatcher

Le premier job, sans le tAssertCatcher ni son tLogRow : The first job, without the tAssertCatcher and its tLogRow:

Loaded 3 rows
End of job

Rien n'indique que la deuxième condition est fausse ; code de sortie 0. Même résultat avec un tAssertCatcher dont la case Capturer les tAssert est décochée. Nothing tells that the second condition is false; exit code 0. Same result with a tAssertCatcher whose Catch tAssert box is unchecked.

Deux tAssertCatcherTwo tAssertCatcher components

tJava_1 puis le tAssert « At most 2 rows », et deux tAssertCatcher, chacun vers un tLogRow en mode Simple : tJava_1 then the "At most 2 rows" tAssert, and two tAssertCatcher components, each to a tLogRow in Basic mode:

Loaded 3 rows
2026-11-18 14:32:51|5ZNHBu|DEMO|JOB_DocLB_A13|java|tAssert_1|Failed|Test logically failed|At most 2 rows
2026-11-18 14:32:51|5ZNHBu|DEMO|JOB_DocLB_A13|java|tAssert_1|Failed|Test logically failed|At most 2 rows

Chaque tAssertCatcher reçoit le message : l'un peut écrire dans la console, l'autre dans un fichier ou une table. Each tAssertCatcher receives the message: one can write to the console, the other to a file or a table.

PiègesPitfalls

Une expression qui lève une exception arrête le jobAn expression that throws an exception stops the job

tJava_1 ne range pas count ; l'expression ((Integer) globalMap.get("count")) > 0 convertit alors null en nombre. Trace abrégée : tJava_1 does not store count; the expression ((Integer) globalMap.get("count")) > 0 then converts null to a number. Shortened trace:

count is not set
Exception in component tAssert_1 (JOB_DocLB_A11)
java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.Map.get(Object)" is null
	at demo.job_doclb_a11_0_1.JOB_DocLB_A11.tAssert_1Process(JOB_DocLB_A11.java:650)
	…
.-------------------+------+-------+-------------+--------+------+------+-------------------+------------------------------------------------------------------------------------------------------------.
|                                                                                               tLogRow_1                                                                                                |
|=------------------+------+-------+-------------+--------+------+------+-------------------+-----------------------------------------------------------------------------------------------------------=|
|moment             |pid   |project|job          |language|origin|status|substatus          |description                                                                                                 |
|=------------------+------+-------+-------------+--------+------+------+-------------------+-----------------------------------------------------------------------------------------------------------=|
|2026-11-18 14:32:46|3GHi3M|DEMO   |JOB_DocLB_A11|java    |null  |Failed|Job execution error|Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.Map.get(Object)" is null|
'-------------------+------+-------+-------------+--------+------+------+-------------------+------------------------------------------------------------------------------------------------------------'

Ce n'est plus un Failed du tAssert : c'est une erreur Java, et le job s'arrête avec le code 1. Le tAssertCatcher la reçoit quand même (case Capturer les exceptions Java), avec Job execution error et sans nom de composant. Écrivez une expression qui supporte null : globalMap.get("count") != null && ((Integer) globalMap.get("count")) > 0. This is no longer a Failed from the tAssert: it is a Java error, and the job stops with code 1. The tAssertCatcher still receives it (Catch Java Exception box), with Job execution error and no component name. Write an expression that copes with null: globalMap.get("count") != null && ((Integer) globalMap.get("count")) > 0.

Expression vide : le job ne compile pasEmpty expression: the job does not compile

Un tAssert dont l'Expression est restée vide (sa valeur par défaut), dans un job qui a un tAssertCatcher : A tAssert whose expression was left empty (its default value), in a job that has a tAssertCatcher:

JOB_DocLB_A12.java:430: error: illegal start of expression
 if() {
    ^
1 error

Description vide, sans guillemets : le job ne compile pasEmpty description, without quotes: the job does not compile

Le modèle remplace une Description tout à fait vide par null, que Java ne sait pas attribuer à l'une des deux méthodes addMessage (description ou exception). Message de compilation abrégé : The template replaces a completely empty description with null, which Java cannot assign to one of the two addMessage methods (description or exception). Shortened compilation message:

JOB_DocLB_B1.java:652: error: reference to addMessage is ambiguous
	tAssertCatcher_1.addMessage(pid, projectName, jobName, "java", "tAssert_1", "Ok", "--", null);
	                ^
  both method addMessage(String,String,String,String,String,String,String,String) in AssertCatcherUtils and method addMessage(String,String,String,String,String,String,String,Exception) in AssertCatcherUtils match
…

La valeur par défaut, "", compile : la colonne description est alors vide. The default value, "", compiles: the description column is then empty.

Un échec ne change pas le code de sortieA failure does not change the exit code

Le job se termine avec le code 0 même si toutes les conditions sont fausses. Pour qu'un échec arrête le job, faites suivre le tAssertCatcher d'un tFilterRow sur status puis d'un tDie, ou testez la même condition dans un Run if vers un tDie. The job ends with code 0 even if all the conditions are false. For a failure to stop the job, follow the tAssertCatcher with a tFilterRow on status then a tDie, or test the same condition in a Run if to a tDie.

Le tLogCatcher ne le voit pasThe tLogCatcher does not see it

Les messages du tAssert ne vont qu'aux tAssertCatcher. Le tLogCatcher reçoit ceux des tWarn et des tDie. The messages of the tAssert only go to the tAssertCatcher components. The tLogCatcher receives those of tWarn and tDie.

ConseilsTips

Une description qui se suffitA self-sufficient description

Le message ne contient ni l'expression ni les valeurs testées. Mettez-les dans la description : "Rows loaded: " + globalMap.get("tDBOutput_1_NB_LINE") + " (expected > 0)". The message holds neither the expression nor the tested values. Put them in the description: "Rows loaded: " + globalMap.get("tDBOutput_1_NB_LINE") + " (expected > 0)".

Vérifier après le sous-jobCheck after the subjob

Les variables NB_LINE ne sont remplies qu'à la fin du composant qui les produit : reliez le tAssert par On Subjob Ok ou On Component Ok, pas au milieu du flux qu'il contrôle. The NB_LINE variables are only filled at the end of the component that produces them: connect the tAssert with On Subjob Ok or On Component Ok, not in the middle of the flow it checks.

Voir aussiSee also