This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new 285fd77 CLOUDSTACK-9957 test fix (#2297)
285fd77 is described below
commit 285fd77674c20c2546b157ad0662f3fc4b640633
Author: dahn <[email protected]>
AuthorDate: Thu Oct 19 08:57:47 2017 +0200
CLOUDSTACK-9957 test fix (#2297)
* tyopos in test
* unittest to prove interface
* test logic flaw fixed
---
.../command/admin/annotation/AddAnnotationCmd.java | 8 ++++-
.../admin/annotation/AddAnnotationCmdTest.java | 40 ++++++++++++++++++++++
test/integration/smoke/test_host_annotations.py | 8 ++---
3 files changed, 51 insertions(+), 5 deletions(-)
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 ac8fbc4..07a73ce 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 class AddAnnotationCmd extends BaseCmd {
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 class AddAnnotationCmd extends BaseCmd {
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 0000000..0665686
--- /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 45a918f..91c3409 100644
--- a/test/integration/smoke/test_host_annotations.py
+++ b/test/integration/smoke/test_host_annotations.py
@@ -162,16 +162,16 @@ class TestHostAnnotations(cloudstackTestCase):
@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")
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].