test_class.declarator: cloudCis
test_class.modifier: private
test_class.original_string: private Map<String, CmsCI> cloudCis;
test_class.type: Map<String, CmsCI>
test_class.var_name: cloudCis
test_class.declarator: clouds = {"c1", "c2", "c3", "c4"}
test_class.modifier: private final
test_class.original_string: private final String[] clouds = {"c1", "c2", "c3", "c4"};
test_class.type: String[]
test_class.var_name: clouds
test_class.file: transistor/src/test/java/com/oneops/transistor/service/BomManagerImplTest.java
test_class.identifier: BomManagerImplTest
test_case.body: @Test
      public void changingSomeDeployedPrimaryToInactiveAndOthersToSecondary() throws Exception {
          CmsCmProcessor cmProcessor =mock(CmsCmProcessor.class);
          BomManagerImpl impl = getInstance(cmProcessor);
          String[] inactivePrimaryClouds = {"c1"};
          String[] activeSecondaryClouds = {"c2"};
          List<CmsCIRelation> platformCloudRels = Stream.of(inactivePrimaryClouds)
                  .map(s -> (createInactivePrimaryCloud(s)))
                  .collect(toList());
          List<CmsCIRelation> secondaryCloudRels = Stream.of(activeSecondaryClouds)
                  .map(s -> (createSecondaryCloud(s)))
                  .collect(toList());
          platformCloudRels.addAll(secondaryCloudRels);
  
          PlatformBomGenerationContext context = platformContext("/test/a1/e1", "p1");
          doAnswer(invocationOnMock -> Stream.of(clouds)
                      .map(cloud -> (fqdnDeployedToRelation(cloud, "1")))
                      .collect(Collectors.toList()))
                  .when(context).getBomRelations();
  
          doAnswer(i -> Arrays.asList(relation("Entrypoint", ci("manifest.Fqdn", "fqdn", 1234))))
                  .when(context).getEntryPoints();
  
          //should allow
          impl.check4Secondary(context, platformCloudRels);
      }
