ControllerUnitTestMixin (Grails 3.1.7)
Date: 2016-05-19

Package: grails.test.mixin.web

## [Groovy] Class ControllerUnitTestMixin

- grails.test.mixin.web.ControllerUnitTestMixin

- Applied to a unit test to test controllers.

  Authors:
    Graeme Rocher
  Since:
    2.0

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `static java.lang.String` | `ALL_CONTENT_TYPE`
    `static java.lang.String` | `ATOM_XML_CONTENT_TYPE`
    `static java.lang.String` | `FORM_CONTENT_TYPE`
    `static java.lang.String` | `HAL_JSON_CONTENT_TYPE`
    `static java.lang.String` | `HAL_XML_CONTENT_TYPE`
    `static java.lang.String` | `HTML_CONTENT_TYPE`
    `static java.lang.String` | `JSON_CONTENT_TYPE`
    `static java.lang.String` | `MULTIPART_FORM_CONTENT_TYPE`
    `static java.lang.String` | `TEXT_JSON_CONTENT_TYPE`
    `static java.lang.String` | `TEXT_XML_CONTENT_TYPE`
    `static java.lang.String` | `XHTML_CONTENT_TYPE`
    `static java.lang.String` | `XML_CONTENT_TYPE`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `ControllerUnitTestMixin (java.util.Set<java.lang.String> features)`
    `ControllerUnitTestMixin ()`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `protected GrailsClass` | `createAndEnhance(java.lang.Class controllerClass)`
    `FlashScope` | `getFlash()` The Grails 'flash' object @return
    `java.util.Map<java.lang.String, java.lang.String>` | `getGroovyPages()`
    `java.util.Map` | `getModel()` @return The model of the current controller
    `GrailsParameterMap` | `getParams()` The Grails 'params' object which is an instance of GrailsParameterMap
    `GrailsMockHttpServletRequest` | `getRequest()`
    `GrailsMockHttpServletResponse` | `getResponse()`
    `org.springframework.mock.web.MockServletContext` | `getServletContext()`
    `org.springframework.mock.web.MockHttpSession` | `getSession()` The org.springframework.mock.web.MockHttpSession instance
    `int` | `getStatus()` @return The status code of the response
    `java.lang.String` | `getView()` @return The view of the current controller
    `java.util.Map<java.lang.String, java.lang.String>` | `getViews()`
    `GrailsWebRequest` | `getWebRequest()`
    `java.lang.Object` | `mockCommandObject(java.lang.Class commandClass)` Mocks a Grails command object providing the necessary validation behavior and returning the instance
    `T` | `mockController(java.lang.Class<T> controllerClass)` Mocks a Grails controller class, providing the needed behavior and defining it in the ApplicationContext
    `T` | `testFor(java.lang.Class<T> controllerClass)` Signifies that the given controller class is the class under test

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class GrailsUnitTestMixin` | `defineBeans, getApplicationContext, getConfig, getGrailsApplication, getMainContext, getMessageSource, mockCodec, shouldFail, shouldFail`
    `class TestMixinRuntimeSupport` | `getFeatures, getRuntime, setRuntime, setTestClass`
    `class groovy.lang.GroovyObjectSupport` | `groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll()`

- - ### Property Detail

    - #### static java.lang.String ALL_CONTENT_TYPE

    - #### static java.lang.String ATOM_XML_CONTENT_TYPE

    - #### static java.lang.String FORM_CONTENT_TYPE

    - #### static java.lang.String HAL_JSON_CONTENT_TYPE

    - #### static java.lang.String HAL_XML_CONTENT_TYPE

    - #### static java.lang.String HTML_CONTENT_TYPE

    - #### static java.lang.String JSON_CONTENT_TYPE

    - #### static java.lang.String MULTIPART_FORM_CONTENT_TYPE

    - #### static java.lang.String TEXT_JSON_CONTENT_TYPE

    - #### static java.lang.String TEXT_XML_CONTENT_TYPE

    - #### static java.lang.String XHTML_CONTENT_TYPE

    - #### static java.lang.String XML_CONTENT_TYPE

  - ### Constructor Detail

    - #### ControllerUnitTestMixin(java.util.Set<java.lang.String> features)

    - #### ControllerUnitTestMixin()

  - ### Method Detail

    - #### protected GrailsClass createAndEnhance(java.lang.Class controllerClass)

    - #### FlashScope getFlash()

      The Grails 'flash' object

      Returns:

    - #### java.util.Map<java.lang.String, java.lang.String> getGroovyPages()

    - #### @groovy.transform.CompileStatic(TypeCheckingMode.SKIP) java.util.Map getModel()

      Returns:
        The model of the current controller

    - #### GrailsParameterMap getParams()

      The Grails 'params' object which is an instance of GrailsParameterMap

    - #### GrailsMockHttpServletRequest getRequest()

    - #### GrailsMockHttpServletResponse getResponse()

    - #### org.springframework.mock.web.MockServletContext getServletContext()

    - #### org.springframework.mock.web.MockHttpSession getSession()

      The org.springframework.mock.web.MockHttpSession instance

    - #### int getStatus()

      Returns:
        The status code of the response

    - #### @groovy.transform.CompileStatic(TypeCheckingMode.SKIP) java.lang.String getView()

      Returns:
        The view of the current controller

    - #### java.util.Map<java.lang.String, java.lang.String> getViews()

    - #### GrailsWebRequest getWebRequest()

    - #### java.lang.Object mockCommandObject(java.lang.Class commandClass)

      Mocks a Grails command object providing the necessary validation behavior and returning the instance

      Parameters:
        `commandClass` - The command class
      Returns:
        The instance

    - #### @groovy.transform.CompileStatic(TypeCheckingMode.SKIP) T mockController(java.lang.Class<T> controllerClass)

      Mocks a Grails controller class, providing the needed behavior and defining it in the ApplicationContext

      Parameters:
        `controllerClass` - The controller class
      Returns:
        An instance of the controller

    - #### T testFor(java.lang.Class<T> controllerClass)

      Signifies that the given controller class is the class under test

      Parameters:
        `controllerClass` - The controller class
      Returns:
        an instance of the controller