Search in sources :

Example 1 with GetReportModel

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

the class GetReportModelTest method serializationDeserialization.

// AI-1359
@Test
public void serializationDeserialization() throws IOException, ClassNotFoundException {
    setUser(1);
    ReportDTO result = execute(new GetReportModel(3, true));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(result);
    ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
    ReportDTO rereadDto = (ReportDTO) ois.readObject();
    assertEquals(result.getReportMetadataDTO().getId(), rereadDto.getReportMetadataDTO().getId());
    assertEquals(result.getReportMetadataDTO().getSubscribers(), rereadDto.getReportMetadataDTO().getSubscribers());
    assertEquals(result.getReportMetadataDTO().getAmOwner(), rereadDto.getReportMetadataDTO().getAmOwner());
    assertEquals(result.getReportMetadataDTO().getEmailDelivery(), rereadDto.getReportMetadataDTO().getEmailDelivery());
    assertEquals(result.getReportMetadataDTO().getOwnerName(), rereadDto.getReportMetadataDTO().getOwnerName());
    assertEquals(result.getReportMetadataDTO().getDay(), rereadDto.getReportMetadataDTO().getDay());
}
Also used : GetReportModel(org.activityinfo.legacy.shared.command.GetReportModel) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) Test(org.junit.Test)

Example 2 with GetReportModel

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

the class GetReportModelTest method selectReportWithMetadata.

@Test
public void selectReportWithMetadata() {
    setUser(1);
    ReportDTO result = execute(new GetReportModel(3, true));
    assertNotNull(result.getReport());
    assertEquals("Report 3", result.getReport().getTitle());
    assertNotNull(result.getReportMetadataDTO());
    assertEquals("Alex", result.getReportMetadataDTO().getOwnerName());
}
Also used : GetReportModel(org.activityinfo.legacy.shared.command.GetReportModel) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) Test(org.junit.Test)

Example 3 with GetReportModel

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

the class GenerateDashboardElementHandler method execute.

@Override
public CommandResult execute(GenerateDashboardElement cmd, User user) throws CommandException {
    ReportDTO report = dispatcher.execute(new GetReportModel(cmd.getReportId()));
    if (report.getReport().getElements().isEmpty()) {
        return new TextReportElement("The report is empty");
    } else {
        ReportElement element = report.getReport().getElements().get(0);
        element.setContent(generator.generateElement(user, element, null, new DateRange()));
        return element;
    }
}
Also used : DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) GetReportModel(org.activityinfo.legacy.shared.command.GetReportModel) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) ReportElement(org.activityinfo.legacy.shared.reports.model.ReportElement) TextReportElement(org.activityinfo.legacy.shared.reports.model.TextReportElement) TextReportElement(org.activityinfo.legacy.shared.reports.model.TextReportElement)

Example 4 with GetReportModel

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

the class GetReportModelTest method selectReportOnly.

@Test
public void selectReportOnly() {
    setUser(1);
    ReportDTO result = execute(new GetReportModel(3));
    assertNotNull(result.getReport());
    assertEquals("Report 3", result.getReport().getTitle());
    assertNull(result.getReportMetadataDTO());
}
Also used : GetReportModel(org.activityinfo.legacy.shared.command.GetReportModel) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) Test(org.junit.Test)

Example 5 with GetReportModel

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

the class GetReportModelTest method selectReportOnly2.

@Test
public void selectReportOnly2() {
    setUser(1);
    ReportDTO result = execute(new GetReportModel(3, false));
    assertNotNull(result.getReport());
    assertEquals("Report 3", result.getReport().getTitle());
    assertNull(result.getReportMetadataDTO());
}
Also used : GetReportModel(org.activityinfo.legacy.shared.command.GetReportModel) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) Test(org.junit.Test)

Aggregations

GetReportModel (org.activityinfo.legacy.shared.command.GetReportModel)5 ReportDTO (org.activityinfo.legacy.shared.model.ReportDTO)5 Test (org.junit.Test)4 DateRange (org.activityinfo.legacy.shared.reports.model.DateRange)1 ReportElement (org.activityinfo.legacy.shared.reports.model.ReportElement)1 TextReportElement (org.activityinfo.legacy.shared.reports.model.TextReportElement)1