@Test public void getAllRegistrationsTest() throws URISyntaxException, RegistrationPersistenceException { RegisterContext registerContext = createRegisterContextTemperature(); registerContext.setRegistrationId("12345"); Registration registration = new Registration(Instant.now().plus(1, ChronoUnit.DAYS), registerContext); registrationsRepository.saveRegistration(registration); RegisterContext registerContext2 = createRegisterContextTemperature(); registerContext2.setRegistrationId("12346"); Registration registration2 = new Registration(Instant.now().plus(1, ChronoUnit.DAYS), registerContext2); registrationsRepository.saveRegistration(registration2); RegisterContext registerContext3 = createRegisterContextTemperature(); registerContext3.setRegistrationId("12347"); Registration registration3 = new Registration(Instant.now().plus(1, ChronoUnit.DAYS), registerContext3); registrationsRepository.saveRegistration(registration3); Assert.assertEquals(3, registrationsRepository.getAllRegistrations().size()); }
public Map<String, Registration> getAllRegistrations() throws RegistrationPersistenceException { Map<String, Registration> registrations = new ConcurrentHashMap<>(); try { List<Registration> registrationList = jdbcTemplate.query("select id, expirationDate, registerContext from t_registrations", (ResultSet rs, int rowNum) -> { Registration registration = new Registration(); try { registration.setExpirationDate(Instant.parse(rs.getString("expirationDate"))); registration.setRegisterContext(mapper.readValue(rs.getString("registerContext"), RegisterContext.class)); } catch (IOException e) { throw new SQLException(e); } return registration; }); registrationList.forEach(registration -> registrations.put(registration.getRegisterContext().getRegistrationId(), registration)); } catch (DataAccessException e) { throw new RegistrationPersistenceException(e); } return registrations; }
RegistrationsRepository { public Map<String, Registration> getAllRegistrations() throws RegistrationPersistenceException { Map<String, Registration> registrations = new ConcurrentHashMap<>(); try { List<Registration> registrationList = jdbcTemplate.query("select id, expirationDate, registerContext from t_registrations", (ResultSet rs, int rowNum) -> { Registration registration = new Registration(); try { registration.setExpirationDate(Instant.parse(rs.getString("expirationDate"))); registration.setRegisterContext(mapper.readValue(rs.getString("registerContext"), RegisterContext.class)); } catch (IOException e) { throw new SQLException(e); } return registration; }); registrationList.forEach(registration -> registrations.put(registration.getRegisterContext().getRegistrationId(), registration)); } catch (DataAccessException e) { throw new RegistrationPersistenceException(e); } return registrations; } }
RegistrationsRepository { public Map<String, Registration> getAllRegistrations() throws RegistrationPersistenceException { Map<String, Registration> registrations = new ConcurrentHashMap<>(); try { List<Registration> registrationList = jdbcTemplate.query("select id, expirationDate, registerContext from t_registrations", (ResultSet rs, int rowNum) -> { Registration registration = new Registration(); try { registration.setExpirationDate(Instant.parse(rs.getString("expirationDate"))); registration.setRegisterContext(mapper.readValue(rs.getString("registerContext"), RegisterContext.class)); } catch (IOException e) { throw new SQLException(e); } return registration; }); registrationList.forEach(registration -> registrations.put(registration.getRegisterContext().getRegistrationId(), registration)); } catch (DataAccessException e) { throw new RegistrationPersistenceException(e); } return registrations; }  }
RegistrationsRepository { public Map<String, Registration> getAllRegistrations() throws RegistrationPersistenceException { Map<String, Registration> registrations = new ConcurrentHashMap<>(); try { List<Registration> registrationList = jdbcTemplate.query("select id, expirationDate, registerContext from t_registrations", (ResultSet rs, int rowNum) -> { Registration registration = new Registration(); try { registration.setExpirationDate(Instant.parse(rs.getString("expirationDate"))); registration.setRegisterContext(mapper.readValue(rs.getString("registerContext"), RegisterContext.class)); } catch (IOException e) { throw new SQLException(e); } return registration; }); registrationList.forEach(registration -> registrations.put(registration.getRegisterContext().getRegistrationId(), registration)); } catch (DataAccessException e) { throw new RegistrationPersistenceException(e); } return registrations; }  void saveRegistration(Registration registration); void updateRegistration(Registration registration); Map<String, Registration> getAllRegistrations(); Registration getRegistration(String registrationId); void removeRegistration(String registrationId); }
RegistrationsRepository { public Map<String, Registration> getAllRegistrations() throws RegistrationPersistenceException { Map<String, Registration> registrations = new ConcurrentHashMap<>(); try { List<Registration> registrationList = jdbcTemplate.query("select id, expirationDate, registerContext from t_registrations", (ResultSet rs, int rowNum) -> { Registration registration = new Registration(); try { registration.setExpirationDate(Instant.parse(rs.getString("expirationDate"))); registration.setRegisterContext(mapper.readValue(rs.getString("registerContext"), RegisterContext.class)); } catch (IOException e) { throw new SQLException(e); } return registration; }); registrationList.forEach(registration -> registrations.put(registration.getRegisterContext().getRegistrationId(), registration)); } catch (DataAccessException e) { throw new RegistrationPersistenceException(e); } return registrations; }  void saveRegistration(Registration registration); void updateRegistration(Registration registration); Map<String, Registration> getAllRegistrations(); Registration getRegistration(String registrationId); void removeRegistration(String registrationId);  }