public Subscriber convert(String login) {
   Subscriber subscriber = subscriberService.loadByUsername(login);
   if (subscriber == null) {
     try {
       long id = Long.parseLong(login.trim());
       subscriber = subscriberRepository.findOne(id);
     } catch (Exception e) {
       logger.error("An error occured on transformi String (" + login + ") to long", e);
     }
   }
   return subscriber;
 }
  /**
   * Test case for stanard subscription flow : - submitting data - looking for user by username -
   * looking for non confirmed user by his id - confirming subscriber
   */
  @Test
  public void subscribe() {
    System.out.println("Testing subscribe() : subscription");

    AnonymousAuthenticationToken anonymousUser =
        new AnonymousAuthenticationToken(
            "anonymous",
            "anonymous",
            new ArrayList(Arrays.asList(new GrantedAuthorityImpl("ROLE_ANONYMOUS"))));
    SecurityContextHolder.getContext().setAuthentication(anonymousUser);

    Subscriber subscriber = new Subscriber();
    subscriber.setLogin("testNonConfirmed");
    subscriber.setEmail("*****@*****.**");
    subscriber.setConfirmed(Subscriber.IS_NOT_CONFIRMED);
    subscriber.setBlacklisted(Subscriber.IS_NOT_BLACKLISTED);

    try {
      subscriber = subscriberService.save(subscriber);
    } catch (Exception e) {
      System.out.println("An error occured on saving subscriber : " + e.getMessage());
    }
    System.out.println("After saving " + subscriber);
    Assert.assertNotNull("Subscriber is null", subscriber);

    Subscriber loadedSubscriber = subscriberService.loadByUsername(subscriber.getLogin());
    Assert.assertNotNull("Subscriber was not loaded correctly", loadedSubscriber);

    Subscriber notConfirmedSubscriber = subscriberService.findNonConfirmedById(subscriber.getId());
    Assert.assertNotNull(
        "Not confirmed subscriber was not loaded correctly", notConfirmedSubscriber);

    Subscriber confirmedSubscriber = subscriberService.confirm(subscriber);
    Assert.assertNotNull("Confirmed subscriber is null", confirmedSubscriber);

    System.out.println("Testing subscribe() : subscription");
  }
 @Scheduled(fixedRate = 7200000) // called every 2 hours
 public void reviveSubscribers() {
   logger.info("=========> Revive non actived subscribers");
   subscriberService.revive(5);
   logger.info("========> Revive send end");
 }