PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 8ms RepoModel.GetById 32ms app.codeStats 0ms

/test/unit/inventario/AlmacenControllerTests.groovy

http://github.com/jdmr/mateo
Groovy | 159 lines | 87 code | 65 blank | 7 comment | 31 complexity | 465ba9a176cfe7de401290e1b3117d39 MD5 | raw file
  1package inventario
  2
  3
  4
  5import org.junit.*
  6import grails.test.mixin.*
  7
  8
  9@TestFor(AlmacenController)
 10@Mock(Almacen)
 11class AlmacenControllerTests {
 12
 13
 14    @Test
 15    void testIndex() {
 16        controller.index()
 17        assert "/almacen/list" == response.redirectedUrl
 18    }
 19
 20    @Test
 21    void testList() {
 22
 23        def model = controller.list()
 24
 25        assert model.almacenInstanceList.size() == 0
 26        assert model.almacenInstanceTotal == 0
 27
 28    }
 29
 30    @Test
 31    void testCreate() {
 32       def model = controller.create()
 33
 34       assert model.almacenInstance != null
 35
 36
 37    }
 38
 39    @Test
 40    void testSave() {
 41        controller.save()
 42
 43        assert model.almacenInstance != null
 44        assert view == '/almacen/create'
 45
 46        // TODO: Populate valid properties
 47
 48        controller.save()
 49
 50        assert response.redirectedUrl == '/almacen/show/1'
 51        assert controller.flash.message != null
 52        assert Almacen.count() == 1
 53    }
 54
 55
 56    @Test
 57    void testShow() {
 58        controller.show()
 59
 60        assert flash.message != null
 61        assert response.redirectedUrl == '/almacen/list'
 62
 63
 64        def almacen = new Almacen()
 65
 66        // TODO: populate domain properties
 67
 68        assert almacen.save() != null
 69
 70        params.id = almacen.id
 71
 72        def model = controller.show()
 73
 74        assert model.almacenInstance == almacen
 75    }
 76
 77    @Test
 78    void testEdit() {
 79        controller.edit()
 80
 81        assert flash.message != null
 82        assert response.redirectedUrl == '/almacen/list'
 83
 84
 85        def almacen = new Almacen()
 86
 87        // TODO: populate valid domain properties
 88
 89        assert almacen.save() != null
 90
 91        params.id = almacen.id
 92
 93        def model = controller.edit()
 94
 95        assert model.almacenInstance == almacen
 96    }
 97
 98    @Test
 99    void testUpdate() {
100
101        controller.update()
102
103        assert flash.message != null
104        assert response.redirectedUrl == '/almacen/list'
105
106        response.reset()
107
108
109        def almacen = new Almacen()
110
111        // TODO: populate valid domain properties
112
113        assert almacen.save() != null
114
115        // test invalid parameters in update
116        params.id = almacen.id
117
118        controller.update()
119
120        assert view == "/almacen/edit"
121        assert model.almacenInstance != null
122
123        almacen.clearErrors()
124
125        // TODO: populate valid domain form parameter
126        controller.update()
127
128        assert response.redirectedUrl == "/almacen/show/$almacen.id"
129        assert flash.message != null
130    }
131
132    @Test
133    void testDelete() {
134        controller.delete()
135
136        assert flash.message != null
137        assert response.redirectedUrl == '/almacen/list'
138
139        response.reset()
140
141        def almacen = new Almacen()
142
143        // TODO: populate valid domain properties
144        assert almacen.save() != null
145        assert Almacen.count() == 1
146
147        params.id = almacen.id
148
149        controller.delete()
150
151        assert Almacen.count() == 0
152        assert Almacen.get(almacen.id) == null
153        assert response.redirectedUrl == '/almacen/list'
154
155
156    }
157
158
159}