Skip to content
Draft
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
@@ -0,0 +1,25 @@
package com.avaloq.tools.ddk.check.validation

import com.avaloq.tools.ddk.check.testLanguage.Greeting

catalog ExecutionEnvironment
for grammar com.avaloq.tools.ddk.check.TestLanguage {

category DefaultCategory "Test category" {

/** Checks the greeting name length */
onSave error GreetingNameLength "Greeting name length" (String defaultName = "Franz")
message "Greeting name {0}" {

for Greeting g {
if (g.name.length > 5) {
issue bind ("too long") data namelength (null)
} else if (g.name.equals(defaultName)) {
issue bind ("must not be Franz") data franzname (null)
}
}

}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ExecutionEnvironment</title>
<style>
:root {
--bg: #ffffff;
--text: #1f2328;
--text-muted: #57606a;
--border: #d0d7de;
--card-bg: #f6f8fa;
--code-bg: #f6f8fa;
--link: #0969da;
--accent: #218bff;
--sev-error-bg: #ffe5e5; --sev-error-text: #82071e; --sev-error-border: #ffadb0;
--sev-warning-bg: #fff8c5; --sev-warning-text: #633c01; --sev-warning-border: #f3df5b;
--sev-info-bg: #ddf4ff; --sev-info-text: #054a72; --sev-info-border: #80ccff;
--sev-ignore-bg: #eaeef2; --sev-ignore-text: #57606a; --sev-ignore-border: #d0d7de;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #0d1117;
--text: #e6edf3;
--text-muted: #8d96a0;
--border: #30363d;
--card-bg: #161b22;
--code-bg: #161b22;
--link: #58a6ff;
--accent: #1f6feb;
--sev-error-bg: #3d1419; --sev-error-text: #ffa198; --sev-error-border: #6e1216;
--sev-warning-bg: #3a2c00; --sev-warning-text: #f0d97c; --sev-warning-border: #7a5a00;
--sev-info-bg: #0c2d4a; --sev-info-text: #79c0ff; --sev-info-border: #1f6feb;
--sev-ignore-bg: #1c2128; --sev-ignore-text: #8d96a0; --sev-ignore-border: #30363d;
}
}
* { box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
font-size: 16px;
line-height: 1.55;
color: var(--text);
background: var(--bg);
max-width: 820px;
margin: 0 auto;
padding: 2rem 1.25rem 4rem;
}
h1 { font-size: 1.875rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.375rem; margin: 2rem 0 1rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.05rem; margin: 0; }
p { margin: 0.5rem 0; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
header.catalog-header { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
header.catalog-header p { color: var(--text-muted); }
nav.jump {
margin-top: 1rem;
padding: 0.75rem 1rem;
background: var(--card-bg);
border: 1px solid var(--border);
border-radius: 6px;
font-size: 0.9rem;
}
nav.jump strong { display: block; margin-bottom: 0.4rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
nav.jump ul { margin: 0; padding-left: 1.25rem; }
nav.jump li { margin: 0.15rem 0; }
section.category { margin: 2rem 0; }
section.category > p { color: var(--text-muted); margin-bottom: 0.75rem; }
article.check {
margin: 0.75rem 0;
padding: 0.85rem 1.15rem;
background: var(--card-bg);
border: 1px solid var(--border);
border-radius: 6px;
}
article.check > header {
display: flex;
align-items: baseline;
gap: 0.6rem;
flex-wrap: wrap;
}
article.check a.anchor {
visibility: hidden;
color: var(--text-muted);
font-weight: 400;
font-size: 0.85em;
}
article.check > header:hover a.anchor { visibility: visible; }
article.check:target {
border-color: var(--accent);
box-shadow: 0 0 0 3px rgba(33, 139, 255, 0.18);
}
.severity {
display: inline-block;
padding: 0.1rem 0.6rem;
font-size: 0.72rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
border-radius: 999px;
border: 1px solid transparent;
white-space: nowrap;
}
.severity.sev-error { background: var(--sev-error-bg); color: var(--sev-error-text); border-color: var(--sev-error-border); }
.severity.sev-warning { background: var(--sev-warning-bg); color: var(--sev-warning-text); border-color: var(--sev-warning-border); }
.severity.sev-info { background: var(--sev-info-bg); color: var(--sev-info-text); border-color: var(--sev-info-border); }
.severity.sev-ignore { background: var(--sev-ignore-bg); color: var(--sev-ignore-text); border-color: var(--sev-ignore-border); }
pre.message {
margin: 0.6rem 0 0;
padding: 0.55rem 0.8rem;
background: var(--code-bg);
border: 1px solid var(--border);
border-radius: 6px;
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
font-size: 0.85rem;
white-space: pre-wrap;
word-break: break-word;
}
pre.message::before {
content: "Message";
display: block;
font-family: inherit;
font-size: 0.68rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--text-muted);
margin-bottom: 0.2rem;
}
ul.catalog-list { list-style: none; padding: 0; margin: 1.5rem 0 0; }
ul.catalog-list li {
margin: 0.75rem 0;
padding: 1rem 1.25rem;
background: var(--card-bg);
border: 1px solid var(--border);
border-radius: 6px;
}
ul.catalog-list li h2 { margin: 0; border-bottom: none; padding-bottom: 0; font-size: 1.2rem; }
ul.catalog-list li p { color: var(--text-muted); margin: 0.25rem 0 0; }
</style>
</head>
<body>
<header class="catalog-header">
<h1>ExecutionEnvironment</h1>
<nav class="jump">
<strong>Jump to</strong>
<ul>
<li><a href="#executionenvironment_testcategory">Test category</a></li>
</ul>
</nav>
</header>
<main>
<section class="category">
<h2 id="executionenvironment_testcategory">Test category</h2>
<p>Checks the greeting name length</p>
<article class="check" id="executionenvironment_greetingnamelength">
<header>
<h3>Greeting name length <a class="anchor" href="#executionenvironment_greetingnamelength">#</a></h3>
<span class="severity sev-error">error</span>
</header>
Checks the greeting name length
<pre class="message">Greeting name ...</pre>
</article>
</section>
</main>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package com.avaloq.tools.ddk.check.validation

import com.avaloq.tools.ddk.check.lib.IResourceCache
import com.avaloq.tools.ddk.check.testLanguage.Greeting
import com.google.inject.Inject
import java.util.List
import com.google.common.collect.ImmutableList

/**
* Check catalog for com.avaloq.tools.ddk.check.TestLanguage
*/
catalog LibraryChecks
for grammar com.avaloq.tools.ddk.check.TestLanguage {

@Inject IResourceCache cache;


category InjectionChecks "Checks on injections in check catalogs." {

/** Warning to indicate that this catalog is active. */
live warning CheckCatalogIsActive "Check catalog is active"
message "Catalog is active" {
for Greeting {
issue;
}
}

/** Error if the injection didn't work. */
live error CacheInjectionFailed "Cache injection failed"
message "Cache was not injected" {
for Greeting g {
if (cache === null) {
issue;
}
}
}

/** Error if values cannot be read from cache. */
live error CacheDoesntWork "Cache doesn't work"
message "{0}" {
for Greeting {
val String key = this.qualifiedCatalogName + ".testValue";
try {
cache.put(it, key, Boolean.TRUE);
val Boolean value = cache.get(it, key);
if (value === null || !value) {
issue bind ("Could not read value from cache: " + value);
}
} catch (Throwable t) {
issue bind ("Exception in cache access: " + t.getMessage());
}
}
}
}

category FormalParameterChecks "Checks on formal parameters" {

/** Test formal parameter access. */
live error FormalParameters "Formal Parameters"
(String param1 = "param1", boolean param2 = !!true, Boolean param3 = false, List<String> names = #['foo', 'bar', 'ba\u0001\nz'], List<Integer> ints = #[5, -42, 7])
message "{0}" {
for Greeting {
val String p1 = param1;
val boolean p2 = false;
val List<String> expectedNames = ImmutableList::of('foo', 'bar', 'ba\u0001\nz');
val expectedInts = #[5, -42, 7];
if (!"param1".equals(p1)) {
issue bind ('String parameter wrong (expected "param1"): ' + p1);
}
if (p2 != param3 || !p2 != param2) {
issue bind ("Boolean parameter wrong.");
}
var int i = 0;
val List<String> names = names; // Whoa!
if (names.size != expectedNames.size) {
issue bind ("Expected three names, got " + names.size);
} else {
while (i < names.size) {
if (!expectedNames.get(i).equals(names.get(i))) {
issue bind ('String mismatch in list, expected "' + expectedNames.get(i) + '" but got "' + names.get(i) + '"')
}
i = i + 1;
}
}
val INTS = ints;
if (INTS.size != expectedInts.size) {
issue bind('Expected three ints, got ' + INTS.size);
}
i = 0;
while (i < INTS.size) {
if (expectedInts.get(i).intValue != INTS.get(i).intValue) {
issue bind ('Integer mismatch at index ' + i + ':' + expectedInts.get(i) + ' != ' + INTS.get(i));
}
i = i + 1;
}
}
}
}
}
Loading