SessionZooKeeperClient { public void writeApplicationId(ApplicationId id) { if ( ! id.tenant().equals(tenantName)) throw new IllegalArgumentException("Cannot write application id '" + id + "' for tenant '" + tenantName + "'"); configCurator.putData(applicationIdPath(), id.serializedForm()); } SessionZooKeeperClient(Curator curator,
                                  ConfigCurator configCurator,
                                  TenantName tenantName,
                                  long sessionId,
                                  String serverId); void writeStatus(Session.Status sessionStatus); Session.Status readStatus(); Curator.CompletionWaiter createActiveWaiter(); CuratorTransaction deleteTransaction(); ApplicationPackage loadApplicationPackage(); ConfigDefinitionRepo getUserConfigDefinitions(); void writeApplicationId(ApplicationId id); Optional<ApplicationId> readApplicationId(); void writeVespaVersion(Version version); Version readVespaVersion(); Optional<DockerImage> readDockerImageRepository(); void writeDockerImageRepository(Optional<DockerImage> dockerImageRepository); Instant readCreateTime(); ZooKeeperDeployer createDeployer(DeployLogger logger); Transaction createWriteStatusTransaction(Session.Status status); void writeAthenzDomain(Optional<AthenzDomain> athenzDomain); Optional<AthenzDomain> readAthenzDomain(); void writeQuota(Optional<Quota> maybeQuota); Optional<Quota> readQuota(); void createNewSession(Instant createTime);  }
@Test public void require_that_application_id_is_written_to_zk() { ApplicationId id = new ApplicationId.Builder() .tenant(tenantName) .applicationName("foo") .instanceName("bim") .build(); int sessionId = 3; SessionZooKeeperClient zkc = createSessionZKClient(sessionId); zkc.writeApplicationId(id); String path = sessionPath(sessionId).append(SessionZooKeeperClient.APPLICATION_ID_PATH).getAbsolute(); assertTrue(configCurator.exists(path)); assertThat(configCurator.getData(path), is(id.serializedForm())); }
@Test public void require_that_wrong_application_gives_exception() { ApplicationId id = new ApplicationId.Builder() .tenant("someOtherTenant") .applicationName("foo") .instanceName("bim") .build(); int sessionId = 3; SessionZooKeeperClient zkc = createSessionZKClient(sessionId); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Cannot write application id 'someOtherTenant.foo.bim' for tenant 'default'"); zkc.writeApplicationId(id); }