### Question:
ServiceLevelUpgrade extends ServiceLevel implements JavaDelegate { @Override public void execute(DelegateExecution execution) throws Exception { LOG.debug("Running execute block for activity id: {}, name: {}", execution.getCurrentActivityId(), execution.getCurrentActivityName()); if (execution.hasVariable(ServiceLevelConstants.RESOURCE_TYPE) && execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) { final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE); LOG.debug("Scope retrieved from delegate execution: " + controllerScope); if (ServiceLevelConstants.VALID_CONTROLLER_SCOPE.contains(controllerScope)) { final String wflName = fetchWorkflowUsingScope(controllerScope, ServiceLevelConstants.SW_UP_OPERATION); LOG.debug("Software Upgrade workflow fetched for the scope: {} is: {}", controllerScope, wflName); validateParamsWithScope(execution, controllerScope, SOFTWARE_UP_PARAMS_MAP.get(controllerScope)); LOG.info("Parameters validated successfully for {}", wflName); execution.setVariable(ServiceLevelConstants.SOFTWARE_WORKFLOW_TO_INVOKE, wflName); execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ServiceLevelConstants.EMPTY_STRING); execution.setVariable(ServiceLevelConstants.PNF_COUNTER, ServiceLevelConstants.COUNT_ZERO); } else { exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, "Invalid Controller scope for resource level software upgrade"); } } else { exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, "Resource type not found in the execution to invoke resource level software upgrade"); } }  @Override void execute(DelegateExecution execution);  }### Answer:
@Test public void ServiceLevelUpgradeWithPnf() throws Exception { ServiceLevelUpgrade testedObject = new ServiceLevelUpgrade(); DelegateExecution execution = prepareExecution(); execution.setVariable(ServiceLevelConstants.RESOURCE_TYPE, "pnf"); testedObject.execute(execution); assertThat(execution.getVariable(ServiceLevelConstants.SOFTWARE_WORKFLOW_TO_INVOKE)) .isEqualTo("GenericPnfSoftwareUpgrade"); assertThat(execution.getVariable(ServiceLevelConstants.CONTROLLER_STATUS)).isEqualTo(""); }
@Test public void ServiceLevelUpgradeWithVnf() throws Exception { ServiceLevelUpgrade testedObject = new ServiceLevelUpgrade(); DelegateExecution execution = prepareExecution(); execution.setVariable(ServiceLevelConstants.RESOURCE_TYPE, "vnf"); testedObject.execute(execution); assertThat(execution.getVariable(ServiceLevelConstants.SOFTWARE_WORKFLOW_TO_INVOKE)) .isEqualTo("GenericVnfSoftwareUpgrade"); assertThat(execution.getVariable(ServiceLevelConstants.CONTROLLER_STATUS)).isEqualTo(""); }