@Test public void createByUser_max_5_zone() throws Exception { accountDao.changeTotalVotedDebate(citizen.getAccountId(), 60, 0); service.createByUser("aaa1", "this is aaa1", citizen); service.createByUser("aaa2", "this is aaa2", citizen); service.createByUser("aaa3", "this is aaa3", citizen); service.createByUser("aaa4", "this is aaa4", citizen); service.createByUser("aaa5", "this is aaa5", citizen); try { service.createByUser("aaa6", "this is aaa6", citizen); fail("CreditNotEnoughException expected"); } catch (CreditNotEnoughException expected) { } }
@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);  }