aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-03-29 14:23:52 +0200
committerEric Hartmann <hartmann.eric@gmail.Com>2017-04-27 09:23:18 +0200
commit5c659e207f045706c4408cc9ae72c56a71e545d9 (patch)
tree01a4092727b6e58c1f66fa6c20a09360028b7482 /server
parente62b51e3812f640230c0d0dc191a54e8db76b949 (diff)
downloadsonarqube-5c659e207f045706c4408cc9ae72c56a71e545d9.tar.gz
sonarqube-5c659e207f045706c4408cc9ae72c56a71e545d9.zip
SONAR-8987 remove use of Guava Optional in CE tables related classes
Diffstat (limited to 'server')
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueue.java2
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java6
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepository.java2
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java4
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerCallableImpl.java4
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java11
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java6
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryRule.java4
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerCallableImplTest.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityDao.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeQueueDao.java8
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java8
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java10
-rw-r--r--server/sonar-server/src/main/java/org/sonar/ce/queue/CeQueueImpl.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ce/ws/ActivityAction.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskAction.java12
-rw-r--r--server/sonar-server/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java2
17 files changed, 46 insertions, 49 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueue.java b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueue.java
index 01f5341f764..42447633920 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueue.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueue.java
@@ -19,7 +19,7 @@
*/
package org.sonar.ce.queue;
-import com.google.common.base.Optional;
+import java.util.Optional;
import javax.annotation.Nullable;
import org.sonar.ce.queue.CeQueue;
import org.sonar.ce.queue.CeTask;
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
index bcd6f0abccf..8f899d4b2e6 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
@@ -19,12 +19,12 @@
*/
package org.sonar.ce.queue;
-import com.google.common.base.Optional;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
@@ -68,7 +68,7 @@ public class InternalCeQueueImpl extends CeQueueImpl implements InternalCeQueue
requireNonNull(workerUuid, "workerUuid can't be null");
if (peekPaused.get()) {
- return Optional.absent();
+ return Optional.empty();
}
try (DbSession dbSession = dbClient.openSession(false)) {
Optional<CeQueueDto> dto = dbClient.ceQueueDao().peek(dbSession, workerUuid, MAX_EXECUTION_COUNT);
@@ -77,7 +77,7 @@ public class InternalCeQueueImpl extends CeQueueImpl implements InternalCeQueue
task = loadTask(dbSession, dto.get());
queueStatus.addInProgress();
}
- return Optional.fromNullable(task);
+ return Optional.ofNullable(task);
}
}
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepository.java b/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepository.java
index 7fbbfa3f3f7..83fb0d01f01 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepository.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepository.java
@@ -19,7 +19,7 @@
*/
package org.sonar.ce.taskprocessor;
-import com.google.common.base.Optional;
+import java.util.Optional;
import org.sonar.ce.queue.CeTask;
import org.sonar.ce.taskprocessor.CeTaskProcessor;
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java
index 24a2bf07530..b96a8e1783f 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java
@@ -21,13 +21,13 @@ package org.sonar.ce.taskprocessor;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
-import com.google.common.base.Optional;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import java.util.Collection;
import java.util.Map;
+import java.util.Optional;
import javax.annotation.Nonnull;
import org.sonar.ce.queue.CeTask;
import org.sonar.ce.taskprocessor.CeTaskProcessor;
@@ -52,7 +52,7 @@ public class CeTaskProcessorRepositoryImpl implements CeTaskProcessorRepository
@Override
public Optional<CeTaskProcessor> getForCeTask(CeTask ceTask) {
- return Optional.fromNullable(taskProcessorByCeTaskType.get(ceTask.getType()));
+ return Optional.ofNullable(taskProcessorByCeTaskType.get(ceTask.getType()));
}
private static Map<String, CeTaskProcessor> indexTaskProcessors(CeTaskProcessor[] taskProcessors) {
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerCallableImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerCallableImpl.java
index 5bb5a047068..517a0a7651d 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerCallableImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerCallableImpl.java
@@ -19,7 +19,7 @@
*/
package org.sonar.ce.taskprocessor;
-import com.google.common.base.Optional;
+import java.util.Optional;
import javax.annotation.Nullable;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
@@ -67,7 +67,7 @@ public class CeWorkerCallableImpl implements CeWorkerCallable {
} catch (Exception e) {
LOG.error("Failed to pop the queue of analysis reports", e);
}
- return Optional.absent();
+ return Optional.empty();
}
private void executeTask(CeTask task) {
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java
index 2bf444730cb..071bd177845 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java
@@ -19,13 +19,13 @@
*/
package org.sonar.ce.queue;
-import com.google.common.base.Optional;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.List;
+import java.util.Optional;
import java.util.Random;
import javax.annotation.Nullable;
-import org.assertj.guava.api.Assertions;
+import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -49,7 +49,6 @@ import org.sonar.server.organization.DefaultOrganizationProvider;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.hamcrest.Matchers.startsWith;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -226,7 +225,7 @@ public class InternalCeQueueImplTest {
underTest.remove(peek.get(), CeActivityDto.Status.FAILED, null, error);
Optional<CeActivityDto> activityDto = dbTester.getDbClient().ceActivityDao().selectByUuid(session, task.getUuid());
- Assertions.assertThat(activityDto).isPresent();
+ assertThat(activityDto).isPresent();
assertThat(activityDto.get().getErrorMessage()).isEqualTo(error.getMessage());
assertThat(activityDto.get().getErrorStacktrace()).isEqualToIgnoringWhitespace(stacktraceToString(error));
@@ -387,7 +386,7 @@ public class InternalCeQueueImplTest {
@Test
public void fail_to_cancel_if_in_progress() throws Exception {
expectedException.expect(IllegalStateException.class);
- expectedException.expectMessage(startsWith("Task is in progress and can't be canceled"));
+ expectedException.expectMessage(Matchers.startsWith("Task is in progress and can't be canceled"));
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
underTest.peek(WORKER_UUID_2);
@@ -445,7 +444,7 @@ public class InternalCeQueueImplTest {
}
private void verifyCanceled(CeQueueDto original) {
- Assertions.assertThat(dbTester.getDbClient().ceQueueDao().selectByUuid(dbTester.getSession(), original.getUuid())).isAbsent();
+ assertThat(dbTester.getDbClient().ceQueueDao().selectByUuid(dbTester.getSession(), original.getUuid())).isEmpty();
CeActivityDto dto = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), original.getUuid()).get();
assertThat(dto.getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
assertThat(dto.getExecutionCount()).isEqualTo(original.getExecutionCount());
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java
index 743f51e169d..0e038487294 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java
@@ -21,7 +21,6 @@ package org.sonar.ce.taskprocessor;
import com.google.common.collect.ImmutableSet;
import java.util.Set;
-import org.assertj.guava.api.Assertions;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -30,7 +29,6 @@ import org.sonar.ce.queue.CeTaskResult;
import static org.assertj.core.api.Assertions.assertThat;
-
public class CeTaskProcessorRepositoryImplTest {
private static final String SOME_CE_TASK_TYPE = "some type";
private static final String SOME_COMPONENT_KEY = "key";
@@ -73,7 +71,7 @@ public class CeTaskProcessorRepositoryImplTest {
public void getForTask_returns_absent_if_repository_is_empty() {
CeTaskProcessorRepositoryImpl underTest = new CeTaskProcessorRepositoryImpl(new CeTaskProcessor[] {});
- Assertions.assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY))).isAbsent();
+ assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY))).isEmpty();
}
@Test
@@ -83,7 +81,7 @@ public class CeTaskProcessorRepositoryImplTest {
createCeTaskProcessor(SOME_CE_TASK_TYPE + "_2", SOME_CE_TASK_TYPE + "_3"),
});
- Assertions.assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY))).isAbsent();
+ assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY))).isEmpty();
}
@Test
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryRule.java b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryRule.java
index 7a07b5e8b8e..c8bebfd5f52 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryRule.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryRule.java
@@ -19,9 +19,9 @@
*/
package org.sonar.ce.taskprocessor;
-import com.google.common.base.Optional;
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import org.junit.rules.ExternalResource;
import org.sonar.ce.queue.CeTask;
@@ -57,7 +57,7 @@ public class CeTaskProcessorRepositoryRule extends ExternalResource implements C
public Optional<CeTaskProcessor> getForCeTask(CeTask ceTask) {
CeTaskProcessor taskProcessor = index.get(ceTask.getType());
checkState(taskProcessor != null, "CeTaskProcessor was not set in rule for task %s", ceTask);
- return taskProcessor instanceof NoCeTaskProcessor ? Optional.<CeTaskProcessor>absent() : Optional.of(taskProcessor);
+ return taskProcessor instanceof NoCeTaskProcessor ? Optional.empty() : Optional.of(taskProcessor);
}
private enum NoCeTaskProcessor implements CeTaskProcessor {
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerCallableImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerCallableImplTest.java
index b63a9e0dacc..05c6112ff57 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerCallableImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerCallableImplTest.java
@@ -19,8 +19,8 @@
*/
package org.sonar.ce.taskprocessor;
-import com.google.common.base.Optional;
import java.util.List;
+import java.util.Optional;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
@@ -59,7 +59,7 @@ public class CeWorkerCallableImplTest {
@Test
public void no_pending_tasks_in_queue() throws Exception {
- when(queue.peek(UNKNOWN_WORKER_UUID)).thenReturn(Optional.<CeTask>absent());
+ when(queue.peek(UNKNOWN_WORKER_UUID)).thenReturn(Optional.empty());
assertThat(underTest.call()).isFalse();
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityDao.java
index 0e8f678fd65..3ba6ad52aae 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityDao.java
@@ -19,9 +19,9 @@
*/
package org.sonar.db.ce;
-import com.google.common.base.Optional;
import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import java.util.Set;
import javax.annotation.Nullable;
import org.sonar.api.utils.System2;
@@ -40,7 +40,7 @@ public class CeActivityDao implements Dao {
}
public Optional<CeActivityDto> selectByUuid(DbSession dbSession, String uuid) {
- return Optional.fromNullable(mapper(dbSession).selectByUuid(uuid));
+ return Optional.ofNullable(mapper(dbSession).selectByUuid(uuid));
}
public void insert(DbSession dbSession, CeActivityDto dto) {
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeQueueDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeQueueDao.java
index 90714f6ebdf..589f2e200c1 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeQueueDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeQueueDao.java
@@ -19,8 +19,8 @@
*/
package org.sonar.db.ce;
-import com.google.common.base.Optional;
import java.util.List;
+import java.util.Optional;
import javax.annotation.Nullable;
import org.apache.ibatis.session.RowBounds;
import org.sonar.api.utils.System2;
@@ -77,7 +77,7 @@ public class CeQueueDao implements Dao {
}
public Optional<CeQueueDto> selectByUuid(DbSession session, String uuid) {
- return Optional.fromNullable(mapper(session).selectByUuid(uuid));
+ return Optional.ofNullable(mapper(session).selectByUuid(uuid));
}
public List<CeQueueDto> selectPendingByMinimumExecutionCount(DbSession dbSession, int minExecutionCount) {
@@ -117,7 +117,7 @@ public class CeQueueDao implements Dao {
public Optional<CeQueueDto> peek(DbSession session, String workerUuid, int maxExecutionCount) {
List<EligibleTaskDto> eligibles = mapper(session).selectEligibleForPeek(maxExecutionCount, ONE_RESULT_PAGINATION);
if (eligibles.isEmpty()) {
- return Optional.absent();
+ return Optional.empty();
}
EligibleTaskDto eligible = eligibles.get(0);
@@ -130,7 +130,7 @@ public class CeQueueDao implements Dao {
new UpdateIf.NewProperties(IN_PROGRESS, workerUuid, eligible.getExecutionCount() + 1, now, now),
new UpdateIf.OldProperties(PENDING, eligible.getExecutionCount()));
if (touchedRows != 1) {
- return Optional.absent();
+ return Optional.empty();
}
CeQueueDto result = mapper(session).selectByUuid(eligible.getUuid());
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java
index 2bc2840a7c3..f11864bb66b 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java
@@ -20,11 +20,11 @@
package org.sonar.db.ce;
import com.google.common.base.Function;
-import com.google.common.base.Optional;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import javax.annotation.Nonnull;
import org.junit.Rule;
import org.junit.Test;
@@ -58,7 +58,7 @@ public class CeActivityDaoTest {
CeActivityDto inserted = insert("TASK_1", REPORT, "PROJECT_1", CeActivityDto.Status.SUCCESS);
Optional<CeActivityDto> saved = underTest.selectByUuid(db.getSession(), "TASK_1");
- assertThat(saved.isPresent()).isTrue();
+ assertThat(saved).isPresent();
CeActivityDto dto = saved.get();
assertThat(dto.getUuid()).isEqualTo("TASK_1");
assertThat(dto.getComponentUuid()).isEqualTo("PROJECT_1");
@@ -306,7 +306,7 @@ public class CeActivityDaoTest {
underTest.deleteByUuids(db.getSession(), ImmutableSet.of("TASK_1", "TASK_3"));
assertThat(underTest.selectByUuid(db.getSession(), "TASK_1").isPresent()).isFalse();
- assertThat(underTest.selectByUuid(db.getSession(), "TASK_2").isPresent()).isTrue();
+ assertThat(underTest.selectByUuid(db.getSession(), "TASK_2")).isPresent();
assertThat(underTest.selectByUuid(db.getSession(), "TASK_3").isPresent()).isFalse();
}
@@ -317,7 +317,7 @@ public class CeActivityDaoTest {
// must not fail
underTest.deleteByUuids(db.getSession(), singleton("TASK_2"));
- assertThat(underTest.selectByUuid(db.getSession(), "TASK_1").isPresent()).isTrue();
+ assertThat(underTest.selectByUuid(db.getSession(), "TASK_1")).isPresent();
}
@Test
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java
index 1ff894d6d39..0bcc63c2521 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java
@@ -20,12 +20,12 @@
package org.sonar.db.ce;
import com.google.common.base.Function;
-import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Random;
import java.util.stream.Stream;
import javax.annotation.Nullable;
@@ -193,7 +193,7 @@ public class CeQueueDaoTest {
insert(TASK_UUID_1, COMPONENT_UUID_1, PENDING);
underTest.deleteByUuid(db.getSession(), "UNKNOWN");
- assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_1).isPresent()).isTrue();
+ assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_1)).isPresent();
underTest.deleteByUuid(db.getSession(), TASK_UUID_1);
assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_1).isPresent()).isFalse();
@@ -276,7 +276,7 @@ public class CeQueueDaoTest {
// peek first one
Optional<CeQueueDto> peek = underTest.peek(db.getSession(), WORKER_UUID_1, MAX_EXECUTION_COUNT);
- assertThat(peek.isPresent()).isTrue();
+ assertThat(peek).isPresent();
assertThat(peek.get().getUuid()).isEqualTo(TASK_UUID_1);
assertThat(peek.get().getStatus()).isEqualTo(IN_PROGRESS);
assertThat(peek.get().getWorkerUuid()).isEqualTo(WORKER_UUID_1);
@@ -285,7 +285,7 @@ public class CeQueueDaoTest {
// peek second one
peek = underTest.peek(db.getSession(), WORKER_UUID_2, MAX_EXECUTION_COUNT);
- assertThat(peek.isPresent()).isTrue();
+ assertThat(peek).isPresent();
assertThat(peek.get().getUuid()).isEqualTo(TASK_UUID_2);
assertThat(peek.get().getStatus()).isEqualTo(IN_PROGRESS);
assertThat(peek.get().getWorkerUuid()).isEqualTo(WORKER_UUID_2);
@@ -304,7 +304,7 @@ public class CeQueueDaoTest {
insert(TASK_UUID_2, COMPONENT_UUID_1, PENDING);
Optional<CeQueueDto> peek = underTest.peek(db.getSession(), WORKER_UUID_1, MAX_EXECUTION_COUNT);
- assertThat(peek.isPresent()).isTrue();
+ assertThat(peek).isPresent();
assertThat(peek.get().getUuid()).isEqualTo(TASK_UUID_1);
assertThat(peek.get().getWorkerUuid()).isEqualTo(WORKER_UUID_1);
assertThat(peek.get().getExecutionCount()).isEqualTo(1);
diff --git a/server/sonar-server/src/main/java/org/sonar/ce/queue/CeQueueImpl.java b/server/sonar-server/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
index 9226758c2cd..4fcc448c83f 100644
--- a/server/sonar-server/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
@@ -20,12 +20,12 @@
package org.sonar.ce.queue;
import com.google.common.base.Function;
-import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nonnull;
@@ -99,7 +99,7 @@ public class CeQueueImpl implements CeQueue {
if (dto.getComponentUuid() == null) {
return new CeQueueDtoToCeTask(defaultOrganizationProvider.get().getUuid()).apply(dto);
}
- Optional<ComponentDto> componentDto = dbClient.componentDao().selectByUuid(dbSession, dto.getComponentUuid());
+ com.google.common.base.Optional<ComponentDto> componentDto = dbClient.componentDao().selectByUuid(dbSession, dto.getComponentUuid());
if (componentDto.isPresent()) {
return new CeQueueDtoToCeTask(defaultOrganizationProvider.get().getUuid(), ImmutableMap.of(dto.getComponentUuid(), componentDto.get())).apply(dto);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/ActivityAction.java b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/ActivityAction.java
index 8fb454385de..777e51746ad 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/ActivityAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/ActivityAction.java
@@ -197,12 +197,12 @@ public class ActivityAction implements CeWsAction {
return Optional.absent();
}
- Optional<CeQueueDto> queue = dbClient.ceQueueDao().selectByUuid(dbSession, textQuery);
+ java.util.Optional<CeQueueDto> queue = dbClient.ceQueueDao().selectByUuid(dbSession, textQuery);
if (queue.isPresent()) {
return Optional.of(formatter.formatQueue(dbSession, queue.get()));
}
- Optional<CeActivityDto> activity = dbClient.ceActivityDao().selectByUuid(dbSession, textQuery);
+ java.util.Optional<CeActivityDto> activity = dbClient.ceActivityDao().selectByUuid(dbSession, textQuery);
if (activity.isPresent()) {
return Optional.of(formatter.formatActivity(dbSession, activity.get()));
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskAction.java b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskAction.java
index fdc082607ed..a39958add89 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskAction.java
@@ -19,12 +19,12 @@
*/
package org.sonar.server.ce.ws;
-import com.google.common.base.Optional;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
+import java.util.Optional;
import java.util.Set;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
@@ -92,12 +92,12 @@ public class TaskAction implements CeWsAction {
WsCe.TaskResponse.Builder wsTaskResponse = WsCe.TaskResponse.newBuilder();
Optional<CeQueueDto> queueDto = dbClient.ceQueueDao().selectByUuid(dbSession, taskUuid);
if (queueDto.isPresent()) {
- Optional<ComponentDto> component = loadComponent(dbSession, queueDto.get().getComponentUuid());
+ com.google.common.base.Optional<ComponentDto> component = loadComponent(dbSession, queueDto.get().getComponentUuid());
checkPermission(component);
wsTaskResponse.setTask(wsTaskFormatter.formatQueue(dbSession, queueDto.get(), component));
} else {
CeActivityDto ceActivityDto = WsUtils.checkFoundWithOptional(dbClient.ceActivityDao().selectByUuid(dbSession, taskUuid), "No activity found for task '%s'", taskUuid);
- Optional<ComponentDto> component = loadComponent(dbSession, ceActivityDto.getComponentUuid());
+ com.google.common.base.Optional<ComponentDto> component = loadComponent(dbSession, ceActivityDto.getComponentUuid());
checkPermission(component);
Set<AdditionalField> additionalFields = AdditionalField.getFromRequest(wsRequest);
maskErrorStacktrace(ceActivityDto, additionalFields);
@@ -108,14 +108,14 @@ public class TaskAction implements CeWsAction {
}
}
- private Optional<ComponentDto> loadComponent(DbSession dbSession, @Nullable String projectUuid) {
+ private com.google.common.base.Optional<ComponentDto> loadComponent(DbSession dbSession, @Nullable String projectUuid) {
if (projectUuid == null) {
- return Optional.absent();
+ return com.google.common.base.Optional.absent();
}
return dbClient.componentDao().selectByUuid(dbSession, projectUuid);
}
- private void checkPermission(Optional<ComponentDto> component) {
+ private void checkPermission(com.google.common.base.Optional<ComponentDto> component) {
if (component.isPresent()) {
String orgUuid = component.get().getOrganizationUuid();
if (!userSession.hasPermission(OrganizationPermission.ADMINISTER, orgUuid) &&
diff --git a/server/sonar-server/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java b/server/sonar-server/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java
index 6e2b2b7dc7a..147e1764829 100644
--- a/server/sonar-server/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java
@@ -19,8 +19,8 @@
*/
package org.sonar.ce.queue;
-import com.google.common.base.Optional;
import java.util.List;
+import java.util.Optional;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;