test_class.declarator: AZURE_CLOUD_ID = 20
test_class.modifier: private static final
test_class.original_string: private static final long AZURE_CLOUD_ID = 20;
test_class.type: long
test_class.var_name: AZURE_CLOUD_ID
test_class.declarator: OPENSTACK_CLOUD_ID = 21
test_class.modifier: private static final
test_class.original_string: private static final long OPENSTACK_CLOUD_ID = 21;
test_class.type: long
test_class.var_name: OPENSTACK_CLOUD_ID
test_class.declarator: GOOGLE_CLOUD_ID = 22
test_class.modifier: private static final
test_class.original_string: private static final long GOOGLE_CLOUD_ID = 22;
test_class.type: long
test_class.var_name: GOOGLE_CLOUD_ID
test_class.declarator: AZURE_CLOUD_LOCATION = "azure-eastus"
test_class.modifier: private static final
test_class.original_string: private static final String AZURE_CLOUD_LOCATION = "azure-eastus";
test_class.type: String
test_class.var_name: AZURE_CLOUD_LOCATION
test_class.declarator: OPENSTACK_CLOUD_LOCATION = "openstack-dal"
test_class.modifier: private static final
test_class.original_string: private static final String OPENSTACK_CLOUD_LOCATION = "openstack-dal";
test_class.type: String
test_class.var_name: OPENSTACK_CLOUD_LOCATION
test_class.declarator: GOOGLE_CLOUD_LOCATION = "google-westcoast"
test_class.modifier: private static final
test_class.original_string: private static final String GOOGLE_CLOUD_LOCATION = "google-westcoast";
test_class.type: String
test_class.var_name: GOOGLE_CLOUD_LOCATION
test_class.declarator: AZURE_SUBSCRIPTION_ID = "azure-sub1"
test_class.modifier: private static final
test_class.original_string: private static final String AZURE_SUBSCRIPTION_ID = "azure-sub1";
test_class.type: String
test_class.var_name: AZURE_SUBSCRIPTION_ID
test_class.declarator: OPENSTACK_SUBSCRIPTION_ID = "openstack-tenant1"
test_class.modifier: private static final
test_class.original_string: private static final String OPENSTACK_SUBSCRIPTION_ID = "openstack-tenant1";
test_class.type: String
test_class.var_name: OPENSTACK_SUBSCRIPTION_ID
test_class.declarator: GOOGLE_SUBSCRIPTION_ID = "google-sub1"
test_class.modifier: private static final
test_class.original_string: private static final String GOOGLE_SUBSCRIPTION_ID = "google-sub1";
test_class.type: String
test_class.var_name: GOOGLE_SUBSCRIPTION_ID
test_class.declarator: ENV_NS_PATH = "/org1/a1/e1"
test_class.modifier: private static final
test_class.original_string: private static final String ENV_NS_PATH = "/org1/a1/e1";
test_class.type: String
test_class.var_name: ENV_NS_PATH
test_class.declarator: cmsVarCapacityManagement
test_class.modifier: private
test_class.original_string: private CmsVar cmsVarCapacityManagement;
test_class.type: CmsVar
test_class.var_name: cmsVarCapacityManagement
test_class.declarator: azureCloud
test_class.modifier: private
test_class.original_string: private CmsCI azureCloud;
test_class.type: CmsCI
test_class.var_name: azureCloud
test_class.declarator: openstackCloud
test_class.modifier: private
test_class.original_string: private CmsCI openstackCloud;
test_class.type: CmsCI
test_class.var_name: openstackCloud
test_class.declarator: googleCloud
test_class.modifier: private
test_class.original_string: private CmsCI googleCloud;
test_class.type: CmsCI
test_class.var_name: googleCloud
test_class.declarator: bomCIs
test_class.modifier: private
test_class.original_string: private ArrayList<CmsRfcCI> bomCIs;
test_class.type: ArrayList<CmsRfcCI>
test_class.var_name: bomCIs
test_class.declarator: bomRels
test_class.modifier: private
test_class.original_string: private ArrayList<CmsRfcRelation > bomRels;
test_class.type: ArrayList<CmsRfcRelation >
test_class.var_name: bomRels
test_class.declarator: capacityProcessor = new CapacityProcessor()
test_class.modifier: private
test_class.original_string: private CapacityProcessor capacityProcessor = new CapacityProcessor();
test_class.type: CapacityProcessor
test_class.var_name: capacityProcessor
test_class.declarator: cmProcessorMock
test_class.modifier: private
test_class.original_string: private CmsCmProcessor cmProcessorMock;
test_class.type: CmsCmProcessor
test_class.var_name: cmProcessorMock
test_class.declarator: tektonClientMock = Mockito.mock(TektonClient.class)
test_class.modifier: private
test_class.original_string: private TektonClient tektonClientMock = Mockito.mock(TektonClient.class);
test_class.type: TektonClient
test_class.var_name: tektonClientMock
test_class.file: cmsdal/src/test/java/com/oneops/capacity/CapacityProcessorTest.java
test_class.identifier: CapacityProcessorTest
test_case.body: @Test
      public void testRelease() throws IOException {
          long deploymentId = 1L;
          bomCIs.clear();
          bomRels.clear();
          createComputeRfc(1L, "add", "M", azureCloud);
  
          CmsWorkOrder workOrder = new CmsWorkOrder();
          workOrder.setRfcCi(bomCIs.get(0));
          workOrder.setCloud(azureCloud);
          workOrder.setDeploymentId(deploymentId);
  
          Map<String, Integer> expectedCapacity = new HashMap<>();
          expectedCapacity.put("Dv2", 2);
          expectedCapacity.put("vm", 1);
          expectedCapacity.put("nic", 1);
          ArgumentCaptor<HashMap> argument= ArgumentCaptor.forClass(HashMap.class);
  
          capacityProcessor.releaseCapacity(workOrder);
          Mockito.verify(tektonClientMock, Mockito.times(1))
                  .releaseResources(argument.capture(),
                                    Mockito.eq(ENV_NS_PATH),
                                    Mockito.eq(AZURE_CLOUD_LOCATION + ":" + AZURE_SUBSCRIPTION_ID));
          Assert.assertEquals(argument.getValue(), expectedCapacity);
      }
