package com.ip_b1.fii.admission;


import com.ip_b1.fii.admission.Controllers.SubmitContestation;
import com.ip_b1.fii.admission.DTO.*;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

/**
 * Created by ddpv on 5/14/2017.
 */
public class SubmitContestationTest {
    private SubmitContestation test;
    private ContestationEntity formEntity;

    @BeforeEach
    private void setUp(){
        test = new SubmitContestation();
        formEntity = new ContestationEntity();
    }
    @AfterEach
    private void tearDown(){
        formEntity = null;
        test = null;
    }

    @Test
    public void unauthorized_user() {
        AuthEntity testEntity = new AuthEntity("alexd@info.uaic.ro", "some_invalid_token");
        formEntity.setAuth(testEntity);
        ResponseEntity<SaveContestationOutEntity> testResult = test.testLogin("id", formEntity);
        Assert.assertEquals(HttpStatus.UNAUTHORIZED, testResult.getStatusCode());
    }

    @Test
    public void authorized_user() {
        AuthEntity testEntity = new AuthEntity("alexd@info.uaic.ro", "valid_token");
        formEntity.setAuth(testEntity);
        ResponseEntity<SaveContestationOutEntity> testResult = test.testLogin("id", formEntity);
        Assert.assertEquals(HttpStatus.OK, testResult.getStatusCode());
    }
}

@@ -363,16 +363,59 @@
 ity;%0D%0A%0D%0A
+import javax.xml.ws.http.HTTPException;%0D%0A%0D%0A
 /**%0D%0A * 
@@ -663,54 +663,8 @@
 );%0D%0A
-        formEntity = new ContestationEntity();
 %0D%0A  
@@ -718,34 +718,8 @@
 )%7B%0D%0A
-        formEntity = null;
 %0D%0A  
@@ -797,34 +797,118 @@
 er() %7B%0D%0A
-        AuthEntity
+%0D%0A        test = new SubmitContestation();%0D%0A        AuthEntity testEntity;%0D%0A        try %7B%0D%0A           
  testEnt
@@ -922,36 +922,36 @@
 ew AuthEntity(%22a
-lexd
+dmin
 @info.uaic.ro%22, 
@@ -955,26 +955,12 @@
 %22, %22
-some_invalid_token
+tkek
 %22);%0D
@@ -968,45 +968,8 @@
     
-    formEntity.setAuth(testEntity);%0D%0A
     
@@ -1043,39 +1043,183 @@
 tLogin(%22id%22,
- form
+new Contestation
 Entity
+()
 );%0D%0A
+            Assert.assertNotEquals(HttpStatus.OK, testResult.getStatusCode());%0D%0A%0D%0A        %7D%0D%0A        catch(HTTPException e) %7B%0D%0A    
         Asse
@@ -1259,26 +1259,17 @@
 ORIZED, 
-testResult
+e
 .getStat
@@ -1276,24 +1276,35 @@
 usCode());%0D%0A
+        %7D%0D%0A
     %7D%0D%0A%0D%0A   
@@ -1327,35 +1327,69 @@
 ic void 
-authorized_user() %7B
+test_ok() %7B%0D%0A        test = new SubmitContestation();
 %0D%0A      
@@ -1435,12 +1435,12 @@
 y(%22a
-lexd
+dmin
 @inf
@@ -1456,65 +1456,19 @@
 %22, %22
-valid_
 to
+p
 ke
-n
+k
 %22);%0D%0A
-        formEntity.setAuth(testEntity);%0D%0A
     
@@ -1546,27 +1546,40 @@
 in(%22id%22,
- form
+new Contestation
 Entity
+()
 );%0D%0A    

Update SubmitContestationTest.java