test_class.declarator: _resourceTagJoinDao
test_class.modifier: @Mock (name = "_resourceTagJoinDao")
      private
test_class.original_string: @Mock (name = "_resourceTagJoinDao")
      private ResourceTagJoinDao _resourceTagJoinDao;
test_class.type: ResourceTagJoinDao
test_class.var_name: _resourceTagJoinDao
test_class.declarator: _securityGroupVMMapDao
test_class.modifier: @Mock (name = "_securityGroupVMMapDao")
      private
test_class.original_string: @Mock (name = "_securityGroupVMMapDao")
      private SecurityGroupVMMapDao _securityGroupVMMapDao;
test_class.type: SecurityGroupVMMapDao
test_class.var_name: _securityGroupVMMapDao
test_class.declarator: _userVmDao
test_class.modifier: @Mock (name = "_userVmDao")
      private
test_class.original_string: @Mock (name = "_userVmDao")
      private UserVmDao _userVmDao;
test_class.type: UserVmDao
test_class.var_name: _userVmDao
test_class.declarator: _securityGroupJoinDaoImpl
test_class.modifier: @InjectMocks
      private
test_class.original_string: @InjectMocks
      private SecurityGroupJoinDaoImpl _securityGroupJoinDaoImpl;
test_class.type: SecurityGroupJoinDaoImpl
test_class.var_name: _securityGroupJoinDaoImpl
test_class.declarator: caller
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private Account caller;
test_class.type: Account
test_class.var_name: caller
test_class.declarator: vsg
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private SecurityGroupJoinVO vsg;
test_class.type: SecurityGroupJoinVO
test_class.var_name: vsg
test_class.declarator: securityGroupVMMapVOone
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private SecurityGroupVMMapVO securityGroupVMMapVOone;
test_class.type: SecurityGroupVMMapVO
test_class.var_name: securityGroupVMMapVOone
test_class.declarator: securityGroupVMMapVOtwo
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private SecurityGroupVMMapVO securityGroupVMMapVOtwo;
test_class.type: SecurityGroupVMMapVO
test_class.var_name: securityGroupVMMapVOtwo
test_class.declarator: userVmVOone
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private UserVmVO userVmVOone;
test_class.type: UserVmVO
test_class.var_name: userVmVOone
test_class.declarator: userVmVOtwo
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private UserVmVO userVmVOtwo;
test_class.type: UserVmVO
test_class.var_name: userVmVOtwo
test_class.declarator: uuidOne = "463e022a-249d-4212-bdf4-726bc9047aa7"
test_class.modifier: private final
test_class.original_string: private final String uuidOne = "463e022a-249d-4212-bdf4-726bc9047aa7";
test_class.type: String
test_class.var_name: uuidOne
test_class.declarator: uuidTwo = "d8714c5f-766f-4b14-bdf4-17571042b9c5"
test_class.modifier: private final
test_class.original_string: private final String uuidTwo = "d8714c5f-766f-4b14-bdf4-17571042b9c5";
test_class.type: String
test_class.var_name: uuidTwo
test_class.file: server/src/test/java/com/cloud/api/query/dao/SecurityGroupJoinDaoImplTest.java
test_class.identifier: SecurityGroupJoinDaoImplTest
test_class.superclass: extends TestCase
test_case.body: @Test
      public void virtualMachineIDsTwoTest() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
  
          when(vsg.getId()).thenReturn(3L);
  
          SecurityGroupResponse securityGroupResponse = _securityGroupJoinDaoImpl.newSecurityGroupResponse(vsg, caller);
  
          Field fieldVirtualMachineIds = securityGroupResponse.getClass().getDeclaredField("virtualMachineIds");
          fieldVirtualMachineIds.setAccessible(true);
  
          Set<String> virtualMachineIds = (Set<String>)fieldVirtualMachineIds.get(securityGroupResponse);
  
          assertEquals(2, virtualMachineIds.size());
          assertTrue(virtualMachineIds.contains(uuidOne));
          assertTrue(virtualMachineIds.contains(uuidTwo));
      }
