@Test @Sql(scripts = { "/sql/clearTokens.sql", "/sql/createTokens.sql" }) public void test_should_return_null_when_token_not_present_for_given_id() { TokenSearchCriteria searchCriteria = new TokenSearchCriteria("id5", "tenant6"); final Token token = tokenRepository.findBy(searchCriteria); assertNull(token); }
public Token findBy(TokenSearchCriteria searchCriteria) { Token token = null; final Map<String, Object> tokenInputs = new HashMap<String, Object>(); tokenInputs.put("id", searchCriteria.getUuid()); List<Token> domainTokens = namedParameterJdbcTemplate.query(GETTOKEN_BYID, tokenInputs, new TokenRowMapper()); if (domainTokens != null && !domainTokens.isEmpty()) { token = domainTokens.get(0); } return token; }
TokenRepository { public Token findBy(TokenSearchCriteria searchCriteria) { Token token = null; final Map<String, Object> tokenInputs = new HashMap<String, Object>(); tokenInputs.put("id", searchCriteria.getUuid()); List<Token> domainTokens = namedParameterJdbcTemplate.query(GETTOKEN_BYID, tokenInputs, new TokenRowMapper()); if (domainTokens != null && !domainTokens.isEmpty()) { token = domainTokens.get(0); } return token; } }
TokenRepository { public Token findBy(TokenSearchCriteria searchCriteria) { Token token = null; final Map<String, Object> tokenInputs = new HashMap<String, Object>(); tokenInputs.put("id", searchCriteria.getUuid()); List<Token> domainTokens = namedParameterJdbcTemplate.query(GETTOKEN_BYID, tokenInputs, new TokenRowMapper()); if (domainTokens != null && !domainTokens.isEmpty()) { token = domainTokens.get(0); } return token; } TokenRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
TokenRepository { public Token findBy(TokenSearchCriteria searchCriteria) { Token token = null; final Map<String, Object> tokenInputs = new HashMap<String, Object>(); tokenInputs.put("id", searchCriteria.getUuid()); List<Token> domainTokens = namedParameterJdbcTemplate.query(GETTOKEN_BYID, tokenInputs, new TokenRowMapper()); if (domainTokens != null && !domainTokens.isEmpty()) { token = domainTokens.get(0); } return token; } TokenRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); Token save(Token token); Token markAsValidated(Token token); Tokens findByNumberAndIdentityAndTenantId(ValidateRequest request); Tokens findByNumberAndIdentityAndTenantIdLike(ValidateRequest request); Token findBy(TokenSearchCriteria searchCriteria); }
TokenRepository { public Token findBy(TokenSearchCriteria searchCriteria) { Token token = null; final Map<String, Object> tokenInputs = new HashMap<String, Object>(); tokenInputs.put("id", searchCriteria.getUuid()); List<Token> domainTokens = namedParameterJdbcTemplate.query(GETTOKEN_BYID, tokenInputs, new TokenRowMapper()); if (domainTokens != null && !domainTokens.isEmpty()) { token = domainTokens.get(0); } return token; } TokenRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); Token save(Token token); Token markAsValidated(Token token); Tokens findByNumberAndIdentityAndTenantId(ValidateRequest request); Tokens findByNumberAndIdentityAndTenantIdLike(ValidateRequest request); Token findBy(TokenSearchCriteria searchCriteria);  }