Package com.cumulocity.me.rest.representation.alarm

Examples of com.cumulocity.me.rest.representation.alarm.AlarmCollectionRepresentation


        // Given
        alarmApi.create(aSampleAlarm(source1));
        alarmApi.create(aSampleAlarm(source1));

        // When
        AlarmCollectionRepresentation alarms = (AlarmCollectionRepresentation) alarmApi.getAlarms().get();

        // Then
        assertThat(alarms.getAlarms().size()).isGreaterThanOrEqualTo(2);
    }
View Full Code Here


        source2 = platform.getInventoryApi().create(aSampleMo().withName("MO2-" + currentTimeMillis()).build());
        alarmApi.create(aSampleAlarm(source1));

        // When
        AlarmFilter filter = new AlarmFilter().bySource(source2);
        AlarmCollectionRepresentation bySource = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(filter).get();

        // Then
        List alarms = bySource.getAlarms();
        assertThat(alarms.size()).isEqualTo(0);
    }
View Full Code Here

        alarmApi.create(aSampleAlarm(source1));
        alarmApi.create(aSampleAlarm(source1));

        // When
        AlarmFilter filter = new AlarmFilter().bySource(source1);
        AlarmCollectionRepresentation bySource = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(filter).get();

        // Then
        List alarms = bySource.getAlarms();
        assertThat(alarms.size()).isEqualTo(2);
    }
View Full Code Here

        alarmApi.create(aSampleAlarm(source1));
        alarmApi.create(aSampleAlarm(source2));

        // When
        AlarmFilter filter = new AlarmFilter().bySource(source1);
        AlarmCollectionRepresentation bySource = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(filter).get();

        // Then
        List alarms = bySource.getAlarms();
        assertThat(alarms.size()).isEqualTo(1);
        assertThat(((AlarmRepresentation)alarms.get(0)).getSource().getId()).isEqualTo(source1.getId());
    }
View Full Code Here

        alarmApi.create(anAlarmRepresentationLike(ALARM_REPRESENTATION).withStatus("ACKNOWLEDGED").withSource(source1).build());

        // When
        AlarmFilter acknowledgedFilter = new AlarmFilter().byStatus(CumulocityAlarmStatuses.ACKNOWLEDGED);
        AlarmCollectionRepresentation acknowledgedAlarms = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(acknowledgedFilter).get();

        // Then
        List alarms = acknowledgedAlarms.getAlarms();
        assertThat(alarms.size()).isGreaterThanOrEqualTo(1);
        assertThat(((AlarmRepresentation)alarms.get(0)).getStatus()).isEqualTo("ACKNOWLEDGED");
    }
View Full Code Here

        alarmApi.create(anAlarmRepresentationLike(ALARM_REPRESENTATION).withStatus("ACKNOWLEDGED").withSource(source1).build());
        alarmApi.create(anAlarmRepresentationLike(ALARM_REPRESENTATION).withStatus("ACKNOWLEDGED").withSource(source2).build());

        // When
        AlarmFilter acknowledgedFilter = new AlarmFilter().byStatus(CumulocityAlarmStatuses.ACKNOWLEDGED).bySource(source1);
        AlarmCollectionRepresentation acknowledgedAlarms = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(acknowledgedFilter).get();

        // Then
        List alarms = acknowledgedAlarms.getAlarms();
        assertThat(alarms.size()).isEqualTo(1);
        assertThat(((AlarmRepresentation)alarms.get(0)).getStatus()).isEqualTo("ACKNOWLEDGED");
        assertThat(((AlarmRepresentation)alarms.get(0)).getSource().getId()).isEqualTo(source1.getId());
    }
View Full Code Here

            alarmApi.create(rep);
        }
        AlarmFilter filter = new AlarmFilter().bySource(source1);

        // When
        AlarmCollectionRepresentation alarms = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(filter).get();

        // Then
        assertThat(alarms.getAlarms().size()).isEqualTo(5);

        // When
        AlarmCollectionRepresentation page1st = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(filter).getPage(alarms, 1);

        // Then
        assertThat(page1st.getAlarms().size()).isEqualTo(5);

        // When
        AlarmCollectionRepresentation page2nd = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(filter).getPage(alarms, 2);

        // Then
        assertThat(page2nd.getAlarms().size()).isEqualTo(5);

        // When
        AlarmCollectionRepresentation page3rd = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(filter).getPage(alarms, 3);

        // Then
        assertThat(page3rd.getAlarms().size()).isEqualTo(2);

        // When
        AlarmCollectionRepresentation page4th = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(filter).getPage(alarms, 4);

        // Then
        assertThat(page4th.getAlarms().size()).isEqualTo(0);
    }
View Full Code Here

            alarmApi.create(aSampleAlarm(source1));
        }
        AlarmFilter filter = new AlarmFilter().bySource(source1);

        // When
        AlarmCollectionRepresentation alarms = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(filter).get();

        // Then
        assertThat(alarms.getAlarms().size()).isEqualTo(5);

        // When
        AlarmCollectionRepresentation page2nd = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(filter).getPage(alarms, 2);

        // Then
        assertThat(page2nd.getAlarms().size()).isEqualTo(5);

        // When
        AlarmCollectionRepresentation page3rd = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(filter).getNextPage(page2nd);

        // Then
        assertThat(page3rd.getPageStatistics().getCurrentPage()).isEqualTo(3);
        assertThat(page3rd.getAlarms().size()).isEqualTo(2);

        // When
        AlarmCollectionRepresentation page1st = (AlarmCollectionRepresentation) alarmApi.getAlarmsByFilter(filter).getPreviousPage(page2nd);

        // Then
        assertThat(page1st.getPageStatistics().getCurrentPage()).isEqualTo(1);
        assertThat(page1st.getAlarms().size()).isEqualTo(5);

    }
View Full Code Here

TOP

Related Classes of com.cumulocity.me.rest.representation.alarm.AlarmCollectionRepresentation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.