[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-9351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15248014#comment-15248014
 ] 

ASF GitHub Bot commented on CLOUDSTACK-9351:
--------------------------------------------

Github user rafaelweingartner commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1497#discussion_r60256696
  
    --- Diff: 
server/test/com/cloud/api/query/MutualExclusiveIdsManagerBaseTest.java ---
    @@ -0,0 +1,84 @@
    +//
    +// 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 com.cloud.api.query;
    +
    +import static org.junit.Assert.assertEquals;
    +import static org.mockito.Mockito.never;
    +import static org.mockito.Mockito.times;
    +
    +import java.util.Arrays;
    +import java.util.List;
    +
    +import org.junit.Before;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.mockito.Mock;
    +import org.mockito.Mockito;
    +import org.mockito.runners.MockitoJUnitRunner;
    +
    +import com.cloud.utils.db.SearchCriteria;
    +
    +@RunWith(MockitoJUnitRunner.class)
    +public class MutualExclusiveIdsManagerBaseTest {
    +
    +    @Mock
    +    SearchCriteria<String> sc;
    +
    +    private static Long id1 = Long.valueOf(1l);
    +    private static Long id2 = Long.valueOf(2l);
    +
    +    private List<Long> idsList;
    +    private List<Long> idsEmptyList;
    +    private List<Long> expectedListId;
    +    private List<Long> expectedListIds;
    +
    +    private MutualExclusiveIdsManagerBase mgr = new 
MutualExclusiveIdsManagerBase();
    +
    +    @Before
    +    public void setup() {
    +        idsList = Arrays.asList(id1, id2);
    +        idsEmptyList = Arrays.asList();
    +        expectedListId = Arrays.asList(id1);
    +        expectedListIds = Arrays.asList(id1, id2);
    +    }
    +
    +    @Test
    +    public void testSetIdsListToSearchCriteria(){
    +        mgr.setIdsListToSearchCriteria(sc, idsList);
    +        Mockito.verify(sc, times(1)).setParameters(Mockito.same("idIN"), 
Mockito.same(id1), Mockito.same(id2));
    +    }
    +
    +    @Test
    +    public void testSetIdsListToSearchCriteriaEmptyList(){
    +        mgr.setIdsListToSearchCriteria(sc, idsEmptyList);
    +        Mockito.verify(sc, never()).setParameters(Mockito.anyString(), 
Mockito.any());
    +    }
    +
    +    @Test
    +    public void testGetIdsListId(){
    +        List<Long> result = mgr.getIdsListFromCmd(id1, idsEmptyList);
    +        assertEquals(result, expectedListId);
    --- End diff --
    
    This is more a question of philosophy, but the assertEquals should be: 
assertEquals(expected, actual). You are doing the opposite. It does not mean 
that the way it is coded now is wrong, it is just not the normal way (at least 
that I am used).


> Add ids parameter to resource listing API calls
> -----------------------------------------------
>
>                 Key: CLOUDSTACK-9351
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9351
>             Project: CloudStack
>          Issue Type: Improvement
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>          Components: API
>    Affects Versions: 4.9.0
>            Reporter: Nicolas Vazquez
>             Fix For: 4.9.0
>
>
> h2. General behaviour
> A new parameter is added in each method, its type a list of IDs of the 
> entity, it will be mutually exclusive with id. (Similar to {{id}} and {{ids}} 
> parameters in {{listVirtualMachines}} method)
> h3. API Methods affected
> * +{{listTemplates}}+: new parameter *{{ids}}*, mutually exclusive with {{id}}
> * +{{listVolumes}}+: new parameter *{{ids}}*, mutually exclusive with {{id}}
> * +{{listSnapshots}}+: new parameter *{{ids}}*, mutually exclusive with {{id}}
> * +{{listVMSnapshots}}+: new parameter *{{vmsnapshotids}}*, mutually 
> exclusive with {{vmsnapshotid}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to