test_case.class_method_signature: SecurityGroupJoinDaoImplTest.virtualMachineIDsTwoTest()
test_case.full_signature: @Test public void virtualMachineIDsTwoTest()
test_case.identifier: virtualMachineIDsTwoTest
test_case.invocations: thenReturn when getId newSecurityGroupResponse getDeclaredField getClass setAccessible get assertEquals size assertTrue contains assertTrue contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void virtualMachineIDsTwoTest()
focal_class.declarator: s_logger = LoggerFactory.getLogger(SecurityGroupJoinDaoImpl.class)
focal_class.modifier: public static final
focal_class.original_string: public static final Logger s_logger = LoggerFactory.getLogger(SecurityGroupJoinDaoImpl.class);
focal_class.type: Logger
focal_class.var_name: s_logger
focal_class.declarator: _configDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private ConfigurationDao _configDao;
focal_class.type: ConfigurationDao
focal_class.var_name: _configDao
focal_class.declarator: _resourceTagJoinDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private ResourceTagJoinDao _resourceTagJoinDao;
focal_class.type: ResourceTagJoinDao
focal_class.var_name: _resourceTagJoinDao
focal_class.declarator: _securityGroupVMMapDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private SecurityGroupVMMapDao _securityGroupVMMapDao;
focal_class.type: SecurityGroupVMMapDao
focal_class.var_name: _securityGroupVMMapDao
focal_class.declarator: _userVmDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private UserVmDao _userVmDao;
focal_class.type: UserVmDao
focal_class.var_name: _userVmDao
focal_class.declarator: sgSearch
focal_class.modifier: private final
focal_class.original_string: private final SearchBuilder<SecurityGroupJoinVO> sgSearch;
focal_class.type: SearchBuilder<SecurityGroupJoinVO>
focal_class.var_name: sgSearch
focal_class.declarator: sgIdSearch
focal_class.modifier: private final
focal_class.original_string: private final SearchBuilder<SecurityGroupJoinVO> sgIdSearch;
focal_class.type: SearchBuilder<SecurityGroupJoinVO>
focal_class.var_name: sgIdSearch
focal_class.file: server/src/main/java/com/cloud/api/query/dao/SecurityGroupJoinDaoImpl.java
focal_class.identifier: SecurityGroupJoinDaoImpl
focal_class.interfaces: implements SecurityGroupJoinDao
focal_class.class_method_signature: SecurityGroupJoinDaoImpl.SecurityGroupJoinDaoImpl()
focal_class.full_signature: protected  SecurityGroupJoinDaoImpl()
focal_class.identifier: SecurityGroupJoinDaoImpl
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.signature:  SecurityGroupJoinDaoImpl()
focal_class.class_method_signature: SecurityGroupJoinDaoImpl.newSecurityGroupResponse(SecurityGroupJoinVO vsg, Account caller)
focal_class.full_signature: @Override public SecurityGroupResponse newSecurityGroupResponse(SecurityGroupJoinVO vsg, Account caller)
focal_class.identifier: newSecurityGroupResponse
focal_class.modifiers: @Override public
focal_class.parameters: (SecurityGroupJoinVO vsg, Account caller)
focal_class.return: SecurityGroupResponse
focal_class.signature: SecurityGroupResponse newSecurityGroupResponse(SecurityGroupJoinVO vsg, Account caller)
focal_class.class_method_signature: SecurityGroupJoinDaoImpl.setSecurityGroupResponse(SecurityGroupResponse vsgData, SecurityGroupJoinVO vsg)
focal_class.full_signature: @Override public SecurityGroupResponse setSecurityGroupResponse(SecurityGroupResponse vsgData, SecurityGroupJoinVO vsg)
focal_class.identifier: setSecurityGroupResponse
focal_class.modifiers: @Override public
focal_class.parameters: (SecurityGroupResponse vsgData, SecurityGroupJoinVO vsg)
focal_class.return: SecurityGroupResponse
focal_class.signature: SecurityGroupResponse setSecurityGroupResponse(SecurityGroupResponse vsgData, SecurityGroupJoinVO vsg)
focal_class.class_method_signature: SecurityGroupJoinDaoImpl.newSecurityGroupView(SecurityGroup sg)
focal_class.full_signature: @Override public List<SecurityGroupJoinVO> newSecurityGroupView(SecurityGroup sg)
focal_class.identifier: newSecurityGroupView
focal_class.modifiers: @Override public
focal_class.parameters: (SecurityGroup sg)
focal_class.return: List<SecurityGroupJoinVO>
focal_class.signature: List<SecurityGroupJoinVO> newSecurityGroupView(SecurityGroup sg)
focal_class.class_method_signature: SecurityGroupJoinDaoImpl.searchByIds(Long... sgIds)
focal_class.full_signature: @Override public List<SecurityGroupJoinVO> searchByIds(Long... sgIds)
focal_class.identifier: searchByIds
focal_class.modifiers: @Override public
focal_class.parameters: (Long... sgIds)
focal_class.return: List<SecurityGroupJoinVO>
focal_class.signature: List<SecurityGroupJoinVO> searchByIds(Long... sgIds)
focal_class.superclass: extends GenericDaoBase<SecurityGroupJoinVO, Long>
focal_method.body: @Override
      public SecurityGroupResponse newSecurityGroupResponse(SecurityGroupJoinVO vsg, Account caller) {
          SecurityGroupResponse sgResponse = new SecurityGroupResponse();
          sgResponse.setId(vsg.getUuid());
          sgResponse.setName(vsg.getName());
          sgResponse.setDescription(vsg.getDescription());
  
          ApiResponseHelper.populateOwner(sgResponse, vsg);
  
          Long rule_id = vsg.getRuleId();
          if (rule_id != null && rule_id.longValue() > 0) {
              SecurityGroupRuleResponse ruleData = new SecurityGroupRuleResponse();
              ruleData.setRuleId(vsg.getRuleUuid());
              ruleData.setProtocol(vsg.getRuleProtocol());
  
              if ("icmp".equalsIgnoreCase(vsg.getRuleProtocol())) {
                  ruleData.setIcmpType(vsg.getRuleStartPort());
                  ruleData.setIcmpCode(vsg.getRuleEndPort());
              } else {
                  ruleData.setStartPort(vsg.getRuleStartPort());
                  ruleData.setEndPort(vsg.getRuleEndPort());
              }
  
              if (vsg.getRuleAllowedNetworkId() != null) {
                  List<SecurityGroupJoinVO> sgs = this.searchByIds(vsg.getRuleAllowedNetworkId());
                  if (sgs != null && sgs.size() > 0) {
                      SecurityGroupJoinVO sg = sgs.get(0);
                      ruleData.setSecurityGroupName(sg.getName());
                      ruleData.setAccountName(sg.getAccountName());
                  }
              } else {
                  ruleData.setCidr(vsg.getRuleAllowedSourceIpCidr());
              }
  
              // list the tags by rule uuid
              List<ResourceTagJoinVO> tags = _resourceTagJoinDao.listBy(vsg.getRuleUuid(), ResourceTag.ResourceObjectType.SecurityGroupRule);
              Set<ResourceTagResponse> tagResponse = new HashSet<ResourceTagResponse>();
              for (ResourceTagJoinVO tag: tags) {
                  tagResponse.add(ApiDBUtils.newResourceTagResponse(tag, false));
              }
  
              // add the tags to the rule data
              ruleData.setTags(tagResponse);
  
              if (vsg.getRuleType() == SecurityRuleType.IngressRule) {
                  ruleData.setObjectName("ingressrule");
                  sgResponse.addSecurityGroupIngressRule(ruleData);
              } else {
                  ruleData.setObjectName("egressrule");
                  sgResponse.addSecurityGroupEgressRule(ruleData);
              }
          }
  
          List<SecurityGroupVMMapVO> securityGroupVmMap = _securityGroupVMMapDao.listBySecurityGroup(vsg.getId());
          s_logger.debug("newSecurityGroupResponse() -> virtualmachine count: " + securityGroupVmMap.size());
          sgResponse.setVirtualMachineCount(securityGroupVmMap.size());
  
          for(SecurityGroupVMMapVO securityGroupVMMapVO : securityGroupVmMap) {
              final UserVmVO userVmVO = _userVmDao.findById(securityGroupVMMapVO.getInstanceId());
              if (userVmVO != null) {
                  sgResponse.addVirtualMachineId(userVmVO.getUuid());
              }
          }
  
          // update tag information
          Long tag_id = vsg.getTagId();
          if (tag_id != null && tag_id.longValue() > 0) {
              ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
              if (vtag != null) {
                  sgResponse.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
              }
          }
  
          // set async job
          if (vsg.getJobId() != null) {
              sgResponse.setJobId(vsg.getJobUuid());
              sgResponse.setJobStatus(vsg.getJobStatus());
          }
  
          sgResponse.setObjectName("securitygroup");
  
          return sgResponse;
      }
