Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 52813200B71 for ; Wed, 31 Aug 2016 23:09:51 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4D194160AB4; Wed, 31 Aug 2016 21:09:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 92A82160AA7 for ; Wed, 31 Aug 2016 23:09:50 +0200 (CEST) Received: (qmail 35651 invoked by uid 500); 31 Aug 2016 21:09:49 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 35636 invoked by uid 99); 31 Aug 2016 21:09:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Aug 2016 21:09:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 37ECBE0159; Wed, 31 Aug 2016 21:09:49 +0000 (UTC) From: jburwell To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request #1600: Support Backup of Snapshots for Managed Stora... Content-Type: text/plain Message-Id: <20160831210949.37ECBE0159@git1-us-west.apache.org> Date: Wed, 31 Aug 2016 21:09:49 +0000 (UTC) archived-at: Wed, 31 Aug 2016 21:09:51 -0000 Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1600#discussion_r77074073 --- Diff: api/test/org/apache/cloudstack/api/command/test/CreateSnapshotCmdTest.java --- @@ -0,0 +1,130 @@ +// 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.test; + +import com.cloud.storage.Snapshot; +import com.cloud.storage.VolumeApiService; +import com.cloud.user.Account; +import com.cloud.user.AccountService; +import junit.framework.TestCase; +import org.apache.cloudstack.api.ResponseGenerator; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotCmd; +import org.apache.cloudstack.api.response.SnapshotResponse; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mockito; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.anyLong; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.isNull; + +public class CreateSnapshotCmdTest extends TestCase { + + private CreateSnapshotCmd createSnapshotCmd; + private ResponseGenerator responseGenerator; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Override + @Before + public void setUp() { + + createSnapshotCmd = new CreateSnapshotCmd() { + + @Override + public String getCommandName() { + return "createsnapshotresponse"; + } + + @Override + public Long getVolumeId(){ + return 1L; + } + + @Override + public long getEntityOwnerId(){ + return 1L; + } + }; + + } + + @Test + public void testCreateSuccess() { + + AccountService accountService = Mockito.mock(AccountService.class); + Account account = Mockito.mock(Account.class); + Mockito.when(accountService.getAccount(anyLong())).thenReturn(account); + + VolumeApiService volumeApiService = Mockito.mock(VolumeApiService.class); + Snapshot snapshot = Mockito.mock(Snapshot.class); + try { + + Mockito.when(volumeApiService.takeSnapshot(anyLong(), anyLong(), anyLong(), + any(Account.class), anyBoolean(), isNull(Snapshot.LocationType.class))).thenReturn(snapshot); + + } catch (Exception e) { + Assert.fail("Received exception when success expected " + e.getMessage()); + } + + responseGenerator = Mockito.mock(ResponseGenerator.class); + SnapshotResponse snapshotResponse = Mockito.mock(SnapshotResponse.class); + Mockito.when(responseGenerator.createSnapshotResponse(snapshot)).thenReturn(snapshotResponse); + Mockito.doNothing().when(snapshotResponse).setAccountName(anyString()); + + createSnapshotCmd._accountService = accountService; + createSnapshotCmd._responseGenerator = responseGenerator; + createSnapshotCmd._volumeService = volumeApiService; + + createSnapshotCmd.execute(); + } + + @Test + @Ignore --- End diff -- Why are we adding a new unit test that is being ignored? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---