Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLOUDSTACK-9957 tyopos in test #2297

Merged
merged 5 commits into from
Oct 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
8 changes: 4 additions & 4 deletions test/integration/smoke/test_host_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down