focal_method.class_method_signature: SecurityGroupJoinDaoImpl.newSecurityGroupResponse(SecurityGroupJoinVO vsg, Account caller)
focal_method.full_signature: @Override public SecurityGroupResponse newSecurityGroupResponse(SecurityGroupJoinVO vsg, Account caller)
focal_method.identifier: newSecurityGroupResponse
focal_method.invocations: setId getUuid setName getName setDescription getDescription populateOwner getRuleId longValue setRuleId getRuleUuid setProtocol getRuleProtocol equalsIgnoreCase getRuleProtocol setIcmpType getRuleStartPort setIcmpCode getRuleEndPort setStartPort getRuleStartPort setEndPort getRuleEndPort getRuleAllowedNetworkId searchByIds getRuleAllowedNetworkId size get setSecurityGroupName getName setAccountName getAccountName setCidr getRuleAllowedSourceIpCidr listBy getRuleUuid add newResourceTagResponse setTags getRuleType setObjectName addSecurityGroupIngressRule setObjectName addSecurityGroupEgressRule listBySecurityGroup getId debug size setVirtualMachineCount size findById getInstanceId addVirtualMachineId getUuid getTagId longValue findResourceTagViewById addTag newResourceTagResponse getJobId setJobId getJobUuid setJobStatus getJobStatus setObjectName
focal_method.modifiers: @Override public
focal_method.parameters: (SecurityGroupJoinVO vsg, Account caller)
focal_method.return: SecurityGroupResponse
focal_method.signature: SecurityGroupResponse newSecurityGroupResponse(SecurityGroupJoinVO vsg, Account caller)