use of jetbrains.buildServer.server.rest.data.PagedSearchResult in project teamcity-rest by JetBrains.
the class ProjectRequestTest method memoryTest.
// @Test
public void memoryTest() throws InterruptedException {
final ProjectRequest request = new ProjectRequest();
request.setInTests(myProjectFinder, myBranchFinder, myBeanContext);
final String locator = "archived:false,affectedProject:_Root";
final String fields = "count,project(id,internalId,name,parentProjectId,archived,readOnlyUI,buildTypes(buildType(id,paused,internalId,projectId,name,type,description)),description)";
Queue<Pair<Integer, ProjectEx>> q = new ArrayDeque<>();
q.add(new Pair<>(0, myProject));
final int max = 2;
final int children = 4;
int counter = 0;
while (!q.isEmpty()) {
Pair<Integer, ProjectEx> p = q.poll();
String prefix = "Bt" + StringUtils.repeat('a', 10 * p.getFirst());
for (int i = 0; i < children; i++) {
ProjectEx c = myFixture.createProject("z-" + p.first + "-" + counter++, p.second);
if (p.first < max) {
q.add(new Pair<>(p.first + 1, c));
}
for (int j = 0; j < children * 4; j++) c.createBuildType(prefix + j);
}
}
System.out.println(counter + " projects created.");
Thread[] ts = new Thread[100];
for (int i = 0; i < ts.length; i++) {
final int threadIdx = i;
ts[i] = new Thread(() -> {
new RestContext(z -> null).run(() -> {
for (int j = 0; j < 100; j++) {
final PagedSearchResult<SProject> result = myProjectFinder.getItems(locator);
Projects projects = new Projects(result.myEntries, null, new Fields(fields), myBeanContext);
projects.projects.stream().flatMap(p -> p.buildTypes.buildTypes.stream()).forEach(bt -> {
bt.getId();
bt.isPaused();
bt.getInternalId();
bt.getProjectId();
bt.getName();
bt.getType();
bt.getDescription();
});
System.out.println(String.format("Finished %d requests in thread %d", j, threadIdx));
}
return null;
});
});
ts[i].start();
}
for (Thread t : ts) t.join();
}
use of jetbrains.buildServer.server.rest.data.PagedSearchResult in project teamcity-rest by JetBrains.
the class ChangeRequest method getUniqueCommiters.
/**
* Experimental support only!
* @since 2021.1.1
*/
@GET
@Path("/{changeLocator}/commiters")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get unique commiters of the matching changes.", nickname = "getUniqueCommiters", hidden = true)
public Commiters getUniqueCommiters(@ApiParam(format = LocatorName.CHANGE) @PathParam("changeLocator") String changeLocator, @QueryParam("fields") String fields) {
Locator patchedChangeLocator = Locator.createPotentiallyEmptyLocator(changeLocator);
if (!patchedChangeLocator.isAnyPresent(PagerData.COUNT)) {
String lookupLimit = TeamCityProperties.getProperty("rest.request.changes.committersLookupLimit", DEFAULT_CHANGES_LOOKUP_LIMIT_FOR_COMMITERS);
patchedChangeLocator.setDimension(PagerData.COUNT, lookupLimit);
}
PagedSearchResult<SVcsModificationOrChangeDescriptor> changes = myChangeFinder.getItems(patchedChangeLocator.getStringRepresentation());
List<CommiterData> commiters = ChangeUtil.getUniqueCommiters(changes.myEntries.stream().map(modOrDesc -> modOrDesc.getSVcsModification()));
return new Commiters(commiters, new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.server.rest.data.PagedSearchResult in project teamcity-rest by JetBrains.
the class PagerDataTest method testSpecialSymbols.
@Test
public void testSpecialSymbols() throws URISyntaxException {
List<String> items = new ArrayList<String>();
PagedSearchResult<String> pagedResult = new PagedSearchResult<>(items, 5L, 3, null, 10L, true, null);
UriBuilder uriBuilder = UriBuilder.fromUri(new URI("http://some.url:8111/teamcity/smth?locator=start:5,count:3,a:%25"));
final PagerData pagerData = new PagerData(uriBuilder, "/teamcity", pagedResult, "start:5,count:3,a:(eight-[{~!@#$%^&*_+`=\\|'\";:/?,<.>]})", "locator");
assertEquals("href is different", "/smth?locator=start:5,count:3,a:%25", pagerData.getHref());
assertEquals("nextHref is different", (Object) "/smth?locator=a:(eight-%5B%7B%7E%21%40%23$%25%5E%26*_%2B%60%3D%5C%7C%27%22%3B:%2F%3F,%3C.%3E%5D%7D),count:3,lookupLimit:20,start:5", pagerData.getNextHref());
assertEquals("prevHref is different", (Object) "/smth?locator=a:(eight-%5B%7B%7E%21%40%23$%25%5E%26*_%2B%60%3D%5C%7C%27%22%3B:%2F%3F,%3C.%3E%5D%7D),count:3,start:2", pagerData.getPrevHref());
}
Aggregations