SolrAutoConfigurationDisablerTest.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.tools.serverboot.config;

import static org.assertj.core.api.Assertions.assertThatCode;

import java.util.Map;

import org.junit.jupiter.api.Test;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.StandardEnvironment;

class SolrAutoConfigurationDisablerTest {

	@Test
	void updateEnvironmentDoesNotThrowWhenPropertySourceAlreadyPresent() {
		ConfigurableEnvironment environment = new StandardEnvironment();
		environment.getPropertySources()
				.addFirst(new MapPropertySource("rdf4jSolrAutoConfiguration",
						Map.of("spring.autoconfigure.exclude", "com.example.ExistingAutoConfig")));

		SolrAutoConfigurationDisabler disabler = new SolrAutoConfigurationDisabler();

		assertThatCode(() -> disabler.postProcessEnvironment(environment, null)).doesNotThrowAnyException();
	}
}