use of org.opengrok.web.api.v1.controller.HistoryController.HistoryDTO in project OpenGrok by OpenGrok.
the class HistoryControllerTest method testHistoryGet.
@Test
public void testHistoryGet() throws Exception {
final String path = "git";
int size = 5;
int start = 2;
Response response = target("history").queryParam("path", path).queryParam("max", size).queryParam("start", start).request().get();
HistoryDTO history = response.readEntity(new GenericType<>() {
});
assertEquals(size, history.getEntries().size());
assertEquals("Kryštof Tulinger <krystof.tulinger@oracle.com>", history.getEntries().get(0).getAuthor());
History repoHistory = HistoryGuru.getInstance().getHistory(new File(repository.getSourceRoot(), path));
assertEquals(history, getHistoryDTO(repoHistory.getHistoryEntries(size, start), repoHistory.getTags(), start, size, repoHistory.getHistoryEntries().size()));
}
use of org.opengrok.web.api.v1.controller.HistoryController.HistoryDTO in project OpenGrok by OpenGrok.
the class HistoryControllerTest method testHistoryDTOEquals.
@Test
public void testHistoryDTOEquals() {
HistoryEntry historyEntry = new HistoryEntry("1", new Date(1245446973L / 60 * 60 * 1000), "xyz", "foo", true);
HistoryEntryDTO entry1 = new HistoryEntryDTO(historyEntry);
historyEntry.setAuthor("abc");
HistoryEntryDTO entry2 = new HistoryEntryDTO(historyEntry);
assertEquals(entry1, entry1);
assertNotEquals(entry1, entry2);
HistoryDTO history1 = new HistoryDTO(Collections.singletonList(entry1), 0, 1, 1);
HistoryDTO history2 = new HistoryDTO(Collections.singletonList(entry2), 0, 1, 1);
assertEquals(history1, history1);
assertNotEquals(history1, history2);
}
use of org.opengrok.web.api.v1.controller.HistoryController.HistoryDTO in project OpenGrok by OpenGrok.
the class HistoryController method get.
@GET
@CorsEnable
@PathAuthorized
@Produces(MediaType.APPLICATION_JSON)
public HistoryDTO get(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("path") final String path, @QueryParam("withFiles") final boolean withFiles, @QueryParam("max") @DefaultValue(MAX_RESULTS + "") final int maxEntries, @QueryParam("start") @DefaultValue(0 + "") final int startIndex) throws HistoryException, IOException, NoPathParameterException {
File file = toFile(path);
History history = HistoryGuru.getInstance().getHistory(file, withFiles, true);
if (history == null) {
return null;
}
return getHistoryDTO(history.getHistoryEntries(maxEntries, startIndex), history.getTags(), startIndex, maxEntries, history.getHistoryEntries().size());
}
Aggregations