### Question:
BpmCaseInstanceActionBase extends BaseAction { public boolean isKieServerConfigurationValid() { logger.debug("Check Configuration for knowledgeSourceId {}", this.getKnowledgeSourceId()); KieBpmConfig config=null; try { if (null!=this.getKnowledgeSourceId()) { config = formManager.getKieServerConfigurations().get(this.getKnowledgeSourceId()); } if (null == config) { logger.warn("The configuration is null, return false"); this.setErrorCode(ERROR_NULL_CONFIG); return false; } } catch (ApsSystemException ex) { logger.error("Error reading the configuration", ex); return false; } logger.debug("The configuration is valid, return true"); return true; }  boolean isKieServerConfigurationValid(); CaseManager getCaseManager(); void setCaseManager(CaseManager caseManager); String getFrontEndCaseData(); void setFrontEndCaseData(String frontEndCaseData); String getKnowledgeSourceId(); void setKnowledgeSourceId(String knowledgeSourceId); String getContainerid(); void setContainerid(String containerid); String getCasePath(); void setCasePath(String casePath); String getChannelPath(); void setChannelPath(String channelPath); String getChannel(); void setChannel(String channel); KieFormManager getFormManager(); void setFormManager(KieFormManager formManager); int getErrorCode(); void setErrorCode(int errorCode); static final int ERROR_NULL_CONFIG; static final int ERROR_EMPTY_CASES; }### Answer:
@Test public void testIsKieServerConfigurationNotValid() throws ApsSystemException { when(formManager.getKieServerConfigurations()).thenReturn(new HashMap<String, KieBpmConfig>()); boolean valid = bpmCaseInstanceActionBase.isKieServerConfigurationValid(); assertFalse(valid); }
@Test public void testIsKieServerConfigurationValid() throws ApsSystemException { HashMap<String, KieBpmConfig> serverConfigurations = new HashMap(); bpmCaseInstanceActionBase.setKnowledgeSourceId(KNOWLEDGE_SOURCE_ID); serverConfigurations.put(KNOWLEDGE_SOURCE_ID, kieBpmConfig); when(formManager.getKieServerConfigurations()).thenReturn(serverConfigurations); when(configManager.getConfigItem(anyString())).thenReturn(xmlConf); when(formManager.getConfigManager()).thenReturn(configManager); boolean valid = bpmCaseInstanceActionBase.isKieServerConfigurationValid(); assertTrue(valid); }