Search in sources :

Example 1 with ReportsResult

use of org.activityinfo.legacy.shared.command.result.ReportsResult in project activityinfo by bedatadriven.

the class GetReportsTest method performanceTest.

@OnDataSet("/dbunit/get-report-performance-tests.db.xml")
// AI-1223
@Test
public void performanceTest() {
    // initial performance: 1838ms - sql fetch, 1962ms - time for client (+serialization/deserialization)
    // after performance tuning: 229ms - sql fetch, 273 ms - time for client (+serialization/deserialization)
    setUser(1);
    Stopwatch started = Stopwatch.createStarted();
    ReportsResult result = execute(new GetReports());
    assertNotNull(result);
    assertEquals(1, result.getData().get(0).getId());
    assertEquals("Report 1", result.getData().get(0).getTitle());
    assertEquals("Alex", result.getData().get(0).getOwnerName());
    long elapsed = started.elapsed(TimeUnit.MILLISECONDS);
    // must be less then one second
    assertTrue("GetReports takes " + elapsed + "ms.", elapsed < 1000);
}
Also used : GetReports(org.activityinfo.legacy.shared.command.GetReports) Stopwatch(com.google.common.base.Stopwatch) ReportsResult(org.activityinfo.legacy.shared.command.result.ReportsResult) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 2 with ReportsResult

use of org.activityinfo.legacy.shared.command.result.ReportsResult in project activityinfo by bedatadriven.

the class GetReportsTest method selectByUser2.

@Test
public void selectByUser2() {
    setUser(2);
    ReportsResult result = execute(new GetReports());
    assertNotNull(result);
    assertThat(result.getData().size(), equalTo(1));
    assertEquals(2, result.getData().get(0).getId());
    assertEquals("Report 1", result.getData().get(0).getTitle());
    assertEquals("Bavon", result.getData().get(0).getOwnerName());
}
Also used : GetReports(org.activityinfo.legacy.shared.command.GetReports) ReportsResult(org.activityinfo.legacy.shared.command.result.ReportsResult) Test(org.junit.Test)

Example 3 with ReportsResult

use of org.activityinfo.legacy.shared.command.result.ReportsResult in project activityinfo by bedatadriven.

the class GetReportsTest method selectByUser1.

@Test
public void selectByUser1() {
    setUser(1);
    ReportsResult result = execute(new GetReports());
    assertNotNull(result);
    assertTrue(result.getData().size() == 2);
    assertEquals(1, result.getData().get(0).getId());
    assertEquals("Report 1", result.getData().get(0).getTitle());
    assertEquals("Alex", result.getData().get(0).getOwnerName());
    assertEquals(3, result.getData().get(1).getId());
    assertEquals("Report 3", result.getData().get(1).getTitle());
    assertEquals("Alex", result.getData().get(1).getOwnerName());
    assertEquals(Integer.valueOf(1), result.getData().get(1).getDay());
    assertEquals(EmailDelivery.NONE, result.getData().get(1).getEmailDelivery());
}
Also used : GetReports(org.activityinfo.legacy.shared.command.GetReports) ReportsResult(org.activityinfo.legacy.shared.command.result.ReportsResult) Test(org.junit.Test)

Example 4 with ReportsResult

use of org.activityinfo.legacy.shared.command.result.ReportsResult in project activityinfo by bedatadriven.

the class ReportVisibilityTest method update.

@Test
public void update() {
    setUser(1);
    ReportVisibilityDTO db1 = new ReportVisibilityDTO();
    db1.setDatabaseId(1);
    db1.setVisible(true);
    db1.setDefaultDashboard(true);
    ReportVisibilityDTO db2 = new ReportVisibilityDTO();
    db2.setDatabaseId(2);
    db2.setVisible(false);
    ReportVisibilityDTO db3 = new ReportVisibilityDTO();
    db3.setDatabaseId(3);
    db3.setVisible(true);
    UpdateReportVisibility update = new UpdateReportVisibility(1, Arrays.asList(db1, db2, db3));
    execute(update);
    ReportVisibilityResult result = execute(new GetReportVisibility(1));
    assertThat(result.getList().size(), equalTo(2));
    // make sure we can still see the report
    ReportsResult visibleToMe = execute(new GetReports());
    assertThat(visibleToMe.getData().size(), equalTo(1));
    // Bavon
    setUser(2);
    ReportsResult visibleToBavon = execute(new GetReports());
    assertThat(visibleToBavon.getData().size(), equalTo(2));
    assertThat(getById(visibleToBavon, 1).isDashboard(), equalTo(true));
    assertThat(getById(visibleToBavon, 2).isDashboard(), equalTo(false));
    // Stefan, no access to db
    setUser(3);
    ReportsResult visibleToStefan = execute(new GetReports());
    assertThat(visibleToStefan.getData().size(), equalTo(0));
}
Also used : ReportVisibilityDTO(org.activityinfo.legacy.shared.model.ReportVisibilityDTO) ReportVisibilityResult(org.activityinfo.legacy.shared.command.result.ReportVisibilityResult) ReportsResult(org.activityinfo.legacy.shared.command.result.ReportsResult) Test(org.junit.Test)

Aggregations

ReportsResult (org.activityinfo.legacy.shared.command.result.ReportsResult)4 Test (org.junit.Test)4 GetReports (org.activityinfo.legacy.shared.command.GetReports)3 Stopwatch (com.google.common.base.Stopwatch)1 ReportVisibilityResult (org.activityinfo.legacy.shared.command.result.ReportVisibilityResult)1 ReportVisibilityDTO (org.activityinfo.legacy.shared.model.ReportVisibilityDTO)1 OnDataSet (org.activityinfo.server.database.OnDataSet)1