/v3.2/nimbits-sdk/test/JsonTest.java
http://nimbits-server.googlecode.com/ · Java · 86 lines · 28 code · 13 blank · 45 comment · 2 complexity · c3d773dfffc493defd898bdd355257ca MD5 · raw file
- /*
- * Copyright (c) 2010 Tonic Solutions LLC.
- *
- * http://www.nimbits.com
- *
- *
- * Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.gnu.org/licenses/gpl.html
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- */
- import com.nimbits.client.NimbitsClient;
- import com.nimbits.client.NimbitsClientFactory;
- import com.nimbits.client.model.common.CommonFactoryLocator;
- import com.nimbits.client.model.email.EmailAddress;
- import com.nimbits.client.model.point.PointName;
- import com.nimbits.user.GoogleUser;
- import com.nimbits.user.UserFactory;
- import org.junit.Test;
- import java.io.IOException;
- /**
- * Created by bsautner
- * User: benjamin
- * Date: 10/7/11
- * Time: 4:02 PM
- */
- public class JsonTest {
- @Test
- public void testM2M() throws IOException, InterruptedException {
- // PointName pointName = CommonFactoryLocator.getInstance().createPointName("foo");
- // Robot robot = new Robot();
- // robot.setFeeling(Robot.Feeling.sad);
- // Value value = ValueModelFactory.createValueModel(40.111, -75.146,1, "Angry", robot);
- //
- //
- // Common.meOnProd().recordValue(pointName, value);
- //
- //
- // sleep(1000);
- //
- // Value v = Common.meOnProd().getCurrentRecordedValue(pointName);
- // Robot returnedRobot = (Robot) v.getData(Robot.class);
- //
- // System.out.println(returnedRobot.getFeeling());
- }
- @Test
- public void sendData() throws Exception {
- //
- // PointName pointName = CommonFactoryLocator.getInstance().createPointName("MyRobot");
- // EmailAddress emailAddress = CommonFactoryLocator.getInstance().createEmailAddress("bsautner@gmail.com");
- // GoogleUser me = UserFactory.createGoogleUser(emailAddress, "Port1234");
- // NimbitsClient client = NimbitsClientFactory.getInstance(me, "http://nimbits1.appspot.com");
- //
- // Robot robot = new Robot();
- // robot.setEmotion(Robot.Emotion.happy);
- //
- // Value value = ValueModelFactory.createValueModel(40.111, -75.146,1, "I'm a happy robot", robot);
- // client.recordValue(pointName, value);
- }
- @Test
- public void getData() throws Exception {
- PointName pointName = CommonFactoryLocator.getInstance().createPointName("MyRobot");
- EmailAddress emailAddress = CommonFactoryLocator.getInstance().createEmailAddress("bsautner@gmail.com");
- GoogleUser me = UserFactory.createGoogleUser(emailAddress, "Port1234");
- NimbitsClient client = NimbitsClientFactory.getInstance(me, "http://nimbits1.appspot.com");
- Robot robot = (Robot) client.getCurrentDataObject(pointName, Robot.class);
- System.out.print(robot.getEmotion());
- if (robot.getEmotion() == Robot.Emotion.angry) {
- //destroyAllHumans();
- }
- }
- }