package com.nosoftskills.predcomposer.prediction;

import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
import com.nosoftskills.predcomposer.model.Prediction;
import org.jglue.cdiunit.ActivatedAlternatives;
import org.jglue.cdiunit.CdiRunner;
import org.jglue.cdiunit.ContextController;
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.inject.Inject;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;


/**
 * @author Ivan St. Ivanov
 */
@RunWith(CdiRunner.class)
@ActivatedAlternatives({
        PredictionsServiceAlternative.class, UserContextAlternative.class
})
public class ViewUserPredictionsBeanTest {

    @Inject
    private ContextController contextController;

    @Inject
    private ViewUserPredictionsBean bean;

    @Test
    public void shouldLoadUserPredictionsUponStartup() throws Exception {
        contextController.openRequest();
        Map<Long, Prediction> userPredictions = bean.getUserPredictions();
        assertNotNull(userPredictions);
        assertEquals(2, userPredictions.size());
        contextController.closeRequest();
        contextController.closeSession();
    }
}

@@ -363,33 +363,30 @@
 cdiunit.
-ContextController
+InRequestScope
 ;%0Aimport
@@ -791,70 +791,8 @@
  %7B%0A%0A
-    @Inject%0A    private ContextController contextController;%0A%0A
     
@@ -852,16 +852,36 @@
   @Test%0A
+    @InRequestScope%0A
     publ
@@ -950,49 +950,8 @@
 n %7B%0A
-        contextController.openRequest();%0A
     
@@ -1061,16 +1061,16 @@
 tions);%0A
+
         
@@ -1114,92 +1114,8 @@
 ));%0A
-        contextController.closeRequest();%0A        contextController.closeSession();%0A
     

Improve CDI test