diff --git a/src/test/java/com/backend/glowhouse/aws/SnsTest.java b/src/test/java/com/backend/glowhouse/aws/SnsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8a96ca4bbb5e203b66454f084361a86aa81406a9 --- /dev/null +++ b/src/test/java/com/backend/glowhouse/aws/SnsTest.java @@ -0,0 +1,21 @@ +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"); + } +} diff --git a/src/test/java/com/backend/glowhouse/aws/TestDeviceShadowApi.java b/src/test/java/com/backend/glowhouse/aws/TestDeviceShadowApi.java new file mode 100644 index 0000000000000000000000000000000000000000..a34f792db861990ae1046382d2e3c1009f2d17f4 --- /dev/null +++ b/src/test/java/com/backend/glowhouse/aws/TestDeviceShadowApi.java @@ -0,0 +1,45 @@ +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); + } +}