ThemeQueryCatalogComplexityTest.java

/*******************************************************************************
 * Copyright (c) 2025 Eclipse RDF4J contributors.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Distribution License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 *******************************************************************************/
// Some portions generated by Codex
package org.eclipse.rdf4j.benchmark.common;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.List;
import java.util.Locale;

import org.eclipse.rdf4j.benchmark.rio.util.ThemeDataSetGenerator.Theme;
import org.junit.jupiter.api.Test;

class ThemeQueryCatalogComplexityTest {

	private static final List<String> COMPLEX_MARKERS = List.of(
			"OPTIONAL",
			"UNION",
			"FILTER EXISTS",
			"FILTER NOT EXISTS",
			"MINUS",
			"BIND(",
			"VALUES",
			"GROUP BY",
			"HAVING");

	@Test
	void eachThemeHasEightComplexQueries() {
		for (Theme theme : Theme.values()) {
			List<String> queries = ThemeQueryCatalog.queriesFor(theme);
			assertEquals(ThemeQueryCatalog.QUERY_COUNT, queries.size(),
					"Unexpected query count for theme " + theme);
			for (int index = 0; index < queries.size(); index++) {
				String query = queries.get(index);
				String normalized = query.toUpperCase(Locale.ROOT);
				long markers = COMPLEX_MARKERS.stream()
						.filter(normalized::contains)
						.count();
				assertTrue(markers >= 2,
						"Theme " + theme + " query " + index + " lacks complexity markers: " + query);
			}
		}
	}
}