smiklosovic commented on code in PR #3931: URL: https://github.com/apache/cassandra/pull/3931#discussion_r1984647912
########## test/unit/org/apache/cassandra/config/ParameterizedClassTest.java: ########## @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.config; + +import java.util.List; +import java.util.Map; + +import org.junit.Rule; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.startsWith; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.apache.cassandra.auth.AllowAllAuthorizer; +import org.apache.cassandra.auth.IAuthorizer; +import org.apache.cassandra.exceptions.ConfigurationException; +import org.junit.rules.ExpectedException; + +public class ParameterizedClassTest +{ + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); Review Comment: @tiagomlalves I don't see `@Rule` used often in tests (but checking, and we _do_ use it). I prefer `Assertions.assertThrownBy` more as it is more succinct and easier for an eye. I can imagine that it might make these tests more friendly for a reader. @Test public void newInstance_WithConstructorException_PreservesOriginalFailure() { assertThatThrownBy(() -> ParameterizedClass.newInstance(new ParameterizedClass(ParameterizedClassExample.class.getName(), Map.of("fail", "true")), null)) .hasMessageContaining("Simulated failure") .hasMessageStartingWith("Failed to instantiate class") .isInstanceOf(ConfigurationException.class); } -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org