Skip to content

Commit

Permalink
Remove deprecated code.
Browse files Browse the repository at this point in the history
  • Loading branch information
paveljandejsek committed Mar 4, 2024
1 parent 8e20f2e commit 08be1e9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ public void parse(String filterAsString) {
*/
public boolean match(Meta meta) {
try {
Object matcher = this.groovyClass.newInstance();
Object matcher = this.groovyClass.getDeclaredConstructor().newInstance();
this.metaField.set(matcher, meta);
return (Boolean) this.match.invoke(matcher);
} catch (InstantiationException | InvocationTargetException | IllegalAccessException e) {
} catch (InstantiationException | InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
throw new IllegalArgumentException("Can't instantiate dynamic groovy matcher", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
Expand Down Expand Up @@ -51,11 +50,14 @@ public void check() {
.build();

HttpGet httpGet = new HttpGet(url);
CloseableHttpResponse response = httpclient.execute(httpGet);
if (response.getCode() != 200) {
throw new IllegalStateException(
"Status code is " + response.getCode() + ". " + response.getReasonPhrase());
}
httpclient.execute(httpGet, response -> {
if (response.getCode() != 200) {
throw new IllegalStateException(
"Status code is " + response.getCode() + ". " + response.getReasonPhrase());
}
return null;
});

} catch (IOException | NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
throw new IllegalStateException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
Expand Down Expand Up @@ -144,7 +145,7 @@ public REQUEST createRequest() {
prefix = requestClazz.getSimpleName();
}
try {
REQUEST request = requestClazz.newInstance();
REQUEST request = requestClazz.getDeclaredConstructor().newInstance();
factoryContext.put(prefix, request);
handleKeys();
return request;
Expand Down Expand Up @@ -223,7 +224,7 @@ private void handleCollectionIndexStep() throws ReflectiveOperationException {
if (isAbstract(type)) {
throw new UnsupportedOperationException("Abstract classes are not supported as generic");
}
Object value = type.newInstance();
Object value = type.getDeclaredConstructor().newInstance();
Object collection = factoryContext.get(pathPrevious);
((Collection) collection).add(value);
factoryContext.put(pathCurrent, value);
Expand All @@ -239,7 +240,7 @@ private void handleNestedStep() throws ReflectiveOperationException {
} else if (isAssignable(type, JAXBElement.class)) {
value = resolveJaxbElement(testContext, pathCurrent, null);
} else if (!isAbstract(type)) {
value = type.newInstance();
value = type.getDeclaredConstructor().newInstance();
} else {
throw new IllegalStateException(
"Field " + pathCurrent + " is abstract. Please provide fully qualified class name in example table or register custom handler");
Expand Down Expand Up @@ -368,10 +369,10 @@ private XmlElementRef getXmlElementRef() {

private Object instantiateClass(Class<?> toInstantiate) {
try {
return toInstantiate.newInstance();
return toInstantiate.getDeclaredConstructor().newInstance();
} catch (IllegalAccessException e) {
throw new IllegalStateException("Provided implementation is not accessible: " + toInstantiate.getSimpleName(), e);
} catch (InstantiationException e) {
} catch (InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalStateException("Provided implementation could not be instantiated: " + toInstantiate.getSimpleName(), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class CompareExpectedRowsFalseStrictMatch extends Specification {
def expectations = new ExamplesTable("| INT | DOUBLE | DECIMAL | STRING | DATE |\r\n"
+ "| 1 | 1.01 | 10.01 | fsa#df | 2010-10-10T10:10:10 |\r\n")
def row = new HashMap<String,Object>(){{
put("INT",new Integer(1))
put("DOUBLE",new Double(1.01))
put("INT", Integer.valueOf(1))
put("DOUBLE", Double.valueOf(1.01))
put("DECIMAL",new BigDecimal("10.01"))
put("STRING",new String("fsa#df"))
put("DATE", LocalDateTime.of(2010, Month.OCTOBER, 10, 10, 10, 10))}}
Expand Down

0 comments on commit 08be1e9

Please sign in to comment.