Skip to content
Snippets Groups Projects
Commit 4fed73d9 authored by Luke O'mahony's avatar Luke O'mahony
Browse files

add: added some integration tests for aws sns and shadow services

parent 745c74a4
Branches
No related merge requests found
package com.backend.glowhouse.aws;
import com.backend.glowhouse.aws.sns.SnsNotificationSender;
import com.backend.glowhouse.GlowhouseApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {GlowhouseApplication.class, SnsNotificationSender.class})
public class SnsTest {
@Autowired
SnsNotificationSender snsNotificationSender;
@Test
public void testSendToAwsSns() {
snsNotificationSender.sendIOCommandForLight("light", "ON");
}
}
package com.backend.glowhouse.aws;
import com.amazonaws.services.iot.client.AWSIotException;
import com.backend.glowhouse.GlowhouseApplication;
import com.backend.glowhouse.controller.DeviceShadowController;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {GlowhouseApplication.class, DeviceShadowController.class})
public class TestDeviceShadowApi {
@Autowired
DeviceShadowController deviceShadowController;
@Test
public void testUpdateShadow() {
//given a message payload for aws
String jsonUpdate = "{\n" +
" \"state\": {\n" +
" \"desired\" : {\n" +
" \"lights\" : \"ON\"\n" +
" }\n" +
" }\n" +
"}";
//and a service that exposes aws topics
deviceShadowController.updateShadow(jsonUpdate);
//TODO: add subback to test here, for now check you see a message on aws
Assert.assertEquals(1, 1);
}
@Test
public void testGetShadow() throws AWSIotException {
//given a request to aws for a devices shadow
String shadow = deviceShadowController.getDeviceShadow("glowhouse");
//TODO: assert here that shadow is as expected
Assert.assertEquals(1, 1);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment