### Question:
SpecManagementServiceImpl implements SpecManagementService { @Override public void deleteServerInstance(final ServerInstanceKey serverInstanceKey) { checkNotNull("serverInstanceKey", serverInstanceKey); if (getKieServerInstanceManager().isAlive(serverInstanceKey)) { throw new RuntimeException("Can't delete live instance."); } else { final String serverInstanceId = serverInstanceKey.getServerInstanceId(); final ServerTemplate serverTemplate = getServerTemplate(serverInstanceKey.getServerTemplateId()); if (serverTemplate != null) { serverTemplate.deleteServerInstance(serverInstanceId); getTemplateStorage().update(serverTemplate); getNotificationService().notify(new ServerInstanceDeleted(serverInstanceId)); } } }  @Override synchronized void saveContainerSpec(String serverTemplateId,
                                               ContainerSpec containerSpec); @Override synchronized void updateContainerSpec(String serverTemplateId, ContainerSpec containerSpec); @Override synchronized void updateContainerSpec(final String serverTemplateId, final String containerId, final ContainerSpec containerSpec); @Override synchronized void updateContainerSpec(String serverTemplateId, String containerId, ContainerSpec containerSpec, Boolean resetBeforeUpdate); @Override synchronized void saveServerTemplate(ServerTemplate serverTemplate); @Override ServerTemplate getServerTemplate(String serverTemplateId); @Override ServerTemplateKeyList listServerTemplateKeys(); @Override ServerTemplateList listServerTemplates(); @Override ContainerSpecList listContainerSpec(String serverTemplateId); @Override ContainerSpec getContainerInfo(String serverTemplateId,
                                          String containerId); @Override synchronized void deleteContainerSpec(String serverTemplateId,
                                                 String containerSpecId); @Override synchronized void deleteServerTemplate(String serverTemplateId); @Override synchronized void copyServerTemplate(String serverTemplateId,
                                                String newServerTemplateId,
                                                String newServerTemplateName); @Override synchronized void updateContainerConfig(final String serverTemplateId,
                                                   final String containerSpecId,
                                                   final Capability capability,
                                                   final ContainerConfig containerConfig); @Override synchronized void updateServerTemplateConfig(String serverTemplateId,
                                                        Capability capability,
                                                        ServerConfig serverTemplateConfig); @Override synchronized void startContainer(ContainerSpecKey containerSpecKey); @Override synchronized void stopContainer(ContainerSpecKey containerSpecKey); @Override synchronized void activateContainer(ContainerSpecKey containerSpecKey); @Override synchronized void deactivateContainer(ContainerSpecKey containerSpecKey); @Override void deleteServerInstance(final ServerInstanceKey serverInstanceKey); KieServerTemplateStorage getTemplateStorage(); void setTemplateStorage(KieServerTemplateStorage templateStorage); NotificationService getNotificationService(); void setNotificationService(NotificationService notificationService); KieServerInstanceManager getKieServerInstanceManager(); void setKieServerInstanceManager(KieServerInstanceManager kieServerInstanceManager);  }### Answer:
@Test public void testDeleteServerInstance() { final ServerTemplate serverTemplate = new ServerTemplate("serverTemplateId", "serverTemplateName"); final ServerInstanceKey serverInstanceKey = new ServerInstanceKey(serverTemplate.getId(), "serverName", "serverInstanceId", "url"); serverTemplate.addServerInstance(serverInstanceKey); specManagementService.saveServerTemplate(serverTemplate); when(kieServerInstanceManager.isAlive(serverInstanceKey)).thenReturn(false); specManagementService.deleteServerInstance(serverInstanceKey); final ServerTemplate updatedServerTemplate = specManagementService.getServerTemplate(serverTemplate.getId()); assertEquals(0, updatedServerTemplate.getServerInstanceKeys().size()); }