]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10266 Create stub for api/project_badges WS
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 10 Jan 2018 14:04:43 +0000 (15:04 +0100)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Thu, 25 Jan 2018 14:16:50 +0000 (15:16 +0100)
12 files changed:
server/sonar-server/src/main/java/org/sonar/server/badge/ws/MeasureAction.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/badge/ws/ProjectBadgesWs.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/badge/ws/ProjectBadgesWsAction.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/badge/ws/ProjectBadgesWsModule.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/badge/ws/QualityGateAction.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/badge/ws/package-info.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
server/sonar-server/src/main/resources/org/sonar/server/badge/ws/measure-example.svg [new file with mode: 0644]
server/sonar-server/src/main/resources/org/sonar/server/badge/ws/quality_gate-example.svg [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/badge/ws/ProjectBadgesWsModuleTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java [new file with mode: 0644]

diff --git a/server/sonar-server/src/main/java/org/sonar/server/badge/ws/MeasureAction.java b/server/sonar-server/src/main/java/org/sonar/server/badge/ws/MeasureAction.java
new file mode 100644 (file)
index 0000000..d0fcedd
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.badge.ws;
+
+import com.google.common.io.Resources;
+import org.apache.commons.io.IOUtils;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.server.ws.WebService.NewAction;
+
+import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
+
+public class MeasureAction implements ProjectBadgesWsAction {
+
+  public static final String PARAM_COMPONENT = "component";
+  public static final String PARAM_METRIC = "metric";
+
+  @Override
+  public void define(WebService.NewController controller) {
+    NewAction action = controller.createAction("measure")
+      .setHandler(this)
+      .setDescription("Generate badge for measure as an SVG")
+      .setResponseExample(Resources.getResource(getClass(), "measure-example.svg"));
+    action.createParam(PARAM_COMPONENT)
+      .setDescription("Project key")
+      .setRequired(true)
+      .setExampleValue(KEY_PROJECT_EXAMPLE_001);
+    action.createParam(PARAM_METRIC)
+      .setDescription("Metric key")
+      .setRequired(true)
+      .setExampleValue(KEY_PROJECT_EXAMPLE_001);
+  }
+
+  @Override
+  public void handle(Request request, Response response) throws Exception {
+    response.stream().setMediaType("image/svg+xml");
+    IOUtils.copy(Resources.getResource(getClass(), "measure-example.svg").openStream(), response.stream().output());
+  }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/badge/ws/ProjectBadgesWs.java b/server/sonar-server/src/main/java/org/sonar/server/badge/ws/ProjectBadgesWs.java
new file mode 100644 (file)
index 0000000..2b95f7b
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.badge.ws;
+
+import java.util.List;
+import org.sonar.api.server.ws.WebService;
+
+public class ProjectBadgesWs implements WebService {
+
+  private final List<ProjectBadgesWsAction> actions;
+
+  public ProjectBadgesWs(List<ProjectBadgesWsAction> actions) {
+    this.actions = actions;
+  }
+
+  @Override
+  public void define(Context context) {
+    NewController controller = context.createController("api/project_badges");
+    controller.setDescription("Generate badges based on quality gates or measures");
+    controller.setSince("7.1");
+    actions.forEach(action -> action.define(controller));
+    controller.done();
+  }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/badge/ws/ProjectBadgesWsAction.java b/server/sonar-server/src/main/java/org/sonar/server/badge/ws/ProjectBadgesWsAction.java
new file mode 100644 (file)
index 0000000..5e8381b
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.badge.ws;
+
+import org.sonar.server.ws.WsAction;
+
+interface ProjectBadgesWsAction extends WsAction {
+  // Marker interface
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/badge/ws/ProjectBadgesWsModule.java b/server/sonar-server/src/main/java/org/sonar/server/badge/ws/ProjectBadgesWsModule.java
new file mode 100644 (file)
index 0000000..085fdc3
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.badge.ws;
+
+import org.sonar.api.config.Configuration;
+import org.sonar.core.config.WebConstants;
+import org.sonar.core.platform.Module;
+
+public class ProjectBadgesWsModule extends Module {
+
+  private final Configuration config;
+
+  public ProjectBadgesWsModule(Configuration config) {
+    this.config = config;
+  }
+
+  @Override
+  protected void configureModule() {
+    if (!config.getBoolean(WebConstants.SONARCLOUD_ENABLED).orElse(false)) {
+      return;
+    }
+    add(
+      ProjectBadgesWs.class,
+      QualityGateAction.class,
+      MeasureAction.class
+      );
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/badge/ws/QualityGateAction.java b/server/sonar-server/src/main/java/org/sonar/server/badge/ws/QualityGateAction.java
new file mode 100644 (file)
index 0000000..6f60519
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.badge.ws;
+
+import com.google.common.io.Resources;
+import org.apache.commons.io.IOUtils;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.server.ws.WebService.NewAction;
+
+import static java.util.Arrays.asList;
+import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
+
+public class QualityGateAction implements ProjectBadgesWsAction {
+
+  public static final String PARAM_COMPONENT = "component";
+  public static final String PARAM_TYPE = "type";
+
+  @Override
+  public void define(WebService.NewController controller) {
+    NewAction action = controller.createAction("quality_gate")
+      .setHandler(this)
+      .setDescription("Generate badge for quality gate as an SVG")
+      .setResponseExample(Resources.getResource(getClass(), "quality_gate-example.svg"));
+    action.createParam(PARAM_COMPONENT)
+      .setDescription("Project key")
+      .setRequired(true)
+      .setExampleValue(KEY_PROJECT_EXAMPLE_001);
+    action.createParam(PARAM_TYPE)
+      .setDescription("Type of badge.")
+      .setRequired(false)
+      .setPossibleValues(asList("BADGE", "CARD"));
+  }
+
+  @Override
+  public void handle(Request request, Response response) throws Exception {
+    response.stream().setMediaType("image/svg+xml");
+    IOUtils.copy(Resources.getResource(getClass(), "quality_gate-example.svg").openStream(), response.stream().output());
+  }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/badge/ws/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/badge/ws/package-info.java
new file mode 100644 (file)
index 0000000..747c157
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.badge.ws;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index db08d7499b5a9db43ebf4fb0430ea84bd38ac8b7..89cf7930d084afbfbec09112bf9771eac90ac147 100644 (file)
@@ -35,6 +35,7 @@ import org.sonar.core.component.DefaultResourceTypes;
 import org.sonar.core.timemachine.Periods;
 import org.sonar.server.authentication.AuthenticationModule;
 import org.sonar.server.authentication.LogOAuthWarning;
+import org.sonar.server.badge.ws.ProjectBadgesWsModule;
 import org.sonar.server.batch.BatchWsModule;
 import org.sonar.server.branch.BranchFeatureProxyImpl;
 import org.sonar.server.branch.ws.BranchWsModule;
@@ -535,6 +536,9 @@ public class PlatformLevel4 extends PlatformLevel {
       // Branch
       BranchFeatureProxyImpl.class,
 
+      // Project badges
+      ProjectBadgesWsModule.class,
+
       // privileged plugins
       PrivilegedPluginsBootstraper.class,
       PrivilegedPluginsStopper.class,
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/measure-example.svg b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/measure-example.svg
new file mode 100644 (file)
index 0000000..8934ac3
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" height="20" width="191">
+    <linearGradient id="smooth" x2="0" y2="100%">
+        <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
+        <stop offset="1" stop-opacity=".1"/>
+    </linearGradient>
+    <mask id="round">
+        <rect fill="#fff" height="20" rx="3" width="191"/>
+    </mask>
+    <g mask="url(#round)">
+        <rect fill="#666" height="20" width="136"/>
+        <rect fill="#969696" height="20" width="55" x="136"/>
+        <rect fill="url(#smooth)" height="20" width="191"/>
+    </g>
+    <g fill="#fff" font-family="DejaVu Sans,Verdana,Sans PT,Lucida Grande,Tahoma,Helvetica,Arial,sans-serif"
+       font-size="11" text-anchor="middle">
+        <text fill="#010101" fill-opacity=".3" x="68" y="15">Coverage</text>
+        <text x="68" y="14">Coverage</text>
+        <text fill="#010101" fill-opacity=".3" x="163" y="15">100.0%</text>
+        <text x="163" y="14">100.0%</text>
+    </g>
+</svg>
\ No newline at end of file
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/quality_gate-example.svg b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/quality_gate-example.svg
new file mode 100644 (file)
index 0000000..038231f
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" height="20" width="123">
+    <linearGradient id="smooth" x2="0" y2="100%">
+        <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
+        <stop offset="1" stop-opacity=".1"/>
+    </linearGradient>
+    <mask id="round">
+        <rect fill="#fff" height="20" rx="3" width="123"/>
+    </mask>
+    <g mask="url(#round)">
+        <rect fill="#666" height="20" width="77"/>
+        <rect fill="#E05D44" height="20" width="46" x="77"/>
+        <rect fill="url(#smooth)" height="20" width="123"/>
+    </g>
+    <g fill="#fff" font-family="Sans PT,Lucida Grande,Tahoma,Helvetica,Arial,sans-serif" font-size="11"
+       text-anchor="middle">
+        <text fill="#010101" fill-opacity=".3" x="38" y="15">Quality Gate</text>
+        <text x="38" y="14">Quality Gate</text>
+        <text fill="#010101" fill-opacity=".3" x="100" y="15">failing</text>
+        <text x="100" y="14">failing</text>
+    </g>
+</svg>
\ No newline at end of file
diff --git a/server/sonar-server/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java
new file mode 100644 (file)
index 0000000..51b619e
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.badge.ws;
+
+import org.junit.Test;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.server.ws.WebService.Param;
+import org.sonar.server.ws.WsActionTester;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
+
+public class MeasureActionTest {
+
+  private WsActionTester ws = new WsActionTester(new MeasureAction());
+
+  @Test
+  public void test_definition() {
+    WebService.Action def = ws.getDef();
+    assertThat(def.key()).isEqualTo("measure");
+    assertThat(def.isInternal()).isFalse();
+    assertThat(def.isPost()).isFalse();
+    assertThat(def.since()).isNull();
+    assertThat(def.responseExampleAsString()).isNotEmpty();
+
+    assertThat(def.params())
+      .extracting(Param::key, Param::isRequired)
+      .containsExactlyInAnyOrder(
+        tuple("component", true),
+        tuple("metric", true));
+  }
+
+  @Test
+  public void test_example() {
+    String response = ws.newRequest().execute().getInput();
+
+    assertThat(response).isEqualTo(ws.getDef().responseExampleAsString());
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/badge/ws/ProjectBadgesWsModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/badge/ws/ProjectBadgesWsModuleTest.java
new file mode 100644 (file)
index 0000000..6957419
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.badge.ws;
+
+import org.junit.Test;
+import org.sonar.api.config.internal.MapSettings;
+import org.sonar.core.platform.ComponentContainer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
+
+public class ProjectBadgesWsModuleTest {
+
+  private ComponentContainer container = new ComponentContainer();
+  private MapSettings mapSettings = new MapSettings();
+  private ProjectBadgesWsModule underTest = new ProjectBadgesWsModule(mapSettings.asConfig());
+
+  @Test
+  public void verify_count_of_added_components() {
+    mapSettings.setProperty("sonar.sonarcloud.enabled", true);
+
+    underTest.configure(container);
+
+    assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 3);
+  }
+
+  @Test
+  public void no_component_when_not_on_sonar_cloud() {
+    mapSettings.setProperty("sonar.sonarcloud.enabled", false);
+
+    underTest.configure(container);
+
+    assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER);
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java
new file mode 100644 (file)
index 0000000..cfecf96
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.badge.ws;
+
+import org.junit.Test;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.server.ws.WebService.Param;
+import org.sonar.server.ws.WsActionTester;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
+
+public class QualityGateActionTest {
+
+  private WsActionTester ws = new WsActionTester(new QualityGateAction());
+
+  @Test
+  public void test_definition() {
+    WebService.Action def = ws.getDef();
+    assertThat(def.key()).isEqualTo("quality_gate");
+    assertThat(def.isInternal()).isFalse();
+    assertThat(def.isPost()).isFalse();
+    assertThat(def.since()).isNull();
+    assertThat(def.responseExampleAsString()).isNotEmpty();
+
+    assertThat(def.params())
+      .extracting(Param::key, Param::isRequired)
+      .containsExactlyInAnyOrder(
+        tuple("component", true),
+        tuple("type", false));
+  }
+
+  @Test
+  public void test_example() {
+    String response = ws.newRequest().execute().getInput();
+
+    assertThat(response).isEqualTo(ws.getDef().responseExampleAsString());
+  }
+}