cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pedro-martins <...@git.apache.org>
Subject [GitHub] cloudstack pull request: CLOUDSTACK-9298: Improve performance of r...
Date Wed, 02 Mar 2016 21:48:28 GMT
Github user pedro-martins commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1425#discussion_r54797480
  
    --- Diff: server/test/com/cloud/api/query/dao/TemplateJoinDaoImplTest.java ---
    @@ -0,0 +1,56 @@
    +package com.cloud.api.query.dao;
    +
    +import junit.framework.TestCase;
    +
    +import org.apache.cloudstack.api.response.ResourceTagResponse;
    +import org.apache.cloudstack.api.response.TemplateResponse;
    +import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
    +import org.junit.Before;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.mockito.InjectMocks;
    +import org.mockito.Mock;
    +import org.mockito.MockitoAnnotations;
    +import org.powermock.api.mockito.PowerMockito;
    +import org.powermock.core.classloader.annotations.PrepareForTest;
    +import org.powermock.modules.junit4.PowerMockRunner;
    +
    +import com.cloud.api.ApiDBUtils;
    +import com.cloud.api.query.vo.TemplateJoinVO;
    +import com.cloud.user.AccountService;
    +
    +@RunWith(PowerMockRunner.class)
    +@PrepareForTest(ApiDBUtils.class)
    +public class TemplateJoinDaoImplTest extends TestCase {
    +
    +    @Mock(name="_configDao")
    +    private ConfigurationDao _configDao;
    +
    +    @Mock(name="_accountService")
    +    private AccountService _accountService;
    +
    +    @InjectMocks
    +    private TemplateJoinDaoImpl _templateJoinDaoImpl;
    +
    +    private TemplateJoinVO template = new TemplateJoinVO();
    +    private TemplateResponse templateResponse = new TemplateResponse();
    +
    +    private final static long TAG_ID = 1l;
    +    private final static String TAG_UUID = "aaaa-aaaa-aaaa-aaaa";
    +
    +    @Before
    +    public void setup() {
    +        MockitoAnnotations.initMocks(this);
    +        template.setTagId(TAG_ID);
    +        template.setTagUuid(TAG_UUID);
    +        PowerMockito.spy(ApiDBUtils.class);
    +        PowerMockito.stub(PowerMockito.method(ApiDBUtils.class, "newResourceTagResponse")).toReturn(new
ResourceTagResponse());
    +    }
    +
    +    @Test
    +    public void testUpdateTemplateTagInfo(){
    +        assertEquals(0, templateResponse.getTags().size());
    +        _templateJoinDaoImpl.updateTemplateTagInformation(template, templateResponse);
    +        assertEquals(1, templateResponse.getTags().size());
    +    }
    --- End diff --
    
    Hi, @nvazquez.
    
    I see a little mistake in you test, you are testing if the method has inserted a tag or
not, I think that this test needs to verify if the template inserted in the templateResponse
is the same that you has passed in the first param of the method.
    You can do it checking if each variable in both templates are equals.
    
    The same problem in the other tests cases.
    
    Ty.


---
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.
---

Mime
View raw message