DaanHoogland closed pull request #2297: CLOUDSTACK-9957 tyopos in test
URL: https://github.com/apache/cloudstack/pull/2297
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/api/src/org/apache/cloudstack/api/command/admin/annotation/AddAnnotationCmd.java
 
b/api/src/org/apache/cloudstack/api/command/admin/annotation/AddAnnotationCmd.java
index ac8fbc40199..07a73ce095f 100644
--- 
a/api/src/org/apache/cloudstack/api/command/admin/annotation/AddAnnotationCmd.java
+++ 
b/api/src/org/apache/cloudstack/api/command/admin/annotation/AddAnnotationCmd.java
@@ -49,10 +49,16 @@ public String getAnnotation() {
         return annotation;
     }
 
+    protected void setEntityType(String newType) {
+        entityType = newType;
+    }
     public AnnotationService.EntityType getEntityType() {
         return AnnotationService.EntityType.valueOf(entityType);
     }
 
+    protected void setEntityUuid(String newUuid) {
+        entityUuid = newUuid;
+    }
     public String getEntityUuid() {
         return entityUuid;
     }
@@ -61,7 +67,7 @@ public String getEntityUuid() {
     public void execute()
             throws ResourceUnavailableException, 
InsufficientCapacityException, ServerApiException, 
ConcurrentOperationException, ResourceAllocationException,
             NetworkRuleConflictException {
-        Preconditions.checkNotNull(entityUuid,"I have to have an entity to set 
an annotation on!");
+        Preconditions.checkNotNull(getEntityUuid(),"I have to have an entity 
to set an annotation on!");
         
Preconditions.checkState(AnnotationService.EntityType.contains(entityType),(java.lang.String)"'%s'
 is ot a valid EntityType to put annotations on", entityType);
         AnnotationResponse annotationResponse = 
annotationService.addAnnotation(this);
         annotationResponse.setResponseName(getCommandName());
diff --git 
a/api/test/org/apache/cloudstack/api/command/admin/annotation/AddAnnotationCmdTest.java
 
b/api/test/org/apache/cloudstack/api/command/admin/annotation/AddAnnotationCmdTest.java
new file mode 100644
index 00000000000..06656868994
--- /dev/null
+++ 
b/api/test/org/apache/cloudstack/api/command/admin/annotation/AddAnnotationCmdTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.cloudstack.api.command.admin.annotation;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+
+public class AddAnnotationCmdTest {
+
+    private AddAnnotationCmd addAnnotationCmd = new AddAnnotationCmd();
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+    }
+
+    @Test (expected = IllegalStateException.class)
+    public void wrongEntityType() throws Exception {
+        addAnnotationCmd.setEntityType("BLA");
+        addAnnotationCmd.setEntityUuid("1");
+        addAnnotationCmd.execute();
+    }
+}
diff --git a/test/integration/smoke/test_host_annotations.py 
b/test/integration/smoke/test_host_annotations.py
index 45a918f4d9d..91c3409d27d 100644
--- a/test/integration/smoke/test_host_annotations.py
+++ b/test/integration/smoke/test_host_annotations.py
@@ -162,16 +162,16 @@ def test_04_remove_annotations(self):
 
 
     @attr(tags=["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], 
required_hardware="false")
-    def test_05_add_annotation_for_invvalid_entityType(self):
+    def test_05_add_annotation_for_invalid_entityType(self):
         cmd = addAnnotation.addAnnotationCmd()
         cmd.entityid = self.host.id
         cmd.entitytype = "BLA"
-        cmd.annotation = annotation
+        cmd.annotation = "annotation"
 
         try:
             self.apiclient.addAnnotation(cmd)
-        except CloudstackAPIException as f:
-            log.debug("error message %s" % f)
+        except Exception as f:
+            pass
         else:
             self.fail("AddAnnotation is allowed for on an unknown entityType")
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to