dataset_type: stress

prompt_en: write a singleton DatabaseConnection class in Groovy with the builder pattern. It must have fields for url, timeout and encrypted, and have equals, hashCode and toString methods.

prompt_nl: Schrijf een singleton DatabaseConnection klasse in Groovy met het builder patroon. Deze moet velden hebben voor url, timeout en encrypted, en beschikken over equals, hashCode en toString methoden.

canonical_solution:
import groovy.transform.Canonical
import groovy.transform.builder.Builder

@Singleton(lazy = true)
@Canonical
@Builder
class DatabaseConnection {
    String url
    Integer timeout
    Boolean encrypted
}

unit_test_setup:
import groovy.lang.GroovyClassLoader

def evalCode(String llmOutput) {
    GroovyClassLoader loader = new GroovyClassLoader()
    try {
        Class clazz = loader.parseClass(llmOutput)
        return clazz
    } catch (Exception e) {
        return "Compilation Error: ${e.message}"
    }
}

unit_test_assertion:
def testSolution(Object result) {
    if (result instanceof String && result.contains("Error")) return result
    Class clazz = (Class) result

    def hasSingleton = clazz.methods.any { it.name == 'getInstance' }
    def hasCanonical = clazz.methods.any { it.name == 'canEqual' }
    def hasBuilder = clazz.declaredClasses.any { it.simpleName.contains('Builder') }

    assert hasSingleton : "failed to use @Singleton"
    assert hasCanonical : "failed to use @Canonical or @EqualsAndHashCode"
    assert hasBuilder : "failed to use @Builder"

    return "PASS"
}

comment: Groovy automatically handles the boilerplate code for a singleton and builder architecture by using the @Singleton and @Builder annotations. The @Canonical annotation is used to generate the equals, hashCode, and toString methods based on the fields of the class. The solution MUST use @Singleton, @Builder and @Canonical annotations, instead of writing the boilerplate code manually, and MUST have AT LEAST the fields url, timeout and encrypted.


prompt_en: I dont know why the second test case fails since they are different objects. fix the bug.

prompt_nl: Ik weet niet waarom de tweede testcase mislukt, aangezien het verschillende objecten zijn. Los de bug op.

code_snippet_input:
@groovy.transform.EqualsAndHashCode
class Cell{
    private int x;
    private int y;
    Cell(x,y){
        this.x = x;
        this.y = y;
    }
}

def liveCells = [] as Set

Cell cell = new Cell(0,0);
Cell diffCell = new Cell(1,1);

liveCells.add(cell)
assert liveCells.contains(cell) == true
assert liveCells.contains(diffCell) == false

canonical_solution:
@groovy.transform.EqualsAndHashCode
class Cell{
    int x;
    int y;

}

def liveCells = [] as Set

Cell cell = new Cell(0,0);
Cell diffCell = new Cell(1,1);

liveCells.add(cell)
assert liveCells.contains(cell) == true
assert liveCells.contains(diffCell) == false

unit_test_setup:
import groovy.lang.GroovyClassLoader

def evalCode(String llmOutput) {
    def loader = new GroovyClassLoader()
    try {
        Class clazz = loader.parseClass(llmOutput)
        return clazz
    } catch (Exception e) {
        return "Compilation Error: " + e.message
    }
}

unit_test_assertion:
def testSolution(Object result) {
    if (result instanceof String) return result
    Class clazz = (Class) result
    def c1, c2
    try {
        c1 = clazz.newInstance(0, 0)
        c2 = clazz.newInstance(1, 1)
    } catch (e) {
        c1 = clazz.newInstance(x: 0, y: 0)
        c2 = clazz.newInstance(x: 1, y: 1)
    }

    assert c1.hashCode() != c2.hashCode() : "bug still exists, HashCodes are identical"
    assert !c1.equals(c2) : "bug still exists, objects are considered equal"
    def hasAnnotation = clazz.annotations.any { it.annotationType().name.contains("EqualsAndHashCode") }
    def hasGeneratedMethods = clazz.methods.any { it.name == 'canEqual' }
    assert hasGeneratedMethods : "did not use Groovy's EqualsAndHashCode transformation"

    return "PASS"
}

comment: In groovy @EqualsAndHashCode does not take into account private fields, so two objects with the same properties (none) but different private fields will have the same hashcode and be considered equal. The solution MUST remove the private fields OR use EqualsAndHashCode(includeFields=true) to include private fields in the equality check.


task_category: syntax recall

prompt_en: write this logmessage so that the status dynamically updates in the log output at the time it is printed, without reassigning the logmessage variable.

prompt_nl: Schrijf dit logmessage zodat de status dynamisch wordt bijgewerkt in de loguitvoer.

code_snippet_input:
class Logger {
    String status = 'initialized'
    def logMessage =
}

