Package com.cumulocity.rest.representation.alarm

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


        String url = getSelfUri() + "/" + alarmToUpdate.getId().getValue();
        return 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


        assertThat(persistentProvider.counter.get()).isGreaterThan(13);
    }
   
    @Test
    public void shouldPersistRequestToFile() throws Exception {
        BufferedRequest request = BufferedRequest.create(HttpMethod.POST, "test", AlarmMediaType.ALARM, new AlarmRepresentation());
       
        persistentProvider.offer(new ProcessingRequest(1 ,request));
       
        assertThat(new File(pathToTempFolder + NEW_REQUESTS_PATH + "1")).exists();
    }
View Full Code Here

        assertThat(new File(pathToTempFolder + NEW_REQUESTS_PATH + "1")).exists();
    }
   
    @Test
    public void shouldNotCreateAFileWhenQueueIsFull() throws Exception {
        BufferedRequest request = BufferedRequest.create(HttpMethod.POST, "test", AlarmMediaType.ALARM, new AlarmRepresentation());
        persistentProvider = new FileBasedPersistentProvider(1, pathToTempFolder);
       
        expectedException.expect(IllegalStateException.class);
        expectedException.expectMessage("Queue is full");
       
View Full Code Here

        persistentProvider.offer(new ProcessingRequest(2 ,request));
    }
   
    @Test
    public void shouldReturnRequestFromQueue() throws Exception {
        BufferedRequest request = BufferedRequest.create(HttpMethod.POST, "test", AlarmMediaType.ALARM, new AlarmRepresentation());
        persistentProvider.offer(new ProcessingRequest(1 ,request));
       
        ProcessingRequest result = persistentProvider.poll();
       
        assertThat(result.getId()).isEqualTo(1);
View Full Code Here

   
    @Test
    public void shouldRetrieveAlarmRep() throws SDKException {
        //Given
        GId gid = new GId("global_id");
        AlarmRepresentation alarmRep = new AlarmRepresentation();
        when(restConnector.get(ALARM_COLLECTION_URL + "/global_id", AlarmMediaType.ALARM, AlarmRepresentation.class)).thenReturn(alarmRep);

        //When
        AlarmRepresentation retrieved = alarmApi.getAlarm(gid);

        //Then
        assertThat(retrieved, sameInstance(alarmRep));
    }
View Full Code Here

    }

    @Test
    public void shouldUpdateAlarmRep() throws SDKException {
        //Given
        AlarmRepresentation alarmToUpdate = new AlarmRepresentation();
        alarmToUpdate.setId(new GId("global_id"));
        alarmToUpdate.setStatus("STATUS");
        AlarmRepresentation alarmRep = new AlarmRepresentation();
        when(
                restConnector.put(eq(ALARM_COLLECTION_URL + "/global_id"), eq(AlarmMediaType.ALARM),
                        argThat(hasOnlyUpdatableFields(alarmToUpdate)))).thenReturn(alarmRep);

        //When
        AlarmRepresentation updated = alarmApi.updateAlarm(alarmToUpdate);

        //Then
        assertThat(updated, sameInstance(alarmRep));
    }
View Full Code Here

    }

    @Test
    public void testCreateAlarmInCollection() throws SDKException {
        //Given
        AlarmRepresentation alarmRepresentation = new AlarmRepresentation();
        AlarmRepresentation created = new AlarmRepresentation();
        when(restConnector.post(ALARM_COLLECTION_URL, AlarmMediaType.ALARM, alarmRepresentation)).thenReturn(created);

        // When
        AlarmRepresentation result = alarmApi.create(alarmRepresentation);

        // Then
        assertThat(result, sameInstance(created));
    }
View Full Code Here

    }

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

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

        // Then
        assertThat(created.getId(), is(notNullValue()));
    }
View Full Code Here

    }

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

        // Then
        exception.expect(sdkException(UNPROCESSABLE));
View Full Code Here

    }

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

        // Then
        exception.expect(sdkException(UNPROCESSABLE));
View Full Code Here

TOP

Related Classes of com.cumulocity.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.