test_case.class_method_signature: BomManagerImplTest.changingSomeDeployedPrimaryToInactiveAndOthersToSecondary()
test_case.full_signature: @Test public void changingSomeDeployedPrimaryToInactiveAndOthersToSecondary()
test_case.identifier: changingSomeDeployedPrimaryToInactiveAndOthersToSecondary
test_case.invocations: mock getInstance collect map of createInactivePrimaryCloud toList collect map of createSecondaryCloud toList addAll platformContext getBomRelations when doAnswer collect map of fqdnDeployedToRelation toList getEntryPoints when doAnswer asList relation ci check4Secondary
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void changingSomeDeployedPrimaryToInactiveAndOthersToSecondary()
focal_class.declarator: logger = Logger.getLogger(BomManagerImpl.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = Logger.getLogger(BomManagerImpl.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: checkSecondary = Boolean.valueOf(getProperty("transistor.checkSecondary", "true"))
focal_class.modifier: private static final
focal_class.original_string: private static final boolean checkSecondary = Boolean.valueOf(getProperty("transistor.checkSecondary", "true"));
focal_class.type: boolean
focal_class.var_name: checkSecondary
focal_class.declarator: check4Services = Boolean.valueOf(getProperty("transistor.checkServices", "true"))
focal_class.modifier: private static final
focal_class.original_string: private static final boolean check4Services = Boolean.valueOf(getProperty("transistor.checkServices", "true"));
focal_class.type: boolean
focal_class.var_name: check4Services
focal_class.declarator: PACK_CLOUD_NS_WHITELIST_CMS_VAR_NAME = "PACK_CLOUD_NS_WHITELIST"
focal_class.modifier: static final
focal_class.original_string: static final String PACK_CLOUD_NS_WHITELIST_CMS_VAR_NAME = "PACK_CLOUD_NS_WHITELIST";
focal_class.type: String
focal_class.var_name: PACK_CLOUD_NS_WHITELIST_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: manifestRfcProcessor
focal_class.modifier: private
focal_class.original_string: private CmsRfcProcessor manifestRfcProcessor;
focal_class.type: CmsRfcProcessor
focal_class.var_name: manifestRfcProcessor
focal_class.declarator: bomRfcProcessor
focal_class.modifier: private
focal_class.original_string: private CmsRfcProcessor bomRfcProcessor;
focal_class.type: CmsRfcProcessor
focal_class.var_name: bomRfcProcessor
focal_class.declarator: bomGenerationProcessor
focal_class.modifier: private
focal_class.original_string: private BomRfcBulkProcessor bomGenerationProcessor;
focal_class.type: BomRfcBulkProcessor
focal_class.var_name: bomGenerationProcessor
focal_class.declarator: trUtil
focal_class.modifier: private
focal_class.original_string: private TransUtil trUtil;
focal_class.type: TransUtil
focal_class.var_name: trUtil
focal_class.declarator: dpmtProcessor
focal_class.modifier: private
focal_class.original_string: private CmsDpmtProcessor dpmtProcessor;
focal_class.type: CmsDpmtProcessor
focal_class.var_name: dpmtProcessor
focal_class.declarator: cmsUtil
focal_class.modifier: private
focal_class.original_string: private CmsUtil cmsUtil;
focal_class.type: CmsUtil
focal_class.var_name: cmsUtil
focal_class.declarator: cloudUtil
focal_class.modifier: private
focal_class.original_string: private CloudUtil cloudUtil;
focal_class.type: CloudUtil
focal_class.var_name: cloudUtil
focal_class.declarator: gson = new Gson()
focal_class.original_string: Gson gson = new Gson();
focal_class.type: Gson
focal_class.var_name: gson
focal_class.file: transistor/src/main/java/com/oneops/transistor/service/BomManagerImpl.java
focal_class.identifier: BomManagerImpl
focal_class.interfaces: implements BomManager
focal_class.class_method_signature: BomManagerImpl.setCloudUtil(CloudUtil cloudUtil)
focal_class.full_signature: public void setCloudUtil(CloudUtil cloudUtil)
focal_class.identifier: setCloudUtil
focal_class.modifiers: public
focal_class.parameters: (CloudUtil cloudUtil)
focal_class.return: void
focal_class.signature: void setCloudUtil(CloudUtil cloudUtil)
focal_class.class_method_signature: BomManagerImpl.setCmsUtil(CmsUtil cmsUtil)
focal_class.full_signature: public void setCmsUtil(CmsUtil cmsUtil)
focal_class.identifier: setCmsUtil
focal_class.modifiers: public
focal_class.parameters: (CmsUtil cmsUtil)
focal_class.return: void
focal_class.signature: void setCmsUtil(CmsUtil cmsUtil)
focal_class.class_method_signature: BomManagerImpl.setTrUtil(TransUtil trUtil)
focal_class.full_signature: public void setTrUtil(TransUtil trUtil)
focal_class.identifier: setTrUtil
focal_class.modifiers: public
focal_class.parameters: (TransUtil trUtil)
focal_class.return: void
focal_class.signature: void setTrUtil(TransUtil trUtil)
focal_class.class_method_signature: BomManagerImpl.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: BomManagerImpl.setManifestRfcProcessor(CmsRfcProcessor manifestRfcProcessor)
focal_class.full_signature: public void setManifestRfcProcessor(CmsRfcProcessor manifestRfcProcessor)
focal_class.identifier: setManifestRfcProcessor
focal_class.modifiers: public
focal_class.parameters: (CmsRfcProcessor manifestRfcProcessor)
focal_class.return: void
focal_class.signature: void setManifestRfcProcessor(CmsRfcProcessor manifestRfcProcessor)
focal_class.class_method_signature: BomManagerImpl.setBomRfcProcessor(CmsRfcProcessor bomRfcProcessor)
focal_class.full_signature: public void setBomRfcProcessor(CmsRfcProcessor bomRfcProcessor)
focal_class.identifier: setBomRfcProcessor
focal_class.modifiers: public
focal_class.parameters: (CmsRfcProcessor bomRfcProcessor)
focal_class.return: void
focal_class.signature: void setBomRfcProcessor(CmsRfcProcessor bomRfcProcessor)
focal_class.class_method_signature: BomManagerImpl.setBomGenerationProcessor(BomRfcBulkProcessor bomGenerationProcessor)
focal_class.full_signature: public void setBomGenerationProcessor(BomRfcBulkProcessor bomGenerationProcessor)
focal_class.identifier: setBomGenerationProcessor
focal_class.modifiers: public
focal_class.parameters: (BomRfcBulkProcessor bomGenerationProcessor)
focal_class.return: void
focal_class.signature: void setBomGenerationProcessor(BomRfcBulkProcessor bomGenerationProcessor)
focal_class.class_method_signature: BomManagerImpl.setDpmtProcessor(CmsDpmtProcessor dpmtProcessor)
focal_class.full_signature: public void setDpmtProcessor(CmsDpmtProcessor dpmtProcessor)
focal_class.identifier: setDpmtProcessor
focal_class.modifiers: public
focal_class.parameters: (CmsDpmtProcessor dpmtProcessor)
focal_class.return: void
focal_class.signature: void setDpmtProcessor(CmsDpmtProcessor dpmtProcessor)
focal_class.class_method_signature: BomManagerImpl.generateAndDeployBom(long envId, String userId, Set<Long> excludePlats, CmsDeployment dpmt, boolean commit)
focal_class.full_signature: @Override public Map<String, Object> generateAndDeployBom(long envId, String userId, Set<Long> excludePlats, CmsDeployment dpmt, boolean commit)
focal_class.identifier: generateAndDeployBom
focal_class.modifiers: @Override public
focal_class.parameters: (long envId, String userId, Set<Long> excludePlats, CmsDeployment dpmt, boolean commit)
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> generateAndDeployBom(long envId, String userId, Set<Long> excludePlats, CmsDeployment dpmt, boolean commit)
focal_class.class_method_signature: BomManagerImpl.generateBom(long envId, String userId, Set<Long> excludePlats, String desc, boolean commit)
focal_class.full_signature: @Override public Map<String, Object> generateBom(long envId, String userId, Set<Long> excludePlats, String desc, boolean commit)
focal_class.identifier: generateBom
focal_class.modifiers: @Override public
focal_class.parameters: (long envId, String userId, Set<Long> excludePlats, String desc, boolean commit)
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> generateBom(long envId, String userId, Set<Long> excludePlats, String desc, boolean commit)
focal_class.class_method_signature: BomManagerImpl.generateBomForClouds(long envId, String userId, Set<Long> excludePlats, String desc, boolean commit)
focal_class.full_signature: private Map<String, Object> generateBomForClouds(long envId, String userId, Set<Long> excludePlats, String desc, boolean commit)
focal_class.identifier: generateBomForClouds
focal_class.modifiers: private
focal_class.parameters: (long envId, String userId, Set<Long> excludePlats, String desc, boolean commit)
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> generateBomForClouds(long envId, String userId, Set<Long> excludePlats, String desc, boolean commit)
focal_class.class_method_signature: BomManagerImpl.generateBomForActiveClouds(EnvBomGenerationContext context)
focal_class.full_signature: private int generateBomForActiveClouds(EnvBomGenerationContext context)
focal_class.identifier: generateBomForActiveClouds
focal_class.modifiers: private
focal_class.parameters: (EnvBomGenerationContext context)
focal_class.return: int
focal_class.signature: int generateBomForActiveClouds(EnvBomGenerationContext context)
focal_class.class_method_signature: BomManagerImpl.getPlatformIds(Map<Integer, List<CmsCI>> platsToProcess)
focal_class.full_signature: private Set<Long> getPlatformIds(Map<Integer, List<CmsCI>> platsToProcess)
focal_class.identifier: getPlatformIds
focal_class.modifiers: private
focal_class.parameters: (Map<Integer, List<CmsCI>> platsToProcess)
focal_class.return: Set<Long>
focal_class.signature: Set<Long> getPlatformIds(Map<Integer, List<CmsCI>> platsToProcess)
focal_class.class_method_signature: BomManagerImpl.check4Secondary(PlatformBomGenerationContext context, List<CmsCIRelation> platformCloudRels)
focal_class.full_signature:  void check4Secondary(PlatformBomGenerationContext context, List<CmsCIRelation> platformCloudRels)
focal_class.identifier: check4Secondary
focal_class.parameters: (PlatformBomGenerationContext context, List<CmsCIRelation> platformCloudRels)
focal_class.return: void
focal_class.signature: void check4Secondary(PlatformBomGenerationContext context, List<CmsCIRelation> platformCloudRels)
focal_class.class_method_signature: BomManagerImpl.generateBomForOfflineClouds(EnvBomGenerationContext context, int startingExecOrder)
focal_class.full_signature: private int generateBomForOfflineClouds(EnvBomGenerationContext context, int startingExecOrder)
focal_class.identifier: generateBomForOfflineClouds
focal_class.modifiers: private
focal_class.parameters: (EnvBomGenerationContext context, int startingExecOrder)
focal_class.return: int
focal_class.signature: int generateBomForOfflineClouds(EnvBomGenerationContext context, int startingExecOrder)
focal_class.class_method_signature: BomManagerImpl.getMaxExecOrder(Map<Integer, List<CmsCI>> platsToProcess)
focal_class.full_signature: private Integer getMaxExecOrder(Map<Integer, List<CmsCI>> platsToProcess)
focal_class.identifier: getMaxExecOrder
focal_class.modifiers: private
focal_class.parameters: (Map<Integer, List<CmsCI>> platsToProcess)
focal_class.return: Integer
focal_class.signature: Integer getMaxExecOrder(Map<Integer, List<CmsCI>> platsToProcess)
focal_class.class_method_signature: BomManagerImpl.getOrderedClouds(List<CmsCIRelation> cloudRels, boolean reverse)
focal_class.full_signature:  SortedMap<Integer, SortedMap<Integer, List<CmsCIRelation>>> getOrderedClouds(List<CmsCIRelation> cloudRels, boolean reverse)
focal_class.identifier: getOrderedClouds
focal_class.parameters: (List<CmsCIRelation> cloudRels, boolean reverse)
focal_class.return: SortedMap<Integer, SortedMap<Integer, List<CmsCIRelation>>>
focal_class.signature: SortedMap<Integer, SortedMap<Integer, List<CmsCIRelation>>> getOrderedClouds(List<CmsCIRelation> cloudRels, boolean reverse)
focal_class.class_method_signature: BomManagerImpl.submitDeployment(long releaseId, String userId, String desc)
focal_class.full_signature: @Override public long submitDeployment(long releaseId, String userId, String desc)
focal_class.identifier: submitDeployment
focal_class.modifiers: @Override public
focal_class.parameters: (long releaseId, String userId, String desc)
focal_class.return: long
focal_class.signature: long submitDeployment(long releaseId, String userId, String desc)
focal_class.class_method_signature: BomManagerImpl.updateParentReleaseId(String nsPath, String manifestNsPath, String bomReleaseState)
focal_class.full_signature: private CmsRelease updateParentReleaseId(String nsPath, String manifestNsPath, String bomReleaseState)
focal_class.identifier: updateParentReleaseId
focal_class.modifiers: private
focal_class.parameters: (String nsPath, String manifestNsPath, String bomReleaseState)
focal_class.return: CmsRelease
focal_class.signature: CmsRelease updateParentReleaseId(String nsPath, String manifestNsPath, String bomReleaseState)
focal_class.class_method_signature: BomManagerImpl.getOrderedPlatforms(EnvBomGenerationContext context)
focal_class.full_signature:  Map<Integer, List<CmsCI>> getOrderedPlatforms(EnvBomGenerationContext context)
focal_class.identifier: getOrderedPlatforms
focal_class.parameters: (EnvBomGenerationContext context)
focal_class.return: Map<Integer, List<CmsCI>>
focal_class.signature: Map<Integer, List<CmsCI>> getOrderedPlatforms(EnvBomGenerationContext context)
focal_class.class_method_signature: BomManagerImpl.processPlatformsOrder(long startPlatId, Map<Long, Integer> platExecOrderMap, List<CmsCIRelation> allLinksToRels)
focal_class.full_signature: private void processPlatformsOrder(long startPlatId, Map<Long, Integer> platExecOrderMap, List<CmsCIRelation> allLinksToRels)
focal_class.identifier: processPlatformsOrder
focal_class.modifiers: private
focal_class.parameters: (long startPlatId, Map<Long, Integer> platExecOrderMap, List<CmsCIRelation> allLinksToRels)
focal_class.return: void
focal_class.signature: void processPlatformsOrder(long startPlatId, Map<Long, Integer> platExecOrderMap, List<CmsCIRelation> allLinksToRels)
focal_class.class_method_signature: BomManagerImpl.commitManifestRelease(String manifestNsPath, String bomNsPath, String userId, String desc)
focal_class.full_signature: private void commitManifestRelease(String manifestNsPath, String bomNsPath, String userId, String desc)
focal_class.identifier: commitManifestRelease
focal_class.modifiers: private
focal_class.parameters: (String manifestNsPath, String bomNsPath, String userId, String desc)
focal_class.return: void
focal_class.signature: void commitManifestRelease(String manifestNsPath, String bomNsPath, String userId, String desc)
focal_class.class_method_signature: BomManagerImpl.check4openDeployment(String nsPath)
focal_class.full_signature: @Override public void check4openDeployment(String nsPath)
focal_class.identifier: check4openDeployment
focal_class.modifiers: @Override public
focal_class.parameters: (String nsPath)
focal_class.return: void
focal_class.signature: void check4openDeployment(String nsPath)
focal_class.class_method_signature: BomManagerImpl.checkPackCloudWhiteList(CmsCI platform, CmsCI cloud)
focal_class.full_signature:  void checkPackCloudWhiteList(CmsCI platform, CmsCI cloud)
focal_class.identifier: checkPackCloudWhiteList
focal_class.parameters: (CmsCI platform, CmsCI cloud)
focal_class.return: void
focal_class.signature: void checkPackCloudWhiteList(CmsCI platform, CmsCI cloud)
focal_method.body: void check4Secondary(PlatformBomGenerationContext context, List<CmsCIRelation> platformCloudRels) {
  		String nsPath = context.getBomNsPath();
  		List<CmsCIRelation> entryPoints = context.getEntryPoints();
  		if(entryPoints.size() == 0) {
  			// Some platforms do not have entrypoints.
  			logger.info("Skipping secondary check - there is no entry point for platform " + context.getPlatform().getCiId() + " in " + nsPath);
  			return;
  		}
  
  		Function<CmsCIRelation, Integer> getPriority = (deployedTo) -> deployedTo.getAttribute("priority") != null ? Integer.valueOf(deployedTo.getAttribute("priority").getDjValue()) : Integer.valueOf(0);
  		CmsCIRelation entryPoint = entryPoints.get(0);
  		//get manifest clouds and priority; what is intended
  		Map<Long, Integer> intendedCloudPriority = platformCloudRels.stream()
  				.filter(cloudUtil::isCloudActive)
  				.collect(toMap(CmsCIRelationBasic::getToCiId, getPriority, (i, j) -> i));
  		//are there any secondary clouds for deployment
  		long numberOfSecondaryClouds = intendedCloudPriority.entrySet().stream()
  				.filter(entry -> (entry.getValue().equals(SECONDARY_CLOUD_STATUS)))
  				.count();
  		if (numberOfSecondaryClouds == 0) {
  			return;
  		}
  
  		String entryPointClass = trUtil.getShortClazzName(entryPoint.getToCi().getCiClassName());
  		Set<Long> cloudIds = platformCloudRels.stream().map(CmsCIRelation::getToCiId).collect(Collectors.toSet());
  		Map<Long, Integer> existingCloudPriority = context.getBomRelations().stream()
  				.filter(r -> cloudIds.contains(r.getToCiId()) && r.getRelationName().equals(DEPLOYED_TO) && trUtil.getShortClazzName(r.getFromCi().getCiClassName()).equals(entryPointClass))
  				.collect(toMap(CmsCIRelationBasic::getToCiId, getPriority, Math::max));
  
  		HashMap<Long, Integer> computedCloudPriority = new HashMap<>(existingCloudPriority);
  		computedCloudPriority.putAll(intendedCloudPriority);
  
  		//Now, take  all offline clouds from
  		Map<Long, Integer> offlineClouds = platformCloudRels.stream()
  				.filter(cloudUtil::isCloudOffline)
  				.collect(toMap(CmsCIRelationBasic::getToCiId, getPriority, (i, j) -> i));
  		if(!offlineClouds.isEmpty()){
  			offlineClouds.forEach((k,v)->{
  				if(computedCloudPriority.containsKey(k)){
  					computedCloudPriority.remove(k);
  				}
  			});
  		}
  
  		long count = computedCloudPriority.entrySet().stream().filter(entry -> (entry.getValue().equals(CmsConstants.SECONDARY_CLOUD_STATUS))).count();
  		if (computedCloudPriority.size() == count) {
  			//throw transistor exception
  			String message;
  			String clouds = platformCloudRels.stream()
  					.filter(rel-> !cloudUtil.isCloudActive(rel) && (getPriority.apply(rel) == PRIMARY_CLOUD_STATUS))
  					.map(rel -> rel.getToCi().getCiName())
  					.collect(joining(","));
  
  			if (StringUtils.isNotEmpty(clouds)) {
  				message = String.format("The deployment will result in no instances in primary clouds for platform %s. Primary clouds <%s>  are not in active state for this platform.  ", nsPath, clouds);
  			} else {
  				message = String.format("The deployment will result in no instances in primary clouds for platform %s. Please check the cloud priority of the clouds. .  ", nsPath);
  			}
  
  			throw new TransistorException(CmsError.TRANSISTOR_ALL_INSTANCES_SECONDARY, message);
  		}
  	}
focal_method.class_method_signature: BomManagerImpl.check4Secondary(PlatformBomGenerationContext context, List<CmsCIRelation> platformCloudRels)
focal_method.full_signature:  void check4Secondary(PlatformBomGenerationContext context, List<CmsCIRelation> platformCloudRels)
focal_method.identifier: check4Secondary
focal_method.invocations: getBomNsPath getEntryPoints size info getCiId getPlatform getAttribute valueOf getDjValue getAttribute valueOf get collect filter stream toMap count filter stream entrySet equals getValue getShortClazzName getCiClassName getToCi collect map stream toSet collect filter stream getBomRelations contains getToCiId equals getRelationName equals getShortClazzName getCiClassName getFromCi toMap putAll collect filter stream toMap isEmpty forEach containsKey remove count filter stream entrySet equals getValue size collect map filter stream isCloudActive apply getCiName getToCi joining isNotEmpty format format
focal_method.parameters: (PlatformBomGenerationContext context, List<CmsCIRelation> platformCloudRels)
focal_method.return: void
focal_method.signature: void check4Secondary(PlatformBomGenerationContext context, List<CmsCIRelation> platformCloudRels)