aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce-task
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2023-06-07 12:30:33 +0200
committersonartech <sonartech@sonarsource.com>2023-06-20 13:10:18 +0000
commit667618747b9e64f552eda5fc24df8398ca7afbef (patch)
tree642f7d84c3888e4081daff283acbbfe07116aff7 /server/sonar-ce-task
parent93734208da4519e1872e80c59f7edd1612dac5da (diff)
downloadsonarqube-667618747b9e64f552eda5fc24df8398ca7afbef.tar.gz
sonarqube-667618747b9e64f552eda5fc24df8398ca7afbef.zip
SONAR-19556 Refactor use of DB columns referencing projects or branches for Entities
Diffstat (limited to 'server/sonar-ce-task')
-rw-r--r--server/sonar-ce-task/src/main/java/org/sonar/ce/task/CeTask.java20
-rw-r--r--server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskTest.java22
2 files changed, 21 insertions, 21 deletions
diff --git a/server/sonar-ce-task/src/main/java/org/sonar/ce/task/CeTask.java b/server/sonar-ce-task/src/main/java/org/sonar/ce/task/CeTask.java
index 82aed72779c..95cc6b2c529 100644
--- a/server/sonar-ce-task/src/main/java/org/sonar/ce/task/CeTask.java
+++ b/server/sonar-ce-task/src/main/java/org/sonar/ce/task/CeTask.java
@@ -40,17 +40,17 @@ public class CeTask {
private final String type;
private final String uuid;
private final Component component;
- private final Component mainComponent;
+ private final Component entity;
private final User submitter;
private final Map<String, String> characteristics;
private CeTask(Builder builder) {
this.uuid = requireNonNull(emptyToNull(builder.uuid), "uuid can't be null nor empty");
this.type = requireNonNull(emptyToNull(builder.type), "type can't be null nor empty");
- checkArgument((builder.component == null) == (builder.mainComponent == null),
- "None or both component and main component must be non null");
+ checkArgument((builder.component == null) == (builder.entity == null),
+ "None or both component and entity must be non null");
this.component = builder.component;
- this.mainComponent = builder.mainComponent;
+ this.entity = builder.entity;
this.submitter = builder.submitter;
if (builder.characteristics == null) {
this.characteristics = emptyMap();
@@ -103,8 +103,8 @@ public class CeTask {
return Optional.ofNullable(component);
}
- public Optional<Component> getMainComponent() {
- return Optional.ofNullable(mainComponent);
+ public Optional<Component> getEntity() {
+ return Optional.ofNullable(entity);
}
@CheckForNull
@@ -122,7 +122,7 @@ public class CeTask {
.add("type", type)
.add("uuid", uuid)
.add("component", component)
- .add("mainComponent", mainComponent)
+ .add("entity", entity)
.add("submitter", submitter)
.toString();
}
@@ -148,7 +148,7 @@ public class CeTask {
private String uuid;
private String type;
private Component component;
- private Component mainComponent;
+ private Component entity;
private User submitter;
private Map<String, String> characteristics;
@@ -167,8 +167,8 @@ public class CeTask {
return this;
}
- public Builder setMainComponent(@Nullable Component mainComponent) {
- this.mainComponent = mainComponent;
+ public Builder setEntity(@Nullable Component entity) {
+ this.entity = entity;
return this;
}
diff --git a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskTest.java b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskTest.java
index c773ae1c5ce..84ec151ab7d 100644
--- a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskTest.java
+++ b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskTest.java
@@ -35,20 +35,20 @@ public class CeTaskTest {
private CeTask.Builder underTest = new CeTask.Builder();
@Test
- @UseDataProvider("oneAndOnlyOneOfComponentAndMainComponent")
- public void build_fails_with_IAE_if_only_one_of_component_and_main_component_is_non_null(CeTask.Component component, CeTask.Component mainComponent) {
+ @UseDataProvider("oneAndOnlyOneOfComponentAndEntity")
+ public void build_fails_with_IAE_if_only_one_of_component_and_main_component_is_non_null(CeTask.Component component, CeTask.Component entity) {
underTest.setType("TYPE_1");
underTest.setUuid("UUID_1");
underTest.setComponent(component);
- underTest.setMainComponent(mainComponent);
+ underTest.setEntity(entity);
assertThatThrownBy(() -> underTest.build())
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("None or both component and main component must be non null");
+ .hasMessage("None or both component and entity must be non null");
}
@DataProvider
- public static Object[][] oneAndOnlyOneOfComponentAndMainComponent() {
+ public static Object[][] oneAndOnlyOneOfComponentAndEntity() {
CeTask.Component component = new CeTask.Component("COMPONENT_UUID_1", "COMPONENT_KEY_1", "The component");
return new Object[][] {
{component, null},
@@ -59,13 +59,13 @@ public class CeTaskTest {
@Test
public void verify_getters() {
CeTask.Component component = new CeTask.Component("COMPONENT_UUID_1", "COMPONENT_KEY_1", "The component");
- CeTask.Component mainComponent = new CeTask.Component("MAIN_COMPONENT_UUID_1", "MAIN_COMPONENT_KEY_1", "The main component");
+ CeTask.Component entity = new CeTask.Component("ENTITY_UUID_1", "ENTITY_KEY_1", "The entity");
CeTask.User submitter = new CeTask.User("UUID_USER_1", "LOGIN_1");
underTest.setType("TYPE_1");
underTest.setUuid("UUID_1");
underTest.setSubmitter(submitter);
underTest.setComponent(component);
- underTest.setMainComponent(mainComponent);
+ underTest.setEntity(entity);
underTest.setCharacteristics(ImmutableMap.of("k1", "v1", "k2", "v2"));
CeTask task = underTest.build();
@@ -74,7 +74,7 @@ public class CeTaskTest {
assertThat(task.getType()).isEqualTo("TYPE_1");
assertThat(task.getSubmitter()).isEqualTo(submitter);
assertThat(task.getComponent()).contains(component);
- assertThat(task.getMainComponent()).contains(mainComponent);
+ assertThat(task.getEntity()).contains(entity);
assertThat(task.getCharacteristics())
.hasSize(2)
.containsEntry("k1", "v1")
@@ -84,11 +84,11 @@ public class CeTaskTest {
@Test
public void verify_toString() {
CeTask.Component component = new CeTask.Component("COMPONENT_UUID_1", "COMPONENT_KEY_1", "The component");
- CeTask.Component mainComponent = new CeTask.Component("MAIN_COMPONENT_UUID_1", "MAIN_COMPONENT_KEY_1", "The main component");
+ CeTask.Component entity = new CeTask.Component("ENTITY_UUID_1", "ENTITY_KEY_1", "The entity");
underTest.setType("TYPE_1");
underTest.setUuid("UUID_1");
underTest.setComponent(component);
- underTest.setMainComponent(mainComponent);
+ underTest.setEntity(entity);
underTest.setSubmitter(new CeTask.User("UUID_USER_1", "LOGIN_1"));
underTest.setCharacteristics(ImmutableMap.of("k1", "v1", "k2", "v2"));
@@ -99,7 +99,7 @@ public class CeTaskTest {
"type=TYPE_1, " +
"uuid=UUID_1, " +
"component=Component{uuid='COMPONENT_UUID_1', key='COMPONENT_KEY_1', name='The component'}, " +
- "mainComponent=Component{uuid='MAIN_COMPONENT_UUID_1', key='MAIN_COMPONENT_KEY_1', name='The main component'}, " +
+ "entity=Component{uuid='ENTITY_UUID_1', key='ENTITY_KEY_1', name='The entity'}, " +
"submitter=User{uuid='UUID_USER_1', login='LOGIN_1'}" +
"}");
}