package com.sanction.thunder.authentication;

import com.google.common.base.Optional;
import com.google.common.collect.Lists;

import io.dropwizard.auth.AuthenticationException;
import io.dropwizard.auth.basic.BasicCredentials;

import java.util.List;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class ThunderAuthenticatorTest {
  private final Key key = new Key("application", "secret");
  private final List<Key> keys = Lists.newArrayList(key);
  private final ThunderAuthenticator authenticator = new ThunderAuthenticator(keys);

  @Test
  public void testAuthenticateWithValidCredentials() {
    BasicCredentials credentials = new BasicCredentials("application", "secret");

    Optional<Key> result = Optional.absent();
    try {
      result =  authenticator.authenticate(credentials);
    } catch (AuthenticationException e) {
      // This shouldn't happen, so fail the test.
      assertTrue(false);
    }

    assertTrue(result.isPresent());
    assertEquals(key, result.get());
  }

  @Test
  public void testAuthenticateWithInvalidCredentials() {
    BasicCredentials credentials = new BasicCredentials("invalidApplication", "secret");

    Optional<Key> result = Optional.absent();
    try {
      result =  authenticator.authenticate(credentials);
    } catch (AuthenticationException e) {
      // This shouldn't happen, so fail the test.
      assertTrue(false);
    }

    assertFalse(result.isPresent());
  }

}

@@ -401,16 +401,53 @@
 ertTrue;
+%0Aimport static org.junit.Assert.fail;
 %0A%0Apublic
@@ -1041,32 +1041,21 @@
 .%0A      
-assertTrue(false
+fail(
 );%0A    %7D
@@ -1504,24 +1504,13 @@
     
-assertTrue(false
+fail(
 );%0A 

Use fail() method in tests