@Test public void createByUser() throws Exception { accountDao.changeTotalVotedDebate(citizen.getAccountId(), 10, 0); ZoneInfo zoneInfo = service.createByUser("aaa", "this is aaa", citizen); ZoneInfo loaded = zoneDao.loadZoneWithoutCache(Zone.valueOf("aaa")); assertEquals(zoneInfo, loaded); assertEquals("aaa", loaded.getName()); assertEquals("this is aaa", loaded.getAliasName()); assertEquals(Authority.CITIZEN, loaded.getVoteAuthority()); assertEquals(Authority.CITIZEN, loaded.getWriteAuthority()); assertEquals(Authority.CITIZEN, loaded.getDebateAuthority()); assertEquals(ZoneInfo.THEME_DEFAULT, loaded.getTheme()); assertFalse(loaded.isHideFromTop()); assertEquals(citizen.getAccountId(), loaded.getAdminAccountIds().get(0)); List<ZoneInfo> zones = zoneDao.listZonesByAdmin(citizen.getAccountId()); assertEquals(zoneInfo, zones.get(0)); }
@Override public ZoneInfo createByUser(String zone, String aliasName, Authorization creator) throws CreditNotEnoughException { Account account = verifyAuthority(creator).flatMap(this::verifyCredit).get(); ZoneInfo zoneInfo = ZoneInfo.createDefault(zone, aliasName, Instant.now()) .withAdmins(singletonList(account.getAccountId())); zoneDao.create(zoneInfo); return zoneInfo; }
ZoneServiceImpl implements ZoneService { @Override public ZoneInfo createByUser(String zone, String aliasName, Authorization creator) throws CreditNotEnoughException { Account account = verifyAuthority(creator).flatMap(this::verifyCredit).get(); ZoneInfo zoneInfo = ZoneInfo.createDefault(zone, aliasName, Instant.now()) .withAdmins(singletonList(account.getAccountId())); zoneDao.create(zoneInfo); return zoneInfo; } }
ZoneServiceImpl implements ZoneService { @Override public ZoneInfo createByUser(String zone, String aliasName, Authorization creator) throws CreditNotEnoughException { Account account = verifyAuthority(creator).flatMap(this::verifyCredit).get(); ZoneInfo zoneInfo = ZoneInfo.createDefault(zone, aliasName, Instant.now()) .withAdmins(singletonList(account.getAccountId())); zoneDao.create(zoneInfo); return zoneInfo; }  }
ZoneServiceImpl implements ZoneService { @Override public ZoneInfo createByUser(String zone, String aliasName, Authorization creator) throws CreditNotEnoughException { Account account = verifyAuthority(creator).flatMap(this::verifyCredit).get(); ZoneInfo zoneInfo = ZoneInfo.createDefault(zone, aliasName, Instant.now()) .withAdmins(singletonList(account.getAccountId())); zoneDao.create(zoneInfo); return zoneInfo; }  @Override ZoneInfo loadZone(Zone zone); @Override ZoneInfo createDefault(String zone, String aliasName); @Override ZoneInfo createKaif(String zone, String aliasName); @Override void updateTheme(Zone zone, String theme); @Override Map<String, List<ZoneInfo>> listZoneAtoZ(); @Override List<ZoneInfo> listRecommendZones(); @Override List<ZoneInfo> listCitizenZones(); @Override ZoneInfo createByUser(String zone, String aliasName, Authorization creator); @Override List<ZoneInfo> listAdministerZones(String username); @Override boolean isZoneAvailable(String zone); @Override boolean canCreateZone(Authorization authorization); @Override List<String> listAdministratorsWithCache(Zone zone); }
ZoneServiceImpl implements ZoneService { @Override public ZoneInfo createByUser(String zone, String aliasName, Authorization creator) throws CreditNotEnoughException { Account account = verifyAuthority(creator).flatMap(this::verifyCredit).get(); ZoneInfo zoneInfo = ZoneInfo.createDefault(zone, aliasName, Instant.now()) .withAdmins(singletonList(account.getAccountId())); zoneDao.create(zoneInfo); return zoneInfo; }  @Override ZoneInfo loadZone(Zone zone); @Override ZoneInfo createDefault(String zone, String aliasName); @Override ZoneInfo createKaif(String zone, String aliasName); @Override void updateTheme(Zone zone, String theme); @Override Map<String, List<ZoneInfo>> listZoneAtoZ(); @Override List<ZoneInfo> listRecommendZones(); @Override List<ZoneInfo> listCitizenZones(); @Override ZoneInfo createByUser(String zone, String aliasName, Authorization creator); @Override List<ZoneInfo> listAdministerZones(String username); @Override boolean isZoneAvailable(String zone); @Override boolean canCreateZone(Authorization authorization); @Override List<String> listAdministratorsWithCache(Zone zone);  }