Seems that the test for lights passes, tried with the emulator
This commit is contained in:
150
.idea/workspace.xml
generated
150
.idea/workspace.xml
generated
@@ -2,19 +2,10 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="78e01e81-87ab-43aa-be01-5489e21c7fc2" name="Default" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/4.4/fileHashes/fileHashes.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/4.4/fileHashes/fileHashes.bin" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/4.4/fileHashes/fileHashes.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/4.4/fileHashes/fileHashes.lock" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/4.4/taskHistory/taskHistory.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/4.4/taskHistory/taskHistory.bin" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/4.4/taskHistory/taskHistory.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/4.4/taskHistory/taskHistory.lock" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/outputFiles.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/outputFiles.bin" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/gradle.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/gradle.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/tests/TestLights.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/gradle/wrapper/gradle-wrapper.properties" beforeDir="false" afterPath="$PROJECT_DIR$/gradle/wrapper/gradle-wrapper.properties" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/device/hue.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/device/hue.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/device/hue.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/device/Hue.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/manage/rest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/manage/Rest.java" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/.gradle/" />
|
||||
<ignored path="$PROJECT_DIR$/build/" />
|
||||
@@ -95,20 +86,24 @@
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file leaf-file-name="hue.java" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/device/hue.java">
|
||||
<file leaf-file-name="Hue.java" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/device/Hue.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="235">
|
||||
<caret line="24" column="24" selection-start-line="24" selection-start-column="24" selection-end-line="24" selection-end-column="24" />
|
||||
<state relative-caret-position="240">
|
||||
<caret line="18" column="5" lean-forward="true" selection-start-line="18" selection-start-column="5" selection-end-line="18" selection-end-column="5" />
|
||||
<folding>
|
||||
<element signature="e#310#311#0" expanded="true" />
|
||||
<element signature="e#362#363#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="rest.java" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/manage/rest.java">
|
||||
<file leaf-file-name="TestLights.java" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/tests/TestLights.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="262">
|
||||
<caret line="67" column="35" lean-forward="true" selection-start-line="67" selection-start-column="35" selection-end-line="67" selection-end-column="35" />
|
||||
<state relative-caret-position="102">
|
||||
<caret line="8" column="17" selection-start-line="8" selection-start-column="17" selection-end-line="8" selection-end-column="17" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
@@ -118,6 +113,13 @@
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Class" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
@@ -489,6 +491,9 @@
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/build.gradle" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/device/hue.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/tests/Test.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/device/Hue.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/tests/TestLights.java" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@@ -555,6 +560,14 @@
|
||||
<item name="java" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="manage" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="SeniorAssistant" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="SeniorAssistant" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="main" type="8a07ba80:GradleTreeStructureProvider$GradleModuleDirectoryNode" />
|
||||
<item name="java" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="tests" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
@@ -582,7 +595,7 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager" selected="Gradle.SeniorAssistant [build]">
|
||||
<component name="RunManager" selected="JUnit.TestLights">
|
||||
<configuration default="true" type="Application" factoryName="Application">
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
</configuration>
|
||||
@@ -619,6 +632,29 @@
|
||||
<setting name="workDir" value="file://$PROJECT_DIR$" />
|
||||
<setting name="debug" value="false" />
|
||||
</configuration>
|
||||
<configuration name="TestLights" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||
<module name="SeniorAssistant_main" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="tests.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="PACKAGE_NAME" value="tests" />
|
||||
<option name="MAIN_CLASS_NAME" value="tests.TestLights" />
|
||||
<option name="METHOD_NAME" />
|
||||
<option name="TEST_OBJECT" value="class" />
|
||||
<option name="VM_PARAMETERS" value="-ea" />
|
||||
<option name="PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<option name="TEST_SEARCH_SCOPE">
|
||||
<value defaultName="singleModule" />
|
||||
</option>
|
||||
<patterns />
|
||||
</configuration>
|
||||
<configuration default="true" type="JUnit" factoryName="JUnit">
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
@@ -661,9 +697,11 @@
|
||||
<item itemvalue="Groovy.build" />
|
||||
<item itemvalue="Groovy.build (1)" />
|
||||
<item itemvalue="Gradle.SeniorAssistant [build]" />
|
||||
<item itemvalue="JUnit.TestLights" />
|
||||
</list>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="JUnit.TestLights" />
|
||||
<item itemvalue="Gradle.SeniorAssistant [build]" />
|
||||
<item itemvalue="Groovy.build (1)" />
|
||||
<item itemvalue="Groovy.build" />
|
||||
@@ -681,12 +719,31 @@
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1527511421271</updated>
|
||||
<workItem from="1527511465296" duration="493000" />
|
||||
<workItem from="1527514123141" duration="3477000" />
|
||||
<workItem from="1527514123141" duration="7701000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Updated build gradle Added functions ph. hue">
|
||||
<created>1527518149240</created>
|
||||
<option name="number" value="00001" />
|
||||
<option name="presentableId" value="LOCAL-00001" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1527518149240</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="2" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TestHistory">
|
||||
<history-entry file="TestLights - 2018.05.28 at 17h 29m 58s.xml">
|
||||
<configuration name="TestLights" configurationId="JUnit" />
|
||||
</history-entry>
|
||||
<history-entry file="TestLights - 2018.05.28 at 17h 34m 08s.xml">
|
||||
<configuration name="TestLights" configurationId="JUnit" />
|
||||
</history-entry>
|
||||
<history-entry file="TestLights - 2018.05.28 at 17h 38m 24s.xml">
|
||||
<configuration name="TestLights" configurationId="JUnit" />
|
||||
</history-entry>
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="3970000" />
|
||||
<option name="totallyTimeSpent" value="8194000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="-8" y="-8" width="1382" height="744" extended-state="6" />
|
||||
@@ -701,8 +758,8 @@
|
||||
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" weight="0.32838285" />
|
||||
<window_info anchor="right" id="Maven Projects" order="3" />
|
||||
<window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
|
||||
<window_info anchor="bottom" id="Version Control" order="7" />
|
||||
<window_info anchor="bottom" id="Run" order="2" weight="0.32838285" />
|
||||
<window_info anchor="bottom" id="Version Control" order="7" weight="0.32838285" />
|
||||
<window_info anchor="bottom" id="Run" order="2" visible="true" weight="0.32838285" />
|
||||
<window_info anchor="bottom" id="Terminal" order="7" />
|
||||
<window_info id="Capture Tool" order="2" />
|
||||
<window_info id="Designer" order="2" />
|
||||
@@ -730,17 +787,40 @@
|
||||
<component name="VcsContentAnnotationSettings">
|
||||
<option name="myLimit" value="2678400000" />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="Updated build gradle Added functions ph. hue" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Updated build gradle Added functions ph. hue" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/device/hue.java">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/device/Hue.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
<caret lean-forward="true" />
|
||||
<folding>
|
||||
<element signature="e#310#311#0" expanded="true" />
|
||||
<element signature="e#362#363#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/settings.gradle">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/manage/Rest.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="262">
|
||||
<caret line="67" column="35" selection-start-line="67" selection-start-column="35" selection-end-line="67" selection-end-column="35" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.gitignore">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-1136" />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/build.gradle">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="221">
|
||||
@@ -748,20 +828,24 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/manage/rest.java">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/device/Hue.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="262">
|
||||
<caret line="67" column="35" lean-forward="true" selection-start-line="67" selection-start-column="35" selection-end-line="67" selection-end-column="35" />
|
||||
<state relative-caret-position="240">
|
||||
<caret line="18" column="5" lean-forward="true" selection-start-line="18" selection-start-column="5" selection-end-line="18" selection-end-column="5" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#310#311#0" expanded="true" />
|
||||
<element signature="e#362#363#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/device/hue.java">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/tests/TestLights.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="235">
|
||||
<caret line="24" column="24" selection-start-line="24" selection-start-column="24" selection-end-line="24" selection-end-column="24" />
|
||||
<state relative-caret-position="102">
|
||||
<caret line="8" column="17" selection-start-line="8" selection-start-column="17" selection-end-line="8" selection-end-column="17" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
package device;
|
||||
|
||||
import java.util.Map;
|
||||
import manage.rest;
|
||||
import manage.Rest;
|
||||
|
||||
public class hue {
|
||||
String baseURL = "192.168.0.2";
|
||||
String username = "admin";
|
||||
String lightsURL = baseURL+"/api/"+username+"/lights/";
|
||||
public class Hue {
|
||||
//private String baseURL;// = "192.168.0.2";
|
||||
//private String username;// = "admin";
|
||||
private String lightsURL;// = baseURL+"/api/"+username+"/lights/";
|
||||
|
||||
Map<String, ?> allLights = rest.get(lightsURL);
|
||||
private Map<String, ?> allLights;
|
||||
|
||||
public Hue () {
|
||||
this("192.168.0.2/api/admin/lights/");
|
||||
}
|
||||
public Hue (String url) {
|
||||
lightsURL = url;
|
||||
allLights = Rest.get(lightsURL);
|
||||
}
|
||||
|
||||
public void turnOn() {
|
||||
for (String light : allLights.keySet()) {
|
||||
String callURL = lightsURL + light + "/state";
|
||||
String body = "{ \"on\" : true }";
|
||||
rest.put(callURL, body, "application/json");
|
||||
Rest.put(callURL, body, "application/json");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +30,7 @@ public class hue {
|
||||
for (String light : allLights.keySet()) {
|
||||
String callURL = lightsURL + light + "/state";
|
||||
String body = "{ \"on\" : false }";
|
||||
rest.put(callURL, body, "application/json");
|
||||
Rest.put(callURL, body, "application/json");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +38,7 @@ public class hue {
|
||||
for (String light : allLights.keySet()) {
|
||||
String callURL = lightsURL + light + "/state";
|
||||
String body = "{ \"bri\" : "+num+" }";
|
||||
rest.put(callURL, body, "application/json");
|
||||
Rest.put(callURL, body, "application/json");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +46,7 @@ public class hue {
|
||||
for (String light : allLights.keySet()) {
|
||||
String callURL = lightsURL + light + "/state";
|
||||
String body = "{ \""+attribute+"\" : "+value+" }";
|
||||
rest.put(callURL, body, "application/json");
|
||||
Rest.put(callURL, body, "application/json");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.apache.http.util.EntityUtils;
|
||||
* @author <a href="mailto:luigi.derussis@uniupo.it">Luigi De Russis</a>
|
||||
* @version 1.0 (18/05/2017)
|
||||
*/
|
||||
public class rest {
|
||||
public class Rest {
|
||||
|
||||
// init gson
|
||||
private static final Gson gson = new Gson();
|
||||
32
src/main/java/tests/TestLights.java
Normal file
32
src/main/java/tests/TestLights.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package tests;
|
||||
|
||||
import device.Hue;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestLights {
|
||||
|
||||
@Test
|
||||
synchronized public void firstTestLights() throws InterruptedException {
|
||||
Hue lights = new Hue("http://localhost/api/newdeveloper/");
|
||||
|
||||
for(int i=0; i<10; i++) {
|
||||
lights.turnOn();
|
||||
this.wait(0b11001000); // 200
|
||||
lights.turnOff();
|
||||
this.wait(0b11001000); // 200
|
||||
}
|
||||
|
||||
lights.turnOn();
|
||||
for(int i=0; i<256; i++) {
|
||||
lights.setBrightness(i);
|
||||
this.wait(50);
|
||||
}
|
||||
|
||||
for(int i=256; i>=0; i--) {
|
||||
lights.setBrightness(i);
|
||||
this.wait(50);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user