Source:
<code>public void testTemplateKeyChangeDuringUpdate() { ServerTemplate serverTemplate = createServerTemplate(); ContainerSpec containerToDeploy = new ContainerSpec(CONTAINER_ID, CONTAINER_NAME, serverTemplate, releaseId, KieContainerStatus.STOPPED, Collections.EMPTY_MAP); mgmtControllerClient.saveContainerSpec(serverTemplate.getId(), containerToDeploy); ContainerSpec containerResponseEntity = mgmtControllerClient.getContainerInfo(kieServerInfo.getServerId(), CONTAINER_ID); checkContainer(containerResponseEntity, KieContainerStatus.STOPPED); assertEquals(CONTAINER_NAME, containerResponseEntity.getContainerName()); assertEquals(releaseId, containerResponseEntity.getReleasedId()); ServerTemplate secondTemplate = createServerTemplate("st-id", "st-id", kieServerInfo.getLocation()); containerToDeploy.setServerTemplateKey(secondTemplate); try { mgmtControllerClient.updateContainerSpec(serverTemplate.getId(), containerToDeploy); fail("Template key should not be allowed to be changed during update."); } catch (UnexpectedResponseCodeException e) { assertEquals(400, e.getResponseCode()); KieServerAssert.assertResultContainsString(e.getMessage(), "Cannot change container template key during update."); } assertEquals(2, mgmtControllerClient.listServerTemplates().size()); <START> KieServerAssert.assertNullOrEmpty("Found container in second server template.", mgmtControllerClient.listContainerSpec(secondTemplate.getId())); <END> }</code><technical_language>good check container is changed</technical_language>

Target:
public void testTemplateKeyChangeDuringUpdate() { ServerTemplate serverTemplate = createServerTemplate(); ContainerSpec containerToDeploy = new ContainerSpec(CONTAINER_ID, CONTAINER_NAME, serverTemplate, releaseId, KieContainerStatus.STOPPED, Collections.EMPTY_MAP); mgmtControllerClient.saveContainerSpec(serverTemplate.getId(), containerToDeploy); ContainerSpec containerResponseEntity = mgmtControllerClient.getContainerInfo(kieServerInfo.getServerId(), CONTAINER_ID); checkContainer(containerResponseEntity, KieContainerStatus.STOPPED); assertEquals(CONTAINER_NAME, containerResponseEntity.getContainerName()); assertEquals(releaseId, containerResponseEntity.getReleasedId()); ServerTemplate secondTemplate = createServerTemplate("st-id", "st-id", kieServerInfo.getLocation()); containerToDeploy.setServerTemplateKey(secondTemplate); try { mgmtControllerClient.updateContainerSpec(serverTemplate.getId(), containerToDeploy); fail("Template key should not be allowed to be changed during update."); } catch (UnexpectedResponseCodeException e) { assertEquals(400, e.getResponseCode()); KieServerAssert.assertResultContainsString(e.getMessage(), "Cannot change container template key during update."); } assertEquals(2, mgmtControllerClient.listServerTemplates().size()); KieServerAssert.assertNullOrEmpty("Found container in second server template.", mgmtControllerClient.listContainerSpec(secondTemplate.getId())); assertEquals(1, mgmtControllerClient.listContainerSpec(serverTemplate.getId()).size()); containerResponseEntity = mgmtControllerClient.getContainerInfo(kieServerInfo.getServerId(), CONTAINER_ID); checkContainer(containerResponseEntity, KieContainerStatus.STOPPED); assertEquals(serverTemplate.getId(), containerResponseEntity.getServerTemplateKey().getId()); assertEquals(serverTemplate.getName(), containerResponseEntity.getServerTemplateKey().getName()); assertEquals(CONTAINER_NAME, containerResponseEntity.getContainerName()); assertEquals(releaseId, containerResponseEntity.getReleasedId()); }