diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-01-03 16:03:28 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-01-05 13:09:46 +0100 |
commit | 58b2a0961fc705d7f65736535d70916c5b8d46f3 (patch) | |
tree | 338262fec471f382a7c77c65e5eb0f14b6e62ae6 /sonar-ws/src/test | |
parent | e23046ef19a3baa4484320e13a3ac0eaa60195b7 (diff) | |
download | sonarqube-58b2a0961fc705d7f65736535d70916c5b8d46f3.tar.gz sonarqube-58b2a0961fc705d7f65736535d70916c5b8d46f3.zip |
SONAR-8575 Set api/settings WS as public and keep only one parameter for component
Diffstat (limited to 'sonar-ws/src/test')
4 files changed, 21 insertions, 58 deletions
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ListDefinitionsRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ListDefinitionsRequestTest.java index 66eb07952f7..c17751cad77 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ListDefinitionsRequestTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ListDefinitionsRequestTest.java @@ -37,24 +37,14 @@ public class ListDefinitionsRequestTest { public void create_request_with_no_component() { ListDefinitionsRequest result = underTest.build(); - assertThat(result.getComponentId()).isNull(); - assertThat(result.getComponentKey()).isNull(); - } - - @Test - public void create_request_with_component_id() { - ListDefinitionsRequest result = underTest.setComponentId("projectId").build(); - - assertThat(result.getComponentId()).isEqualTo("projectId"); - assertThat(result.getComponentKey()).isNull(); + assertThat(result.getComponent()).isNull(); } @Test public void create_request_with_component_key() { - ListDefinitionsRequest result = underTest.setComponentKey("projectKey").build(); + ListDefinitionsRequest result = underTest.setComponent("projectKey").build(); - assertThat(result.getComponentId()).isNull(); - assertThat(result.getComponentKey()).isEqualTo("projectKey"); + assertThat(result.getComponent()).isEqualTo("projectKey"); } } diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SetRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SetRequestTest.java index 461daa1d29f..d0f714d754c 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SetRequestTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SetRequestTest.java @@ -40,28 +40,16 @@ public class SetRequestTest { assertThat(result.getKey()).isEqualTo("my.key"); assertThat(result.getValue()).isEqualTo("my value"); assertThat(result.getValues()).isNotNull().isEmpty(); - assertThat(result.getComponentKey()).isNull(); - assertThat(result.getComponentId()).isNull(); - } - - @Test - public void create_request_with_component_id() { - SetRequest result = underTest.setKey("my.key").setValue("my value").setComponentId("projectId").build(); - - assertThat(result.getKey()).isEqualTo("my.key"); - assertThat(result.getValue()).isEqualTo("my value"); - assertThat(result.getComponentId()).isEqualTo("projectId"); - assertThat(result.getComponentKey()).isNull(); + assertThat(result.getComponent()).isNull(); } @Test public void create_request_with_component_key() { - SetRequest result = underTest.setKey("my.key").setValue("my value").setComponentKey("projectKey").build(); + SetRequest result = underTest.setKey("my.key").setValue("my value").setComponent("projectKey").build(); assertThat(result.getKey()).isEqualTo("my.key"); assertThat(result.getValue()).isEqualTo("my value"); - assertThat(result.getComponentId()).isNull(); - assertThat(result.getComponentKey()).isEqualTo("projectKey"); + assertThat(result.getComponent()).isEqualTo("projectKey"); } @Test diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SettingsServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SettingsServiceTest.java index 1faf51ef43d..66cfbf94c91 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SettingsServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SettingsServiceTest.java @@ -31,8 +31,7 @@ import org.sonarqube.ws.client.WsConnector; import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; -import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_COMPONENT_ID; -import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_COMPONENT_KEY; +import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_COMPONENT; import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_FIELD_VALUES; import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_KEY; import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_KEYS; @@ -49,13 +48,13 @@ public class SettingsServiceTest { @Test public void list_definitions() { underTest.listDefinitions(ListDefinitionsRequest.builder() - .setComponentKey("KEY") + .setComponent("KEY") .build()); GetRequest getRequest = serviceTester.getGetRequest(); assertThat(serviceTester.getGetParser()).isSameAs(ListDefinitionsWsResponse.parser()); serviceTester.assertThat(getRequest) - .hasParam(PARAM_COMPONENT_KEY, "KEY") + .hasParam(PARAM_COMPONENT, "KEY") .andNoOtherParam(); } @@ -63,14 +62,14 @@ public class SettingsServiceTest { public void values() { underTest.values(ValuesRequest.builder() .setKeys("sonar.debt,sonar.issue") - .setComponentKey("KEY") + .setComponent("KEY") .build()); GetRequest getRequest = serviceTester.getGetRequest(); assertThat(serviceTester.getGetParser()).isSameAs(ValuesWsResponse.parser()); serviceTester.assertThat(getRequest) .hasParam(PARAM_KEYS, "sonar.debt,sonar.issue") - .hasParam(PARAM_COMPONENT_KEY, "KEY") + .hasParam(PARAM_COMPONENT, "KEY") .andNoOtherParam(); } @@ -80,9 +79,8 @@ public class SettingsServiceTest { .setKey("sonar.debt") .setValue("8h") .setValues(newArrayList("v1", "v2", "v3")) - .setFieldValues(newArrayList("json1","json2","json3")) - .setComponentId("UUID") - .setComponentKey("KEY") + .setFieldValues(newArrayList("json1", "json2", "json3")) + .setComponent("KEY") .build()); serviceTester.assertThat(serviceTester.getPostRequest()) @@ -90,8 +88,7 @@ public class SettingsServiceTest { .hasParam(PARAM_VALUE, "8h") .hasParam(PARAM_VALUES, newArrayList("v1", "v2", "v3")) .hasParam(PARAM_FIELD_VALUES, newArrayList("json1", "json2", "json3")) - .hasParam(PARAM_COMPONENT_ID, "UUID") - .hasParam(PARAM_COMPONENT_KEY, "KEY") + .hasParam(PARAM_COMPONENT, "KEY") .andNoOtherParam(); } @@ -99,12 +96,12 @@ public class SettingsServiceTest { public void reset() { underTest.reset(ResetRequest.builder() .setKeys("sonar.debt") - .setComponentKey("KEY") + .setComponent("KEY") .build()); serviceTester.assertThat(serviceTester.getPostRequest()) .hasParam(PARAM_KEYS, "sonar.debt") - .hasParam(PARAM_COMPONENT_KEY, "KEY") + .hasParam(PARAM_COMPONENT, "KEY") .andNoOtherParam(); } diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ValuesRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ValuesRequestTest.java index 3c08fd7142f..bbf78709a25 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ValuesRequestTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ValuesRequestTest.java @@ -37,8 +37,7 @@ public class ValuesRequestTest { public void create_request_with_no_component() { ValuesRequest result = underTest.setKeys("sonar.debt").build(); - assertThat(result.getComponentId()).isNull(); - assertThat(result.getComponentKey()).isNull(); + assertThat(result.getComponent()).isNull(); assertThat(result.getKeys()).containsOnly("sonar.debt"); } @@ -46,26 +45,15 @@ public class ValuesRequestTest { public void create_request_with_no_keys() { ValuesRequest result = underTest.build(); - assertThat(result.getComponentId()).isNull(); - assertThat(result.getComponentKey()).isNull(); + assertThat(result.getComponent()).isNull(); assertThat(result.getKeys()).isEmpty(); } @Test - public void create_request_with_component_id() { - ValuesRequest result = underTest.setKeys("sonar.debt").setComponentId("projectId").build(); + public void create_request_with_component() { + ValuesRequest result = underTest.setKeys("sonar.debt").setComponent("projectKey").build(); - assertThat(result.getComponentId()).isEqualTo("projectId"); - assertThat(result.getComponentKey()).isNull(); - assertThat(result.getKeys()).containsOnly("sonar.debt"); - } - - @Test - public void create_request_with_component_key() { - ValuesRequest result = underTest.setKeys("sonar.debt").setComponentKey("projectKey").build(); - - assertThat(result.getComponentId()).isNull(); - assertThat(result.getComponentKey()).isEqualTo("projectKey"); + assertThat(result.getComponent()).isEqualTo("projectKey"); assertThat(result.getKeys()).containsOnly("sonar.debt"); } |