package org.apereo.cas.web.view;

import org.apereo.cas.authentication.Authentication;
import org.apereo.cas.authentication.CoreAuthenticationTestUtils;
import org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan;
import org.apereo.cas.validation.DefaultAssertionBuilder;
import org.apereo.cas.web.view.attributes.NoOpProtocolAttributesRenderer;

import lombok.val;
import org.junit.Before;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.*;

/**
 * Unit test for {@link Cas10ResponseView} class.
 *
 * @author Scott Battaglia
 * @author Marvin S. Addison
 * @since 3.0.0
 */
public class Cas10ResponseViewTests {

    private Map<String, Object> model;

    @Before
    public void initialize() {
        this.model = new HashMap<>();
        val list = new ArrayList<Authentication>();
        list.add(CoreAuthenticationTestUtils.getAuthentication("someothername"));
        this.model.put("assertion", new DefaultAssertionBuilder(
            CoreAuthenticationTestUtils.getAuthentication()).with(list).with(
            CoreAuthenticationTestUtils.getService("TestService")).with(true).build());
    }

    @Test
    public void verifySuccessView() throws Exception {
        val response = new MockHttpServletResponse();
        val view = new Cas10ResponseView(true, null,
            null, null, new DefaultAuthenticationServiceSelectionPlan(),
            new NoOpProtocolAttributesRenderer());
        view.render(this.model, new MockHttpServletRequest(), response);
        assertEquals("yes\ntest\n", response.getContentAsString());
    }

    @Test
    public void verifyFailureView() throws Exception {
        val response = new MockHttpServletResponse();
        val view = new Cas10ResponseView(false, null,
            null, null,
            new DefaultAuthenticationServiceSelectionPlan(),
            new NoOpProtocolAttributesRenderer());
        view.render(this.model, new MockHttpServletRequest(), response);
        assertEquals("no\n\n", response.getContentAsString());
    }
}

@@ -226,16 +226,210 @@
 onPlan;%0A
+import org.apereo.cas.authentication.support.NoOpProtocolAttributeEncoder;%0Aimport org.apereo.cas.services.ServicesManager;%0Aimport org.apereo.cas.validation.AuthenticationAttributeReleasePolicy;%0A
 import o
@@ -474,24 +474,24 @@
 ionBuilder;%0A
-
 import org.a
@@ -852,16 +852,53 @@
 ssert.*;
+%0Aimport static org.mockito.Mockito.*;
 %0A%0A/**%0A *
@@ -1727,35 +1727,132 @@
 e, n
-ull,%0A            null, null
+ew NoOpProtocolAttributeEncoder(),%0A            mock(ServicesManager.class), mock(AuthenticationAttributeReleasePolicy.class)
 , ne
@@ -2269,35 +2269,132 @@
 e, n
-ull,%0A            null, null
+ew NoOpProtocolAttributeEncoder(),%0A            mock(ServicesManager.class), mock(AuthenticationAttributeReleasePolicy.class)
 ,%0A  

fix test cases for cas v1