package com.nosoftskills.predcomposer.prediction;

import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
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 static com.nosoftskills.predcomposer.common.TestData.game2;
import static org.junit.Assert.assertEquals;


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

    @Inject
    private ContextController contextController;

    @Inject
    private ViewGamePredictionsBean bean;

    @Test
    public void shouldLoadGamePredictionsUponRequest() throws Exception {
        contextController.openRequest();
        bean.showGamePredictions(game2);
        assertEquals(game2, bean.getGame());
        assertEquals(2, bean.getPredictions().size());
        contextController.closeRequest();
        contextController.closeSession();
    }

}

@@ -308,33 +308,30 @@
 cdiunit.
-ContextController
+InRequestScope
 ;%0Aimport
@@ -735,70 +735,8 @@
  %7B%0A%0A
-    @Inject%0A    private ContextController contextController;%0A%0A
     
@@ -796,16 +796,36 @@
   @Test%0A
+    @InRequestScope%0A
     publ
@@ -894,49 +894,8 @@
 n %7B%0A
-        contextController.openRequest();%0A
     
@@ -972,24 +972,24 @@
 getGame());%0A
+
         asse
@@ -1035,92 +1035,8 @@
 ));%0A
-        contextController.closeRequest();%0A        contextController.closeSession();%0A
     

Improve game prediction bean test