PageRenderTime 29ms CodeModel.GetById 15ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1/*
 2 * Copyright (c) 2010 Tonic Solutions LLC.
 3 *
 4 * http://www.nimbits.com
 5 *
 6 *
 7 * 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
 8 *
 9 * http://www.gnu.org/licenses/gpl.html
10 *
11 * 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.
12 */
13
14import com.nimbits.client.NimbitsClient;
15import com.nimbits.client.NimbitsClientFactory;
16import com.nimbits.client.model.common.CommonFactoryLocator;
17import com.nimbits.client.model.email.EmailAddress;
18import com.nimbits.client.model.point.PointName;
19import com.nimbits.user.GoogleUser;
20import com.nimbits.user.UserFactory;
21import org.junit.Test;
22
23import java.io.IOException;
24
25/**
26 * Created by bsautner
27 * User: benjamin
28 * Date: 10/7/11
29 * Time: 4:02 PM
30 */
31public class JsonTest {
32
33    @Test
34    public void testM2M() throws IOException, InterruptedException {
35
36//        PointName pointName = CommonFactoryLocator.getInstance().createPointName("foo");
37//        Robot robot = new Robot();
38//        robot.setFeeling(Robot.Feeling.sad);
39//        Value value = ValueModelFactory.createValueModel(40.111, -75.146,1, "Angry", robot);
40//
41//
42//        Common.meOnProd().recordValue(pointName, value);
43//
44//
45//        sleep(1000);
46//
47//        Value v = Common.meOnProd().getCurrentRecordedValue(pointName);
48//        Robot returnedRobot = (Robot) v.getData(Robot.class);
49//
50//        System.out.println(returnedRobot.getFeeling());
51
52
53    }
54
55    @Test
56    public void sendData() throws Exception {
57//
58//        PointName pointName = CommonFactoryLocator.getInstance().createPointName("MyRobot");
59//        EmailAddress emailAddress = CommonFactoryLocator.getInstance().createEmailAddress("bsautner@gmail.com");
60//        GoogleUser me = UserFactory.createGoogleUser(emailAddress, "Port1234");
61//        NimbitsClient client = NimbitsClientFactory.getInstance(me, "http://nimbits1.appspot.com");
62//
63//        Robot robot = new Robot();
64//        robot.setEmotion(Robot.Emotion.happy);
65//
66//        Value value = ValueModelFactory.createValueModel(40.111, -75.146,1, "I'm a happy robot", robot);
67//        client.recordValue(pointName, value);
68    }
69
70    @Test
71    public void getData() throws Exception {
72
73        PointName pointName = CommonFactoryLocator.getInstance().createPointName("MyRobot");
74        EmailAddress emailAddress = CommonFactoryLocator.getInstance().createEmailAddress("bsautner@gmail.com");
75        GoogleUser me = UserFactory.createGoogleUser(emailAddress, "Port1234");
76        NimbitsClient client = NimbitsClientFactory.getInstance(me, "http://nimbits1.appspot.com");
77
78        Robot robot = (Robot) client.getCurrentDataObject(pointName, Robot.class);
79        System.out.print(robot.getEmotion());
80        if (robot.getEmotion() == Robot.Emotion.angry) {
81            //destroyAllHumans();
82        }
83
84    }
85
86}