You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by js...@apache.org on 2013/02/01 18:07:16 UTC
svn commit: r1441533 -
/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/
Author: jspeidel
Date: Fri Feb 1 17:07:15 2013
New Revision: 1441533
URL: http://svn.apache.org/viewvc?rev=1441533&view=rev
Log:
AMBARI-1294. Add 'isEmpty' and 'in' query operators to API. Added missing tests from previous commit.
Added:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/AndOperatorTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/EqualsOperatorTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/GreaterEqualsOperatorTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/GreaterOperatorTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/InOperatorTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/IsEmptyOperatorTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/LessEqualsOperatorTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/LessOperatorTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/NotEqualsOperatorTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/NotOperatorTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/OrOperatorTest.java
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/AndOperatorTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/AndOperatorTest.java?rev=1441533&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/AndOperatorTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/AndOperatorTest.java Fri Feb 1 17:07:15 2013
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+
+import org.apache.ambari.server.controller.predicate.AndPredicate;
+import org.apache.ambari.server.controller.predicate.EqualsPredicate;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * AND operator test.
+ */
+public class AndOperatorTest {
+
+ @Test
+ public void testGetName() {
+ assertEquals("AndOperator", new AndOperator(1).getName());
+ }
+
+ @Test
+ public void testToPredicate() {
+ EqualsPredicate p1 = new EqualsPredicate<String>("p1", "one");
+ EqualsPredicate p2 = new EqualsPredicate<String>("p2", "two");
+ AndPredicate andPredicate = new AndPredicate(p1, p2);
+
+ assertEquals(andPredicate, new AndOperator(1).toPredicate(p1, p2));
+ }
+
+ @Test
+ public void testGetType() {
+ assertSame(Operator.TYPE.AND, new AndOperator(1).getType());
+ }
+
+ @Test
+ public void testGetBasePrecedence() {
+ assertEquals(2, new AndOperator(1).getBasePrecedence());
+ }
+
+ @Test
+ public void testGetPrecedence() {
+ assertEquals(4, new AndOperator(2).getPrecedence());
+ }
+}
\ No newline at end of file
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/EqualsOperatorTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/EqualsOperatorTest.java?rev=1441533&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/EqualsOperatorTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/EqualsOperatorTest.java Fri Feb 1 17:07:15 2013
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+
+import org.apache.ambari.server.controller.predicate.EqualsPredicate;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * EQUALS operator test.
+ */
+public class EqualsOperatorTest {
+
+ @Test
+ public void testGetName() {
+ assertEquals("EqualsOperator", new EqualsOperator().getName());
+ }
+
+ @Test
+ public void testToPredicate() {
+ assertEquals(new EqualsPredicate<String>("prop", "val"),
+ new EqualsOperator().toPredicate("prop", "val"));
+ }
+
+ @Test
+ public void testGetType() {
+ assertSame(Operator.TYPE.EQUAL, new EqualsOperator().getType());
+ }
+
+ @Test
+ public void testGetBasePrecedence() {
+ assertEquals(-1, new EqualsOperator().getBasePrecedence());
+ }
+
+ @Test
+ public void testGetPrecedence() {
+ assertEquals(-1, new EqualsOperator().getPrecedence());
+ }
+}
\ No newline at end of file
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/GreaterEqualsOperatorTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/GreaterEqualsOperatorTest.java?rev=1441533&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/GreaterEqualsOperatorTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/GreaterEqualsOperatorTest.java Fri Feb 1 17:07:15 2013
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+
+import org.apache.ambari.server.controller.predicate.GreaterEqualsPredicate;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * GreaterEquals operator test.
+ */
+public class GreaterEqualsOperatorTest {
+
+ @Test
+ public void testGetName() {
+ assertEquals("GreaterEqualsOperator", new GreaterEqualsOperator().getName());
+ }
+
+ @Test
+ public void testToPredicate() {
+ assertEquals(new GreaterEqualsPredicate<String>("1", "2"),
+ new GreaterEqualsOperator().toPredicate("1", "2"));
+ }
+
+ @Test
+ public void testGetType() {
+ assertSame(Operator.TYPE.GREATER_EQUAL, new GreaterEqualsOperator().getType());
+ }
+
+ @Test
+ public void testGetBasePrecedence() {
+ assertEquals(-1, new GreaterEqualsOperator().getBasePrecedence());
+ }
+
+ @Test
+ public void testGetPrecedence() {
+ assertEquals(-1, new GreaterEqualsOperator().getPrecedence());
+ }
+}
\ No newline at end of file
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/GreaterOperatorTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/GreaterOperatorTest.java?rev=1441533&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/GreaterOperatorTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/GreaterOperatorTest.java Fri Feb 1 17:07:15 2013
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+
+import org.apache.ambari.server.controller.predicate.GreaterPredicate;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * GREATER operator test.
+ */
+public class GreaterOperatorTest {
+
+ @Test
+ public void testGetName() {
+ assertEquals("GreaterOperator", new GreaterOperator().getName());
+ }
+
+ @Test
+ public void testToPredicate() {
+ assertEquals(new GreaterPredicate<String>("1", "2"),
+ new GreaterOperator().toPredicate("1", "2"));
+ }
+
+ @Test
+ public void testGetType() {
+ assertSame(Operator.TYPE.GREATER, new GreaterOperator().getType());
+ }
+
+ @Test
+ public void testGetBasePrecedence() {
+ assertEquals(-1, new GreaterOperator().getBasePrecedence());
+ }
+
+ @Test
+ public void testGetPrecedence() {
+ assertEquals(-1, new GreaterOperator().getPrecedence());
+ }
+}
\ No newline at end of file
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/InOperatorTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/InOperatorTest.java?rev=1441533&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/InOperatorTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/InOperatorTest.java Fri Feb 1 17:07:15 2013
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+
+import org.apache.ambari.server.controller.predicate.EqualsPredicate;
+import org.apache.ambari.server.controller.predicate.OrPredicate;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * IN operator test.
+ */
+public class InOperatorTest {
+
+ @Test
+ public void testGetName() {
+ assertEquals("InOperator", new InOperator().getName());
+ }
+
+ @Test
+ public void testToPredicate() throws Exception {
+ String prop = "prop";
+ String val = "one,2,three";
+ EqualsPredicate p1 = new EqualsPredicate<String>(prop, "one");
+ EqualsPredicate p2 = new EqualsPredicate<String>(prop, "2");
+ EqualsPredicate p3 = new EqualsPredicate<String>(prop, "three");
+ OrPredicate orPredicate = new OrPredicate(p1, p2, p3);
+
+ assertEquals(orPredicate, new InOperator().toPredicate(prop, val));
+ }
+
+ @Test
+ public void testGetType() {
+ assertSame(Operator.TYPE.IN, new InOperator().getType());
+ }
+
+ @Test
+ public void testGetBasePrecedence() {
+ assertEquals(-1, new InOperator().getBasePrecedence());
+ }
+
+ @Test
+ public void testGetPrecedence() {
+ assertEquals(-1, new InOperator().getPrecedence());
+ }
+}
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/IsEmptyOperatorTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/IsEmptyOperatorTest.java?rev=1441533&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/IsEmptyOperatorTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/IsEmptyOperatorTest.java Fri Feb 1 17:07:15 2013
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+
+import org.apache.ambari.server.api.predicate.InvalidQueryException;
+import org.apache.ambari.server.controller.predicate.CategoryIsEmptyPredicate;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * IsEmpty operator test.
+ */
+public class IsEmptyOperatorTest {
+
+ @Test
+ public void testGetName() {
+ assertEquals("IsEmptyOperator", new IsEmptyOperator().getName());
+ }
+
+ @Test
+ public void testToPredicate() throws InvalidQueryException {
+ String prop = "prop";
+ Predicate p = new CategoryIsEmptyPredicate(prop);
+
+ assertEquals(p, new IsEmptyOperator().toPredicate(prop, null));
+ }
+
+ @Test
+ public void testGetType() {
+ assertSame(Operator.TYPE.IS_EMPTY, new IsEmptyOperator().getType());
+ }
+
+ @Test
+ public void testGetBasePrecedence() {
+ assertEquals(-1, new IsEmptyOperator().getBasePrecedence());
+ }
+
+ @Test
+ public void testGetPrecedence() {
+ assertEquals(-1, new IsEmptyOperator().getPrecedence());
+ }
+}
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/LessEqualsOperatorTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/LessEqualsOperatorTest.java?rev=1441533&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/LessEqualsOperatorTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/LessEqualsOperatorTest.java Fri Feb 1 17:07:15 2013
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+
+import org.apache.ambari.server.controller.predicate.LessEqualsPredicate;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * LessEquals operator test.
+ */
+public class LessEqualsOperatorTest {
+
+ @Test
+ public void testGetName() {
+ assertEquals("LessEqualsOperator", new LessEqualsOperator().getName());
+ }
+
+ @Test
+ public void testToPredicate() {
+ assertEquals(new LessEqualsPredicate<String>("1", "2"),
+ new LessEqualsOperator().toPredicate("1", "2"));
+ }
+
+ @Test
+ public void testGetType() {
+ assertSame(Operator.TYPE.LESS_EQUAL, new LessEqualsOperator().getType());
+ }
+
+ @Test
+ public void testGetBasePrecedence() {
+ assertEquals(-1, new LessEqualsOperator().getBasePrecedence());
+ }
+
+ @Test
+ public void testGetPrecedence() {
+ assertEquals(-1, new LessEqualsOperator().getPrecedence());
+ }
+}
\ No newline at end of file
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/LessOperatorTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/LessOperatorTest.java?rev=1441533&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/LessOperatorTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/LessOperatorTest.java Fri Feb 1 17:07:15 2013
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+
+import org.apache.ambari.server.controller.predicate.LessPredicate;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * LESS operator test.
+ */
+public class LessOperatorTest {
+
+ @Test
+ public void testGetName() {
+ assertEquals("LessOperator", new LessOperator().getName());
+ }
+
+ @Test
+ public void testToPredicate() {
+ assertEquals(new LessPredicate<String>("1", "2"),
+ new LessOperator().toPredicate("1", "2"));
+ }
+
+ @Test
+ public void testGetType() {
+ assertSame(Operator.TYPE.LESS, new LessOperator().getType());
+ }
+
+ @Test
+ public void testGetBasePrecedence() {
+ assertEquals(-1, new LessOperator().getBasePrecedence());
+ }
+
+ @Test
+ public void testGetPrecedence() {
+ assertEquals(-1, new LessOperator().getPrecedence());
+ }
+}
\ No newline at end of file
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/NotEqualsOperatorTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/NotEqualsOperatorTest.java?rev=1441533&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/NotEqualsOperatorTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/NotEqualsOperatorTest.java Fri Feb 1 17:07:15 2013
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+
+import org.apache.ambari.server.controller.predicate.EqualsPredicate;
+import org.apache.ambari.server.controller.predicate.NotPredicate;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * NOT EQUALS operator test.
+ */
+public class NotEqualsOperatorTest {
+
+ @Test
+ public void testGetName() {
+ assertEquals("NotEqualsOperator", new NotEqualsOperator().getName());
+ }
+
+ @Test
+ public void testToPredicate() {
+ assertEquals(new NotPredicate(new EqualsPredicate<String>("prop", "val")),
+ new NotEqualsOperator().toPredicate("prop", "val"));
+ }
+
+ @Test
+ public void testGetType() {
+ assertSame(Operator.TYPE.NOT_EQUAL, new NotEqualsOperator().getType());
+ }
+
+ @Test
+ public void testGetBasePrecedence() {
+ assertEquals(-1, new NotEqualsOperator().getBasePrecedence());
+ }
+
+ @Test
+ public void testGetPrecedence() {
+ assertEquals(-1, new NotEqualsOperator().getPrecedence());
+ }
+}
\ No newline at end of file
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/NotOperatorTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/NotOperatorTest.java?rev=1441533&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/NotOperatorTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/NotOperatorTest.java Fri Feb 1 17:07:15 2013
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+
+import org.apache.ambari.server.controller.predicate.EqualsPredicate;
+import org.apache.ambari.server.controller.predicate.NotPredicate;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * NOT operator test.
+ */
+public class NotOperatorTest {
+
+ @Test
+ public void testGetName() {
+ assertEquals("NotOperator", new NotOperator(1).getName());
+ }
+
+ @Test
+ public void testToPredicate() {
+ EqualsPredicate p = new EqualsPredicate<String>("prop", "val");
+ NotPredicate notPredicate = new NotPredicate(p);
+
+ assertEquals(notPredicate, new NotOperator(1).toPredicate(null, p));
+ }
+
+ @Test
+ public void testGetType() {
+ assertSame(Operator.TYPE.NOT, new NotOperator(1).getType());
+ }
+
+ @Test
+ public void testGetBasePrecedence() {
+ assertEquals(3, new NotOperator(1).getBasePrecedence());
+ }
+
+ @Test
+ public void testGetPrecedence() {
+ assertEquals(5, new NotOperator(2).getPrecedence());
+ }
+}
\ No newline at end of file
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/OrOperatorTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/OrOperatorTest.java?rev=1441533&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/OrOperatorTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/predicate/operators/OrOperatorTest.java Fri Feb 1 17:07:15 2013
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+
+import org.apache.ambari.server.controller.predicate.EqualsPredicate;
+import org.apache.ambari.server.controller.predicate.OrPredicate;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * OR operator test.
+ */
+public class OrOperatorTest {
+
+ @Test
+ public void testGetName() {
+ assertEquals("OrOperator", new OrOperator(1).getName());
+ }
+
+ @Test
+ public void testToPredicate() {
+ EqualsPredicate p1 = new EqualsPredicate<String>("p1", "one");
+ EqualsPredicate p2 = new EqualsPredicate<String>("p2", "two");
+ OrPredicate orPRedicate = new OrPredicate(p1, p2);
+
+ assertEquals(orPRedicate, new OrOperator(1).toPredicate(p1, p2));
+ }
+
+ @Test
+ public void testGetType() {
+ assertSame(Operator.TYPE.OR, new OrOperator(1).getType());
+ }
+
+ @Test
+ public void testGetBasePrecedence() {
+ assertEquals(1, new OrOperator(1).getBasePrecedence());
+ }
+
+ @Test
+ public void testGetPrecedence() {
+ assertEquals(3, new OrOperator(2).getPrecedence());
+ }
+}
\ No newline at end of file