test_case.class_method_signature: CapacityProcessorTest.testRelease()
test_case.full_signature: @Test public void testRelease()
test_case.identifier: testRelease
test_case.invocations: clear clear createComputeRfc setRfcCi get setCloud setDeploymentId put put put forClass releaseCapacity releaseResources verify times capture eq eq assertEquals getValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRelease()
focal_class.declarator: logger = Logger.getLogger(CapacityProcessor.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger logger = Logger.getLogger(CapacityProcessor.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: CAPACITY_MANAGEMENT_VAR_NAME = "CAPACITY_MANAGEMENT"
focal_class.modifier: static final
focal_class.original_string: static final String CAPACITY_MANAGEMENT_VAR_NAME = "CAPACITY_MANAGEMENT";
focal_class.type: String
focal_class.var_name: CAPACITY_MANAGEMENT_VAR_NAME
focal_class.declarator: PROVIDER_MAPPINGS_CMS_VAR_NAME = "CLOUD_PROVIDER_MAPPINGS"
focal_class.modifier: static final
focal_class.original_string: static final String PROVIDER_MAPPINGS_CMS_VAR_NAME = "CLOUD_PROVIDER_MAPPINGS";
focal_class.type: String
focal_class.var_name: PROVIDER_MAPPINGS_CMS_VAR_NAME
focal_class.declarator: cmProcessor
focal_class.modifier: private
focal_class.original_string: private CmsCmProcessor cmProcessor;
focal_class.type: CmsCmProcessor
focal_class.var_name: cmProcessor
focal_class.declarator: rfcProcessor
focal_class.modifier: private
focal_class.original_string: private CmsRfcProcessor rfcProcessor;
focal_class.type: CmsRfcProcessor
focal_class.var_name: rfcProcessor
focal_class.declarator: tektonClient
focal_class.modifier: private
focal_class.original_string: private TektonClient tektonClient;
focal_class.type: TektonClient
focal_class.var_name: tektonClient
focal_class.declarator: gson = new Gson()
focal_class.modifier: private
focal_class.original_string: private Gson gson = new Gson();
focal_class.type: Gson
focal_class.var_name: gson
focal_class.file: cmsdal/src/main/java/com/oneops/capacity/CapacityProcessor.java
focal_class.identifier: CapacityProcessor
focal_class.class_method_signature: CapacityProcessor.setCmProcessor(CmsCmProcessor cmProcessor)
focal_class.full_signature: public void setCmProcessor(CmsCmProcessor cmProcessor)
focal_class.identifier: setCmProcessor
focal_class.modifiers: public
focal_class.parameters: (CmsCmProcessor cmProcessor)
focal_class.return: void
focal_class.signature: void setCmProcessor(CmsCmProcessor cmProcessor)
focal_class.class_method_signature: CapacityProcessor.setRfcProcessor(CmsRfcProcessor rfcProcessor)
focal_class.full_signature: public void setRfcProcessor(CmsRfcProcessor rfcProcessor)
focal_class.identifier: setRfcProcessor
focal_class.modifiers: public
focal_class.parameters: (CmsRfcProcessor rfcProcessor)
focal_class.return: void
focal_class.signature: void setRfcProcessor(CmsRfcProcessor rfcProcessor)
focal_class.class_method_signature: CapacityProcessor.setTektonClient(TektonClient tektonClient)
focal_class.full_signature: public void setTektonClient(TektonClient tektonClient)
focal_class.identifier: setTektonClient
focal_class.modifiers: public
focal_class.parameters: (TektonClient tektonClient)
focal_class.return: void
focal_class.signature: void setTektonClient(TektonClient tektonClient)
focal_class.class_method_signature: CapacityProcessor.isCapacityManagementEnabled(String nsPath)
focal_class.full_signature: public boolean isCapacityManagementEnabled(String nsPath)
focal_class.identifier: isCapacityManagementEnabled
focal_class.modifiers: public
focal_class.parameters: (String nsPath)
focal_class.return: boolean
focal_class.signature: boolean isCapacityManagementEnabled(String nsPath)
focal_class.class_method_signature: CapacityProcessor.estimateCapacity(String nsPath, Collection<CmsRfcCI> cis, Collection<CmsRfcRelation> deployedToRels)
focal_class.full_signature: public CapacityEstimate estimateCapacity(String nsPath, Collection<CmsRfcCI> cis, Collection<CmsRfcRelation> deployedToRels)
focal_class.identifier: estimateCapacity
focal_class.modifiers: public
focal_class.parameters: (String nsPath, Collection<CmsRfcCI> cis, Collection<CmsRfcRelation> deployedToRels)
focal_class.return: CapacityEstimate
focal_class.signature: CapacityEstimate estimateCapacity(String nsPath, Collection<CmsRfcCI> cis, Collection<CmsRfcRelation> deployedToRels)
focal_class.class_method_signature: CapacityProcessor.reserveCapacityForDeployment(CmsDeployment deployment)
focal_class.full_signature: public void reserveCapacityForDeployment(CmsDeployment deployment)
focal_class.identifier: reserveCapacityForDeployment
focal_class.modifiers: public
focal_class.parameters: (CmsDeployment deployment)
focal_class.return: void
focal_class.signature: void reserveCapacityForDeployment(CmsDeployment deployment)
focal_class.class_method_signature: CapacityProcessor.discardCapacityForDeployment(CmsDeployment deployment)
focal_class.full_signature: public void discardCapacityForDeployment(CmsDeployment deployment)
focal_class.identifier: discardCapacityForDeployment
focal_class.modifiers: public
focal_class.parameters: (CmsDeployment deployment)
focal_class.return: void
focal_class.signature: void discardCapacityForDeployment(CmsDeployment deployment)
focal_class.class_method_signature: CapacityProcessor.commitCapacity(CmsWorkOrder workOrder)
focal_class.full_signature: public void commitCapacity(CmsWorkOrder workOrder)
focal_class.identifier: commitCapacity
focal_class.modifiers: public
focal_class.parameters: (CmsWorkOrder workOrder)
focal_class.return: void
focal_class.signature: void commitCapacity(CmsWorkOrder workOrder)
focal_class.class_method_signature: CapacityProcessor.releaseCapacity(CmsWorkOrder workOrder)
focal_class.full_signature: public void releaseCapacity(CmsWorkOrder workOrder)
focal_class.identifier: releaseCapacity
focal_class.modifiers: public
focal_class.parameters: (CmsWorkOrder workOrder)
focal_class.return: void
focal_class.signature: void releaseCapacity(CmsWorkOrder workOrder)
focal_class.class_method_signature: CapacityProcessor.getReservationNsPath(String fullNsPath)
focal_class.full_signature: private String getReservationNsPath(String fullNsPath)
focal_class.identifier: getReservationNsPath
focal_class.modifiers: private
focal_class.parameters: (String fullNsPath)
focal_class.return: String
focal_class.signature: String getReservationNsPath(String fullNsPath)
focal_class.class_method_signature: CapacityProcessor.getCloudProviderMappings()
focal_class.full_signature: private Map<String, Object> getCloudProviderMappings()
focal_class.identifier: getCloudProviderMappings
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> getCloudProviderMappings()
focal_class.class_method_signature: CapacityProcessor.getDeployedToCloudInfoMap(Collection<CmsRfcRelation> deployedToRels)
focal_class.full_signature: private Map<Long, CloudInfo> getDeployedToCloudInfoMap(Collection<CmsRfcRelation> deployedToRels)
focal_class.identifier: getDeployedToCloudInfoMap
focal_class.modifiers: private
focal_class.parameters: (Collection<CmsRfcRelation> deployedToRels)
focal_class.return: Map<Long, CloudInfo>
focal_class.signature: Map<Long, CloudInfo> getDeployedToCloudInfoMap(Collection<CmsRfcRelation> deployedToRels)
focal_class.class_method_signature: CapacityProcessor.getDeployedToCloudInfo(long cloudCiId)
focal_class.full_signature: private CloudInfo getDeployedToCloudInfo(long cloudCiId)
focal_class.identifier: getDeployedToCloudInfo
focal_class.modifiers: private
focal_class.parameters: (long cloudCiId)
focal_class.return: CloudInfo
focal_class.signature: CloudInfo getDeployedToCloudInfo(long cloudCiId)
focal_class.class_method_signature: CapacityProcessor.getDeployedToCloudInfo(CmsCI cloud)
focal_class.full_signature: private CloudInfo getDeployedToCloudInfo(CmsCI cloud)
focal_class.identifier: getDeployedToCloudInfo
focal_class.modifiers: private
focal_class.parameters: (CmsCI cloud)
focal_class.return: CloudInfo
focal_class.signature: CloudInfo getDeployedToCloudInfo(CmsCI cloud)
focal_class.class_method_signature: CapacityProcessor.getCapacityForCis(Collection<CmsRfcCI> cis,
                                                                  Collection<CmsRfcRelation> deployedToRels,
                                                                  Map<Long, CloudInfo> cloudInfoMap,
                                                                  Map<String, Object> mappings)
focal_class.full_signature: private Map<String, Map<String, Integer>> getCapacityForCis(Collection<CmsRfcCI> cis,
                                                                  Collection<CmsRfcRelation> deployedToRels,
                                                                  Map<Long, CloudInfo> cloudInfoMap,
                                                                  Map<String, Object> mappings)
focal_class.identifier: getCapacityForCis
focal_class.modifiers: private
focal_class.parameters: (Collection<CmsRfcCI> cis,
                                                                  Collection<CmsRfcRelation> deployedToRels,
                                                                  Map<Long, CloudInfo> cloudInfoMap,
                                                                  Map<String, Object> mappings)
focal_class.return: Map<String, Map<String, Integer>>
focal_class.signature: Map<String, Map<String, Integer>> getCapacityForCis(Collection<CmsRfcCI> cis,
                                                                  Collection<CmsRfcRelation> deployedToRels,
                                                                  Map<Long, CloudInfo> cloudInfoMap,
                                                                  Map<String, Object> mappings)
focal_class.class_method_signature: CapacityProcessor.getCapacityForCi(CmsRfcCI rfcCi, CloudInfo cloudInfo, Map<String, Object> mappings)
focal_class.full_signature: private Map<String, Integer> getCapacityForCi(CmsRfcCI rfcCi, CloudInfo cloudInfo, Map<String, Object> mappings)
focal_class.identifier: getCapacityForCi
focal_class.modifiers: private
focal_class.parameters: (CmsRfcCI rfcCi, CloudInfo cloudInfo, Map<String, Object> mappings)
focal_class.return: Map<String, Integer>
focal_class.signature: Map<String, Integer> getCapacityForCi(CmsRfcCI rfcCi, CloudInfo cloudInfo, Map<String, Object> mappings)
focal_class.class_method_signature: CapacityProcessor.deleteReservations(String nsPath)
focal_class.full_signature: private void deleteReservations(String nsPath)
focal_class.identifier: deleteReservations
focal_class.modifiers: private
focal_class.parameters: (String nsPath)
focal_class.return: void
focal_class.signature: void deleteReservations(String nsPath)
focal_class.class_method_signature: CapacityProcessor.capacityShortageMessage(Map<String, String> info, Map<Long, CloudInfo> cloudInfo, String prefix)
focal_class.full_signature: private String capacityShortageMessage(Map<String, String> info, Map<Long, CloudInfo> cloudInfo, String prefix)
focal_class.identifier: capacityShortageMessage
focal_class.modifiers: private
focal_class.parameters: (Map<String, String> info, Map<Long, CloudInfo> cloudInfo, String prefix)
focal_class.return: String
focal_class.signature: String capacityShortageMessage(Map<String, String> info, Map<Long, CloudInfo> cloudInfo, String prefix)
focal_method.body: public void releaseCapacity(CmsWorkOrder workOrder) {
          CmsRfcCI rfcCi = workOrder.getRfcCi();
          String nsPath = getReservationNsPath(rfcCi.getNsPath());
          if (!isCapacityManagementEnabled(nsPath)) return;
  
          Map<String, Object> mappings = getCloudProviderMappings();
          if (mappings == null) return;
  
          List<CmsCIRelation> deployedTos = cmProcessor.getFromCIRelationsNakedNoAttrs(rfcCi.getCiId(), "base.DeployedTo", null, null);
          CloudInfo cloudInfo = getDeployedToCloudInfo(deployedTos.get(0).getToCiId());
          Map<String, Integer> capacity = getCapacityForCi(rfcCi, cloudInfo, mappings);
  
          if (!capacity.isEmpty()) {
              tektonClient.releaseResources(capacity, nsPath, cloudInfo.getSubscriptionId());
          }
      }
focal_method.class_method_signature: CapacityProcessor.releaseCapacity(CmsWorkOrder workOrder)
focal_method.full_signature: public void releaseCapacity(CmsWorkOrder workOrder)
focal_method.identifier: releaseCapacity
focal_method.invocations: getRfcCi getReservationNsPath getNsPath isCapacityManagementEnabled getCloudProviderMappings getFromCIRelationsNakedNoAttrs getCiId getDeployedToCloudInfo getToCiId get getCapacityForCi isEmpty releaseResources getSubscriptionId
focal_method.modifiers: public
focal_method.parameters: (CmsWorkOrder workOrder)
focal_method.return: void
focal_method.signature: void releaseCapacity(CmsWorkOrder workOrder)