2 * Copyright 2016 Samsung Electronics All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.oic.simulator.test;
19 import org.oic.simulator.AttributeValue;
20 import org.oic.simulator.DoubleProperty;
22 import junit.framework.TestCase;
24 public class DoublePropertyTest extends TestCase {
26 protected void setUp() throws Exception {
30 protected void tearDown() throws Exception {
34 public void testDoubleProperty_P01() {
35 DoubleProperty property = new DoubleProperty.Builder().build();
37 assertNotNull(property);
38 assertEquals(property.getDefaultValue(), 0.0);
41 public void testIsDouble_P01() {
42 DoubleProperty property = new DoubleProperty.Builder().build();
44 assertNotNull(property);
45 assertTrue(property.isDouble());
48 public void testGetDefaultValue_P02() {
49 DoubleProperty.Builder builder = new DoubleProperty.Builder();
50 builder.setDefaultValue(3.142);
52 DoubleProperty property = builder.build();
54 assertNotNull(property);
55 assertEquals(property.getDefaultValue(), 3.142);
58 public void testHasRange_P01() {
59 DoubleProperty.Builder builder = new DoubleProperty.Builder();
60 builder.setRange(1.0, 10.25);
62 DoubleProperty property = builder.build();
64 assertNotNull(property);
65 assertTrue(property.hasRange());
68 public void testGetRange_P03() {
69 DoubleProperty.Builder builder = new DoubleProperty.Builder();
70 builder.setRange(1.0, 10.25);
72 DoubleProperty property = builder.build();
74 assertNotNull(property);
75 assertEquals(property.min(), 1.0);
76 assertEquals(property.max(), 10.25);
79 public void testHasValues_P01() {
80 DoubleProperty.Builder builder = new DoubleProperty.Builder();
81 double[] values = { 1.5, 2, 3.2 };
82 builder.setValues(values);
84 DoubleProperty property = builder.build();
86 assertNotNull(property);
87 assertTrue(property.hasValues());
90 public void testGetValues_P04() {
91 DoubleProperty.Builder builder = new DoubleProperty.Builder();
92 double[] values = { 1.5, 2, 3.2 };
93 builder.setValues(values);
95 DoubleProperty property = builder.build();
97 assertNotNull(property);
98 assertNotNull(property.getValues());
99 assertEquals(property.getValues().length, 3);
102 public void testValidate_P04() {
103 DoubleProperty.Builder builder = new DoubleProperty.Builder();
104 builder.setRange(1.0, 10.25);
106 DoubleProperty property = builder.build();
108 assertNotNull(property);
109 assertTrue(property.validate(new AttributeValue(3.25)));
112 public void testValidate_P05() {
113 DoubleProperty.Builder builder = new DoubleProperty.Builder();
114 builder.setRange(1.0, 10.25);
116 DoubleProperty property = builder.build();
118 assertNotNull(property);
119 assertTrue(property.validate(3.25));
122 public void testValidate_P06() {
123 DoubleProperty.Builder builder = new DoubleProperty.Builder();
124 double[] values = { 1.5, 2, 3.2 };
125 builder.setValues(values);
127 DoubleProperty property = builder.build();
129 assertNotNull(property);
130 assertTrue(property.validate(new AttributeValue(3.2)));
133 public void testValidate_P07() {
134 DoubleProperty.Builder builder = new DoubleProperty.Builder();
135 double[] values = { 1.5, 2, 3.2 };
136 builder.setValues(values);
138 DoubleProperty property = builder.build();
140 assertNotNull(property);
141 assertTrue(property.validate(3.2));
144 public void testValidate_N01() {
145 DoubleProperty.Builder builder = new DoubleProperty.Builder();
146 builder.setRange(1.0, 10.25);
148 DoubleProperty property = builder.build();
150 assertNotNull(property);
151 assertFalse(property.validate(new AttributeValue(11.5)));
154 public void testValidate_N02() {
155 DoubleProperty.Builder builder = new DoubleProperty.Builder();
156 builder.setRange(1.0, 10.25);
158 DoubleProperty property = builder.build();
160 assertNotNull(property);
161 assertFalse(property.validate(11.5));
164 public void testValidate_N04() {
165 DoubleProperty.Builder builder = new DoubleProperty.Builder();
166 double[] values = { 1.5, 2, 3.2 };
167 builder.setValues(values);
169 DoubleProperty property = builder.build();
171 assertNotNull(property);
172 assertFalse(property.validate(new AttributeValue(11.25)));
175 public void testValidate_N05() {
176 DoubleProperty.Builder builder = new DoubleProperty.Builder();
177 double[] values = { 1.5, 2, 3.2 };
178 builder.setValues(values);
180 DoubleProperty property = builder.build();
182 assertNotNull(property);
183 assertFalse(property.validate(11.25));