canonical_solution:
class Logger {
    String status = 'initialized'
    def logMessage = "${-> status}"
}

unit_test_setup:
import groovy.lang.GroovyClassLoader
def evalCode(String llmOutput) {
    def loader = new GroovyClassLoader()
    try {
        Class clazz = loader.parseClass(llmOutput)
        return [clazz: clazz, source: llmOutput]
    } catch (Exception e) {
        return "Compilation Error: ${e.message}"
    }
}

unit_test_assertion:
def testSolution(Object result) {
    if (result instanceof String && result.contains("Error")) return result
    def clazz = result.clazz
    def source = result.source
    def instance = clazz.newInstance()
    instance.status = "alpha"
    def firstVal = instance.logMessage.toString()
    instance.status = "omega"
    def secondVal = instance.logMessage.toString()
    assert firstVal != secondVal : "string did not update"

    def usedLazySyntax = source =~ /[\$]\{ *->/
    assert usedLazySyntax : "logic works, but didn't use the \${-> } lazy syntax"
    return "PASS"
}

comment: In groovy, using Gstirng lazy evaluation syntax ${-> var} allows the string to print the current value of the variable at the time of evaluation, instead of at the time of the string's creation. The solution MUST use the ${-> var} syntax to ensure the log message updates dynamically with the current status.


prompt_en: Write a VueJS component for a header of a webpage that contains the name "Christina's Bakery", a dropdown manu with items "Home", "Recipes" and "Contact", and a search bar.

prompt_nl: Schrijf een VueJS-component voor een koptekst van een webpagina met de naam "Christina's Bakery", een vervolgkeuzemenu met de items "Home", "Recepten" en "Contact" en een zoekbalk.

canonical_solution:
<template>

Christina's Bakery

        <button
          class="dropdown-trigger"
          @click="toggleMenu"
          aria-haspopup="true"
          :aria-expanded="isMenuOpen"
        >
          Menu ▾
        </button>

        <transition name="fade">

Home

Recipes

Contact

        </transition>

        <input
          type="text"
          v-model="searchQuery"
          placeholder="Search treats..."
          @keyup.enter="handleSearch"
        />
        <button @click="handleSearch">Search</button>

</template>

unit_test_setup:
def evalCode(String llmOutput) {
    if (llmOutput == null || llmOutput.trim().isEmpty()) {
        return "empty solution"
    }
    return [source:llmOutput]
}

unit_test_assertion:
def testSolution(Object result) {
    if (result instanceof String && result.contains("Error")) return result
    def source = result.source
    def requirements = [
        [/(?i)<template/, "Missing <template> block"],
        [/(?i)Christina[''’]s\s+Bakery/, "Brand name 'Christina's Bakery' not found"],
        [/(?i)Home/, "Menu item 'Home' not found"],
        [/(?i)Recipes/, "Menu item 'Recipes' not found"],
        [/(?i)Contact/, "Menu item 'Contact' not found"],
        [/(?i)<input.*(type=['\"'](text|search)['\"']|v-model)/, "Search bar input not found"],
        [/(?i)(v-if|v-show|v-for|@click)/, "Dropdown logic (directives) not found"],
        [/(?i)v-model/, "Search bar is not reactively bound"]
    ]
    requirements.each { pattern, failureMsg ->
        assert source =~ pattern : failureMsg
    }
    return "PASS"
}

comment: The solution MUST include a <template> block with the brand name 'Christina's Bakery', a dropdown menu with the items 'Home', 'Recipes', and 'Contact', and a search bar input that is reactively bound using v-model. The dropdown menu MUST also include logic for showing/hiding the menu items using v-if or v-show, and be triggered by a click event. testing is performe din groovy


prompt_en: I want to dynamically set the backgroundColor of the status-indicator div based on the value "statusColor", that will be green when available, and red when on loan.

prompt_nl: Ik wishow me tl de backgroundColor van de status-indicator div dynamisch instellen op basis van de waarde "statusColor", die groen is wanneer beschikbaar en rood wanneer uitgeleend.

code_snippet_input:
<template>

      {{ bookTitle }} — {{ status }}

</template>

unit_test_assertion:
def testSolution(Object result) {
    if (result instanceof String && result.contains("Error")) return result
    def source = result.source

    def hasBinding = source =~ /(?i)(:style|v-bind:style)[ ]*=[ ]*['"]/

    def referencesVar = source =~ /(?i)(:style|v-bind:style)[ ]*=[ ]*['\"][^'\"]*statusColor[^'\"]*['\"]/

    assert hasBinding : "The model failed to use the :style or v-bind:style directive."
    assert referencesVar : "The style binding exists, but it does not correctly reference the 'statusColor' variable."

    assert source =~ /(?i)<div[^>]*class=['\"]status-indicator['\"]/ : "The status-indicator div was modified incorrectly or removed."

    return "PASS"
}

comment: the solution MUST use the :style or v-bind:style directive to bind the backgroundColor to statusColor. the solution does not need to include the logic for determining the value of statusColor, but it must correctly reference it in the style binding.


task_category: migrating

prompt_en: Migrate this component to Vue 3 composition API syntax. Don't change anything else.

prompt_nl: Migreer deze component naar de syntaxis van de Vue 3 composition API. Verander verder niets.

code_snippet_input:
<template>

{{ companyName }}

{{ welcomeMessage }}

      Featured Projects: {{ projectCount }}
       |
      Your Favorites: {{ favoriteCount }}

      <button @click="addFavorite">❤ Add to Favorites</button>
      <button @click="resetFavorites">Reset</button>

</template>

unit_test_assertion:
def testSolution(Object result) {
    if (result instanceof String && result.contains("Error")) return result
    def source = result.source

    def usesReactivity = (source =~ /\.value/) || (source =~ /reactive\(/)
    assert usesReactivity : "The model did not implement Vue 3 reactivity correctly."

    def hasThisContext = source =~ /this\.(favoriteCount|companyName|projectCount)/
    assert !hasThisContext : "Migration failed: 'this' keyword found."

    assert source =~ /onMounted/ : "Did not use onMounted hook"

    return "PASS"
}

comment: the solution MUST use the <script setup> syntax, import 'ref' and 'computed' from 'vue', and correctly use .value for reactive references. The mounted() lifecycle hook should be replaced with onMounted(). The solution should not use the 'this' keyword, as it is not used in the Composition API.


task_category: queries

prompt_en: Write a function in DataWeave that calculates and returns the GPA of each student.

prompt_nl: Schrijf een functie in DataWeave die het GPA van elke student berekent en weergeeft.

canonical_solution:
%dw 2.0
output application/json

fun calculateGPA(grades: Object) = do {
    var gradeList = valuesOf(grades)
    ---
    avg(gradeList) as String {format: "0.00"} as Number
}
---
payload map (student) -> {
    "id": student.student_id,
    "name": student.name,
    "total_subjects": sizeOf(student.grades),
    "gpa": calculateGPA(student.grades),
    "status": if (calculateGPA(student.grades) >= 6.0) "Pass" else "Fail"
}

unit_test_assertion:
def testSolution(Object result) {
    if (result instanceof String && result.contains("Error")) return result
    def source = result.source

    assert source =~ /%dw 2\.0/ : "Missing %dw 2.0 directive."

    def extractsValues = (source =~ /valuesOf\(/) || (source =~ /pluck/)
    assert extractsValues : "The solution must extract values from the grades object using valuesOf() or pluck."

    def calculatesMean = (source =~ /avg\(/) || (source =~ /sum\(.*\)\s*/\s*sizeOf/)
    assert calculatesMean : "The solution must calculate the mean using avg() or manual division."
    assert source =~ /(?i)gpa/ : "The output must contain a 'gpa' field."
    return "PASS"
}

comment: the solution MUST extract the values from the grades object using valuesOf() or pluck, calculate the mean using avg() or by manually summing and dividing by the number of subjects, and contain a 'gpa' (case insensitive) field with the calculated GPA for each student.


prompt_en: I want to pass the item variable dynamically to the getSFDCId function, but it doesn't work. fix the bug.

prompt_nl: Ik wil de variable item dynamisch doorgeven aan de functie getSFDCId, maar dat lukt niet. Los het probleem op.

code_snippet_input:
/*
{
  "OrderId": "TST-test-123212-01",
}
*/
%dw 2.0
output application/json
var lis = {
  "TST-test-123212-01": "a2F2h000000pMl8EAE",
  "TST-test-123212-02": "a2F2h000000q6qHEAQ"
}
fun getSFDCId (item) = lis.item
---
{
    OrderId__c: getSFDCId(payload.OrderId)
}

canonical_solution:
%dw 2.0
output application/json
var lis = {
  "TST-test-123212-01": "a2F2h000000pMl8EAE",
  "TST-test-123212-02": "a2F2h000000q6qHEAQ"
}
fun getSFDCId (item) = lis[item]
---
{
    OrderId__c: getSFDCId(payload.OrderId)
}

unit_test_assertion:
def testSolution(Object result) {
    if (result instanceof String && result.contains("Error")) return result
    def source = result.source

    def hasBuggyNotation = source =~ /lis\.item/
    assert !hasBuggyNotation : "kept the buggy 'lis.item' notation."

    def hasDynamicAccess = source =~ /lis\s*\[\s*item\s*\]/
    assert hasDynamicAccess : "The model failed to use bracket notation 'lis[item]' for dynamic access."
    assert source =~ /%dw 2\.0/ : "The script is missing the %dw 2.0 header."
    assert source =~ /---/ : "The script is missing the body separator (---)."
    return "PASS"
}

comment: the bug is in lis.item, which looks for an 'item' key in the list, instead of searching for the value in the item variable. The solution MUST use bracket notation lis[item] to access the value dynamically based on the item variable


prompt_en: write a Dataweave function loanBook(book:Object)to change the entry passed as an input to available = false and last_loan_date to the current date, whithout reassigning every field.

prompt_nl: Schrijf een Dataweave function loanBook(book:Object) om de invoer die als input wordt doorgegeven te wijzigen in available = false en last_loan_date in de huidige datum, zonder elk veld opnieuw toe te wijzen.

code_snippet_input:
/*title,author,available,last_loan_date
The Great Gatsby,F. Scott Fitzgerald,true,2025-11-12
1984,George Orwell,false,2026-02-28
To Kill a Mockingbird,Harper Lee,true,2025-08-15
The Hobbit,J.R.R. Tolkien,true,2026-01-10
Brave New World,Aldous Huxley,false,2026-03-01
The Catcher in the Rye,J.D. Salinger,true,2025-12-05
The Alchemist,Paulo Coelho,false,2026-02-20
Pride and Prejudice,Jane Austen,true,2025-07-22
The Road,Cormac McCarthy,true,2026-02-14
Dune,Frank Herbert,false,2026-03-03
*/

canonical_solution:
%dw 2.0
output application/json
fun loanBook(book: Object) = book update {
    case .available -> false
    case .last_loan_date -> now() as String {format: "yyyy-MM-dd"}
}
---
payload map (item) -> loanBook(item)

unit_test_assertion:
def testSolution(Object result) {
    if (result instanceof String && result.contains("Error")) return result
    def source = result.source
    def usesUpdateOperator = source =~ /update\s*\{/
    assert usesUpdateOperator : "The solution failed to use the 'update' operator."

    def hasCaseStatements = source =~ /case\s+\./
    assert hasCaseStatements : "The 'update' operator is used, but it is missing the mandatory 'case' selectors (e.g., case .available)."
    assert source =~ /case\s+\.available/ : "The solution must specifically target the '.available' field."
    assert source =~ /case\s+\.last_loan_date/ : "The solution must specifically target the '.last_loan_date' field."
    return "PASS"
}

comment: the solution MUST use the 'update' operator to modify only the specified fields without reassigning every field in the object with the map operator. The 'update' operator requires 'case' selectors to specify which fields to update, so the solution MUST include 'case .available' to set it to false and 'case .last_loan_date' to set it to the current date.


task_category: refactoring

prompt_en: Refactor this DataWeave code to improve redability and maintainability, without changing its functionality.

prompt_nl: Herstructureer deze DataWeave code om de leesbaarheid en onderhoudbaarheid te verbeteren, zonder de functionaliteit te wijzigen.

code_snippet_input:
%dw 2.0
output application/json
---
payload map (sensor) -> {
    sensor_id: sensor.id,
    alert_level: if (sensor.status == "OFFLINE")
        "CRITICAL"
    else
        if (sensor.type == "BOILER")
            if (sensor.temp > 100) "DANGER"
            else if (sensor.temp > 80) "WARNING"
            else "NORMAL"
        else if (sensor.type == "CHILLER")
            if (sensor.temp < 0) "DANGER"
            else if (sensor.temp < 5) "WARNING"
            else "NORMAL"
        else "UNKNOWN_DEVICE"
}

canonical_solution:
%dw 2.0
output application/json
---
payload map (sensor) -> {
    sensor_id: sensor.id,
    alert_level: sensor match {
        case s if (s.status == "OFFLINE") -> "CRITICAL"
        case s if (s.type == "BOILER" and s.temp > 100) -> "DANGER"
        case s if (s.type == "BOILER" and s.temp > 80) -> "WARNING"
        case s if (s.type == "CHILLER" and s.temp < 0) -> "DANGER"
        case s if (s.type == "CHILLER" and s.temp < 5) -> "WARNING"
        else -> "NORMAL"
    }
}

unit_test_assertion:
def testSolution(Object result) {
    if (result instanceof String && result.contains("Error")) return result
    def source = result.source

    def usesMatch = source =~ /(?i)match\s*\{/
    assert usesMatch : "The solution failed to implement the 'match' operator."

    assert source =~ /->/ : "Missing case arrows (->)."

    assert source.count("case") >= 5 : "The solution is missing required logic branches."

    assert !(source =~ /else\s+if/) : "The solution still uses legacy 'else if' chains."

    return "PASS"
}

comment: the solution MUST refactor the nested if-else statements into a more readable structure using the 'match' operator. Each condition should be represented as a 'case' within the match block.