@Test
public void createAffinityGroupFromCmdTest() {

    when(_acctMgr.finalizeOwner((Account)anyObject(), anyString(), anyLong(), anyLong())).thenReturn(acct);
    when(_groupDao.isNameInUse(anyLong(), anyLong(), eq(AFFINITY_GROUP_NAME))).thenReturn(false);
    CreateAffinityGroupCmd mockCreateAffinityGroupCmd = Mockito.mock(CreateAffinityGroupCmd.class);
    when(mockCreateAffinityGroupCmd.getProjectId()).thenReturn(PROJECT_ID);
    when(mockCreateAffinityGroupCmd.getAffinityGroupName()).thenReturn(AFFINITY_GROUP_NAME);
    when(mockCreateAffinityGroupCmd.getAffinityGroupType()).thenReturn("mock");
    when(mockCreateAffinityGroupCmd.getDescription()).thenReturn("affinity group one");
    AffinityGroup group = _affinityService.createAffinityGroup(mockCreateAffinityGroupCmd);
    assertNotNull("Affinity group 'group1' of type 'mock' failed to create ", group);
}