Source:
public void testUpdateContainerInAccount() throws JSONException { Account account = Account.fromJson(accountJsonLike); AccountBuilder accountBuilder = new AccountBuilder(account); for (int i = 0; i < CONTAINER_COUNT; i++) { Container container = account.getContainerById(refContainerIds.get(i)); accountBuilder.removeContainer(container); ContainerBuilder containerBuilder = new ContainerBuilder(container); short updatedContainerId = (short) (container.getId() + 100); String updatedContainerName = container.getName() + "-updated"; Container.ContainerStatus updatedContainerStatus = Container.ContainerStatus.INACTIVE; String updatedContainerDescription = container.getDescription() + "--updated"; boolean updatedIsPrivate = !container.isPrivate(); containerBuilder.setId(updatedContainerId) .setName(updatedContainerName) .setStatus(updatedContainerStatus) .setDescription(updatedContainerDescription) .setIsPrivate(updatedIsPrivate); Container updatedContainer = containerBuilder.build(); accountBuilder.addOrUpdateContainer(updatedContainer); Account updatedAccount = accountBuilder.build(); assertEquals("container id is not correctly updated", updatedContainerId, updatedAccount.getContainerById(updatedContainerId).getId()); assertEquals("container name is not correctly updated", updatedContainerName, updatedAccount.getContainerById(updatedContainerId).getName()); assertEquals("container status is not correctly updated", updatedContainerStatus, updatedAccount.getContainerById(updatedContainerId).getStatus()); assertEquals("container description is not correctly updated", updatedContainerDescription, updatedAccount.getContainerById(updatedContainerId).getDescription()); assertEquals("container isPrivate attribute is not correctly updated", updatedIsPrivate, updatedAccount.getContainerById(updatedContainerId).isPrivate()); } }

Target:
public void testUpdateContainerInAccount() throws JSONException { Account account = Account.fromJson(accountJsonLike); AccountBuilder accountBuilder = new AccountBuilder(account); for (int i = 0; i < CONTAINER_COUNT; i++) { Container container = account.getContainerById(refContainerIds.get(i)); accountBuilder.removeContainer(container); ContainerBuilder containerBuilder = new ContainerBuilder(container); short updatedContainerId = (short) (-1 * (container.getId())); String updatedContainerName = container.getName() + "-updated"; Container.ContainerStatus updatedContainerStatus = Container.ContainerStatus.INACTIVE; String updatedContainerDescription = container.getDescription() + "--updated"; boolean updatedIsPrivate = !container.isPrivate(); containerBuilder.setId(updatedContainerId) .setName(updatedContainerName) .setStatus(updatedContainerStatus) .setDescription(updatedContainerDescription) .setIsPrivate(updatedIsPrivate); Container updatedContainer = containerBuilder.build(); accountBuilder.addOrUpdateContainer(updatedContainer); Account updatedAccount = accountBuilder.build(); assertEquals("container id is not correctly updated", updatedContainerId, updatedAccount.getContainerById(updatedContainerId).getId()); assertEquals("container name is not correctly updated", updatedContainerName, updatedAccount.getContainerById(updatedContainerId).getName()); assertEquals("container status is not correctly updated", updatedContainerStatus, updatedAccount.getContainerById(updatedContainerId).getStatus()); assertEquals("container description is not correctly updated", updatedContainerDescription, updatedAccount.getContainerById(updatedContainerId).getDescription()); assertEquals("container isPrivate attribute is not correctly updated", updatedIsPrivate, updatedAccount.getContainerById(updatedContainerId).isPrivate()); } }