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

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


        String url = getAlarmsApiRepresentation().getAlarms().getSelf() + "/" + alarmToUpdate.getId().getValue();
        return (AlarmRepresentation) restConnector.put(url, AlarmMediaType.ALARM, prepareForUpdate(alarmToUpdate));
    }

    private AlarmRepresentation prepareForUpdate(AlarmRepresentation alarm) {
        AlarmRepresentation updatable = new AlarmRepresentation();
        updatable.setStatus(alarm.getStatus());
        updatable.setSeverity(alarm.getSeverity());
        updatable.setSource(alarm.getSource());
        updatable.setText(alarm.getText());
        updatable.setAttrs(alarm.getAttrs());
        return updatable;
    }
View Full Code Here


    }

    @Test
    public void shouldHaveIdAfterCreateAlarm() throws Exception {
        // Given
        AlarmRepresentation rep = aSampleAlarm(source1);

        // When
        AlarmRepresentation created = alarmApi.create(rep);

        // Then
        assertThat(created.getId()).isNotNull();
    }
View Full Code Here

    }

    @Test
    public void createAlarmWithoutTime() throws Exception {
        // Given
        AlarmRepresentation alarm = anAlarmRepresentationLike(ALARM_REPRESENTATION).withSource(source1).withTime(null).build();

        // Then
        exception.expect(sdkException(UNPROCESSABLE));

        // When
View Full Code Here

    }

    @Test
    public void createAlarmWithoutText() throws Exception {
        // Given
        AlarmRepresentation alarm = anAlarmRepresentationLike(ALARM_REPRESENTATION).withSource(source1).withText(null).build();

        // Then
        exception.expect(sdkException(UNPROCESSABLE));

        // When
View Full Code Here

    }

    @Test
    public void createAlarmWithoutStatus() throws Exception {
        // Given
        AlarmRepresentation alarm = anAlarmRepresentationLike(ALARM_REPRESENTATION).withSource(source1).withStatus(null).build();

        // Then
        exception.expect(sdkException(UNPROCESSABLE));

        // When
View Full Code Here

    }

    @Test
    public void createAlarmsWithoutSeverity() throws Exception {
        // Given
        AlarmRepresentation alarm = anAlarmRepresentationLike(ALARM_REPRESENTATION).withSource(source1).withSeverity(null).build();

        // Then
        exception.expect(sdkException(UNPROCESSABLE));

        // When
View Full Code Here

    }

    @Test
    public void shouldGetAlarmById() throws Exception {
        // Given
        AlarmRepresentation created = alarmApi.create(anAlarmRepresentationLike(ALARM_REPRESENTATION).withStatus("ACTIVE").withSource(source1)
                .build());

        AlarmRepresentation returned = alarmApi.getAlarm(created.getId());

        assertThat(returned.getStatus()).isEqualTo("ACTIVE");
        assertThat(returned.getSource().getId()).isEqualTo(source1.getId());
    }
View Full Code Here

    }

    @Test
    public void shouldReturnTheUpdatedAlarm() throws Exception {
        // Given
        AlarmRepresentation created = alarmApi.create(anAlarmRepresentationLike(ALARM_REPRESENTATION).withStatus("ACTIVE").withSource(source1)
                .build());

        // When
        AlarmRepresentation alarm = new AlarmRepresentation();
        alarm.setStatus("ACKNOWLEDGED");
        alarm.setId(created.getId());
        AlarmRepresentation updated = alarmApi.updateAlarm(alarm);

        // Then
        assertThat(updated.getStatus()).isEqualTo("ACKNOWLEDGED");
        assertThat(updated.getSource().getId()).isEqualTo(source1.getId());
    }
View Full Code Here

    }

    @Test
    public void shouldUpdateAlarm() throws Exception {
        // Given
        AlarmRepresentation created = alarmApi.create(anAlarmRepresentationLike(ALARM_REPRESENTATION).withStatus("ACTIVE").withSource(source1)
                .build());

        // When
        AlarmRepresentation alarm = new AlarmRepresentation();
        alarm.setStatus("ACKNOWLEDGED");
        alarm.setId(created.getId());
        alarmApi.updateAlarm(alarm);

        // Then
        AlarmRepresentation returned = alarmApi.getAlarm(created.getId());

        assertThat(returned.getStatus()).isEqualTo("ACKNOWLEDGED");
        assertThat(returned.getSource().getId()).isEqualTo(source1.getId());
    }
View Full Code Here

    @Test
    public void getAlarmCollectionByDefaultPageSettings() throws Exception {
        // Given
        for (int i = 0; i < 12; i++) {
            AlarmRepresentation rep = aSampleAlarm(source1);
            alarmApi.create(rep);
        }
        AlarmFilter filter = new AlarmFilter().bySource(source1);

        // When
View Full Code Here

TOP

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

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.