@Test @Sql(scripts = { "/sql/clearTokens.sql", "/sql/createTokens.sql" }) public void test_should_retrieve_otp_for_given_token_number_and_identity() { ValidateRequest validateRequest = ValidateRequest.builder().otp("token2").identity("identity2") .tenantId("tenant2").build(); final Tokens actualTokens = tokenRepository.findByNumberAndIdentityAndTenantId(validateRequest); assertNotNull(actualTokens); final Token firstToken = actualTokens.getTokens().get(0); assertEquals("id2", firstToken.getUuid()); assertEquals("identity2", firstToken.getIdentity()); assertEquals("tenant2", firstToken.getTenantId()); assertEquals("token2", firstToken.getNumber()); assertEquals(Long.valueOf(200), firstToken.getTimeToLiveInSeconds()); assertFalse(firstToken.isValidated()); assertNotNull(firstToken.getCreatedDate()); }
public Tokens findByNumberAndIdentityAndTenantId(ValidateRequest request) { final Map<String, Object> tokenInputs = new HashMap<String, Object>(); tokenInputs.put("tokenNumber", request.getOtp()); tokenInputs.put("tokenIdentity", request.getIdentity()); tokenInputs.put("tenantId", request.getTenantId()); List<Token> domainTokens = namedParameterJdbcTemplate.query(GETTOKENS_BY_NUMBER_IDENTITY_TENANT, tokenInputs, new TokenRowMapper()); return new Tokens(domainTokens); }
TokenRepository { public Tokens findByNumberAndIdentityAndTenantId(ValidateRequest request) { final Map<String, Object> tokenInputs = new HashMap<String, Object>(); tokenInputs.put("tokenNumber", request.getOtp()); tokenInputs.put("tokenIdentity", request.getIdentity()); tokenInputs.put("tenantId", request.getTenantId()); List<Token> domainTokens = namedParameterJdbcTemplate.query(GETTOKENS_BY_NUMBER_IDENTITY_TENANT, tokenInputs, new TokenRowMapper()); return new Tokens(domainTokens); } }
TokenRepository { public Tokens findByNumberAndIdentityAndTenantId(ValidateRequest request) { final Map<String, Object> tokenInputs = new HashMap<String, Object>(); tokenInputs.put("tokenNumber", request.getOtp()); tokenInputs.put("tokenIdentity", request.getIdentity()); tokenInputs.put("tenantId", request.getTenantId()); List<Token> domainTokens = namedParameterJdbcTemplate.query(GETTOKENS_BY_NUMBER_IDENTITY_TENANT, tokenInputs, new TokenRowMapper()); return new Tokens(domainTokens); } TokenRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
TokenRepository { public Tokens findByNumberAndIdentityAndTenantId(ValidateRequest request) { final Map<String, Object> tokenInputs = new HashMap<String, Object>(); tokenInputs.put("tokenNumber", request.getOtp()); tokenInputs.put("tokenIdentity", request.getIdentity()); tokenInputs.put("tenantId", request.getTenantId()); List<Token> domainTokens = namedParameterJdbcTemplate.query(GETTOKENS_BY_NUMBER_IDENTITY_TENANT, tokenInputs, new TokenRowMapper()); return new Tokens(domainTokens); } 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 Tokens findByNumberAndIdentityAndTenantId(ValidateRequest request) { final Map<String, Object> tokenInputs = new HashMap<String, Object>(); tokenInputs.put("tokenNumber", request.getOtp()); tokenInputs.put("tokenIdentity", request.getIdentity()); tokenInputs.put("tenantId", request.getTenantId()); List<Token> domainTokens = namedParameterJdbcTemplate.query(GETTOKENS_BY_NUMBER_IDENTITY_TENANT, tokenInputs, new TokenRowMapper()); return new Tokens(domainTokens); } TokenRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); Token save(Token token); Token markAsValidated(Token token); Tokens findByNumberAndIdentityAndTenantId(ValidateRequest request); Tokens findByNumberAndIdentityAndTenantIdLike(ValidateRequest request); Token findBy(TokenSearchCriteria searchCriteria);  }