import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
+import org.sonar.api.server.ws.Change;
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.web.UserRole;
import org.sonar.core.util.Uuids;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import static org.sonar.api.server.ws.WebService.Param.PAGE;
import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE;
-import static org.sonar.api.web.UserRole.*;
+import static org.sonar.api.web.UserRole.CODEVIEWER;
+import static org.sonar.core.util.Protobuf.setNullable;
import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001;
import static org.sonar.server.ws.WsUtils.checkFoundWithOptional;
.setResponseExample(Resources.getResource(getClass(), "tests-example-list.json"))
.setDeprecatedSince("5.6")
.setHandler(this)
+ .setChangelog(new Change("6.6", "\"fileBranch\" field is now returned"))
.addPagingParams(100, MAX_LIMIT);
action
testBuilder.setFileId(testDoc.fileUuid());
ComponentDto component = componentsByTestFileUuid.get(testDoc.fileUuid());
if (component != null) {
- testBuilder.setFileKey(component.getDbKey());
+ testBuilder.setFileKey(component.getKey());
testBuilder.setFileName(component.longName());
+ setNullable(component.getBranch(), testBuilder::setFileBranch);
}
testBuilder.setStatus(WsTests.TestStatus.valueOf(testDoc.status()));
if (testDoc.durationInMs() != null) {
import static java.lang.String.format;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE;
import static org.sonar.api.web.UserRole.CODEVIEWER;
import static org.sonar.api.web.UserRole.USER;
.setParam("branch", testFile.getBranch()));
assertThat(request.getTestsList())
- .extracting(WsTests.Test::getId)
- .containsOnly(test1.getUuid(), test2.getUuid());
+ .extracting(WsTests.Test::getId, WsTests.Test::getFileKey, WsTests.Test::getFileBranch)
+ .containsOnly(
+ tuple(test1.getUuid(), testFile.getKey(), testFile.getBranch()),
+ tuple(test2.getUuid(), testFile.getKey(), testFile.getBranch()));
}
@Test
.setParam("branch", testFile.getBranch()));
assertThat(request.getTestsList())
- .extracting(WsTests.Test::getId)
- .containsOnly(test1.getUuid(), test3.getUuid());
+ .extracting(WsTests.Test::getId, WsTests.Test::getFileKey, WsTests.Test::getFileBranch)
+ .containsOnly(
+ tuple(test1.getUuid(), testFile.getKey(), testFile.getBranch()),
+ tuple(test3.getUuid(), testFile.getKey(), testFile.getBranch()));
}
@Test