diff --git a/jmeter-java-dsl-azure/src/main/java/us/abstracta/jmeter/javadsl/azure/AzureClient.java b/jmeter-java-dsl-azure/src/main/java/us/abstracta/jmeter/javadsl/azure/AzureClient.java index 76e8b4b0..5fc6a994 100644 --- a/jmeter-java-dsl-azure/src/main/java/us/abstracta/jmeter/javadsl/azure/AzureClient.java +++ b/jmeter-java-dsl-azure/src/main/java/us/abstracta/jmeter/javadsl/azure/AzureClient.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.io.File; import java.io.IOException; +import java.net.HttpURLConnection; import java.nio.charset.StandardCharsets; import java.time.Instant; import java.util.Base64; @@ -47,11 +48,11 @@ import us.abstracta.jmeter.javadsl.engines.BaseRemoteEngineApiClient; import us.abstracta.jmeter.javadsl.util.TestResource; + public class AzureClient extends BaseRemoteEngineApiClient { private static final Logger LOG = LoggerFactory.getLogger(AzureClient.class); private static final String USER_AGENT = getUserAgent(); - private static final int HTTP_NOT_FOUND = 404; private final String tenantId; private final String clientId; @@ -267,7 +268,7 @@ public ResourceGroup findResourceGroup(String name, Subscription subscription) private Optional execOptionalApiCall(Call call) throws IOException { retrofit2.Response response = call.execute(); if (!response.isSuccessful()) { - if (response.code() == HTTP_NOT_FOUND) { + if (response.code() == HttpURLConnection.HTTP_NOT_FOUND) { return Optional.empty(); } try (ResponseBody errorBody = response.errorBody()) { diff --git a/jmeter-java-dsl-dashboard/src/test/java/us/abstracta/jmeter/javadsl/dashboard/DashboardVisualizerTest.java b/jmeter-java-dsl-dashboard/src/test/java/us/abstracta/jmeter/javadsl/dashboard/DashboardVisualizerTest.java index a5ebb71a..24ab3053 100644 --- a/jmeter-java-dsl-dashboard/src/test/java/us/abstracta/jmeter/javadsl/dashboard/DashboardVisualizerTest.java +++ b/jmeter-java-dsl-dashboard/src/test/java/us/abstracta/jmeter/javadsl/dashboard/DashboardVisualizerTest.java @@ -36,11 +36,9 @@ public void shouldDisplayGraphsAndSummaryWhenRunTestPlanWithDashboard(TestInfo t ); } - @Test - public void shouldThrowUnsupportedOperationWhenShowInGuiOnDashboardVisualizer() { - DashboardVisualizer dashboardVisualizer = new DashboardVisualizer(); - - assertThrows(UnsupportedOperationException.class, dashboardVisualizer::showInGui); - } + @Test + public void shouldThrowUnsupportedOperationWhenShowInGuiOnDashboardVisualizer() { + assertThrows(UnsupportedOperationException.class, () -> new DashboardVisualizer().showInGui()); + } } diff --git a/jmeter-java-dsl-graphql/src/test/java/us/abstracta/jmeter/javadsl/graphql/DslGraphqlSamplerTest.java b/jmeter-java-dsl-graphql/src/test/java/us/abstracta/jmeter/javadsl/graphql/DslGraphqlSamplerTest.java index bc0db840..c2533157 100644 --- a/jmeter-java-dsl-graphql/src/test/java/us/abstracta/jmeter/javadsl/graphql/DslGraphqlSamplerTest.java +++ b/jmeter-java-dsl-graphql/src/test/java/us/abstracta/jmeter/javadsl/graphql/DslGraphqlSamplerTest.java @@ -138,20 +138,13 @@ public void shouldSendGraphqlQueryToServerWhenGraphqlSamplerWithHttpGet() ).run(); verify(getRequestedFor(anyUrl()).withQueryParam("query", equalTo(QUERY))); } + @Test public void shouldThrowIllegalArgumentWhenGraphqlSamplerWithInvalidVariable() { DslGraphqlSampler sampler = graphqlSampler("http://localhost", "{ user(id: 1){ name } }"); assertThrows(IllegalArgumentException.class, () -> sampler.variable("invalidVar", new Object())); } - @Test - public void shouldHandleInvalidJsonInput() { - DslGraphqlSampler sampler = graphqlSampler("http://localhost", "{ user(id: 1){ name } }"); - sampler.variablesJson("invalidJson"); - } - - - @Nested public class CodeBuilderTest extends MethodCallBuilderTest { diff --git a/jmeter-java-dsl/src/main/java/us/abstracta/jmeter/javadsl/core/threadgroups/DslDefaultThreadGroup.java b/jmeter-java-dsl/src/main/java/us/abstracta/jmeter/javadsl/core/threadgroups/DslDefaultThreadGroup.java index a96d88a3..03e2cc9e 100644 --- a/jmeter-java-dsl/src/main/java/us/abstracta/jmeter/javadsl/core/threadgroups/DslDefaultThreadGroup.java +++ b/jmeter-java-dsl/src/main/java/us/abstracta/jmeter/javadsl/core/threadgroups/DslDefaultThreadGroup.java @@ -167,12 +167,10 @@ private void addStage(Stage stage) { private boolean isSimpleThreadGroup() { return stages.size() <= 1 - || stages.size() == 2 && ( - ZERO.equals(stages.get(0).threadCount()) - || stages.get(0).threadCount().equals(stages.get(1).threadCount())) - || stages.size() == 3 && ( - ZERO.equals(stages.get(0).threadCount()) - && stages.get(1).threadCount().equals(stages.get(2).threadCount())); + || stages.size() == 2 && (ZERO.equals(stages.get(0).threadCount()) || stages.get(0) + .threadCount().equals(stages.get(1).threadCount())) + || stages.size() == 3 && (ZERO.equals(stages.get(0).threadCount()) && stages.get(1) + .threadCount().equals(stages.get(2).threadCount())); } /** @@ -246,10 +244,9 @@ private Object getPrevThreadsCount() { * termination condition). *

* Setting this property to -1 is in general not advised, since you - * might - * inadvertently end up running a test plan without limits consuming unnecessary - * computing power. Prefer specifying a big value as a safe limit for iterations - * or duration instead. + * might inadvertently end up running a test plan without limits consuming + * unnecessary computing power. Prefer specifying a big value as a safe limit + * for iterations or duration instead. * @return the thread group for further configuration or usage. * @throws IllegalStateException when adding iterations would result in not supported JMeter * thread group. @@ -286,10 +283,12 @@ public DslDefaultThreadGroup holdIterating(String iterations) { private void checkIterationsPreConditions() { boolean isJustRamp = stages.size() == 1 && !ZERO.equals(stages.get(0).threadCount()); - boolean isJustDelayAndRamp = stages.size() == 2 && ZERO.equals(stages.get(0).threadCount()) && !ZERO.equals(stages.get(1).threadCount()); - + boolean isJustDelayAndRamp = + stages.size() == 2 && ZERO.equals(stages.get(0).threadCount()) && !ZERO.equals( + stages.get(1).threadCount()); if (!(isJustRamp || isJustDelayAndRamp)) { - throw new IllegalStateException("Holding for iterations is only supported after initial hold and ramp, or ramp."); + throw new IllegalStateException( + "Holding for iterations is only supported after initial hold and ramp, or ramp."); } if (ZERO.equals(getLastStage().threadCount())) { throw new IllegalStateException("Can't hold for iterations with no threads.");