PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/v3.2/nimbits-tds/test/TestPointServiceImpl.java

http://nimbits-server.googlecode.com/
Java | 53 lines | 27 code | 8 blank | 18 comment | 0 complexity | f8d5df46b89eba34ca04a97aeaf9c2e6 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.model.point.Point;
15import com.nimbits.client.model.user.User;
16import com.nimbits.server.point.PointServiceFactory;
17import com.nimbits.server.user.UserModelFactory;
18import org.junit.Assert;
19import org.junit.Test;
20
21import static com.nimbits.client.model.point.PointModelFactory.createPointModel;
22
23/**
24 * Created by bsautner
25 * User: benjamin
26 * Date: 7/2/11
27 * Time: 11:53 AM
28 */
29public class TestPointServiceImpl {
30
31    @Test
32    public void testPointProtectionOwnerRequestsConnectionsPublicPoint() {
33        User loggedInUser = UserModelFactory.createUserModel(1001L);
34        Point p = createPointModel(1L, 1002L);
35        User pointOwner = UserModelFactory.createUserModel(1002);
36        Assert.assertNotNull(p);
37        p.setPublic(true);
38        Assert.assertTrue("Accessing Stranger's Public Point", PointServiceFactory.getInstance().checkPointProtection(loggedInUser, pointOwner, p));
39
40    }
41
42    @Test
43    public void testPointProtectionOwnerRequestsConnectionsPrivatePoint() {
44        User loggedInUser = UserModelFactory.createUserModel(1001L);
45        Point p = createPointModel(1L, 1002L);
46        User pointOwner = UserModelFactory.createUserModel(1002);
47        Assert.assertNotNull(p);
48        p.setPublic(false);
49        Assert.assertFalse("Accessing Stranger's Public Point", PointServiceFactory.getInstance().checkPointProtection(loggedInUser, pointOwner, p));
50
51    }
52
53}