PageRenderTime 23ms CodeModel.GetById 13ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/sigmah/src/test/java/org/sigmah/client/page/entry/editor/AdminChangeTest.java

http://sigma-h.googlecode.com/
Java | 59 lines | 29 code | 17 blank | 13 comment | 0 complexity | a0708c4d5dcbf79bb7871a3b0744014e MD5 | raw file
 1/*
 2 * All Sigmah code is released under the GNU General Public License v3
 3 * See COPYRIGHT.txt and LICENSE.txt.
 4 */
 5
 6package org.sigmah.client.page.entry.editor;
 7
 8import org.junit.Assert;
 9import org.junit.Test;
10import org.sigmah.client.mock.DispatcherStub;
11import org.sigmah.client.mock.DummyData;
12import org.sigmah.client.mock.MockEventBus;
13import org.sigmah.shared.dto.AdminEntityDTO;
14import org.sigmah.shared.dto.AdminLevelDTO;
15import org.sigmah.shared.dto.SchemaDTO;
16import org.sigmah.shared.dto.SiteDTO;
17
18import java.util.Map;
19
20import static org.easymock.EasyMock.createNiceMock;
21/*
22 * @author Alex Bertram
23 */
24
25public class AdminChangeTest {
26
27
28    @Test
29    public void testChange3rdLevelAdmin() {
30
31        // collaborator: event bus
32        MockEventBus eventBus = new MockEventBus();
33
34        // collaborator: command service
35        DispatcherStub service = new DispatcherStub();
36
37        // collaborator: view
38        AdminFieldSetPresenter.View view = createNiceMock(AdminFieldSetPresenter.View.class);
39
40        // test data
41        SchemaDTO schema = DummyData.PEAR();
42        SiteDTO site = DummyData.PEAR_Sites().get(4);
43
44        // CLASS UNDER TEST
45        AdminFieldSetPresenter presenter = new AdminFieldSetPresenter(service, schema.getActivityById(91).getDatabase().getCountry(), view);
46
47        // VERIFY: changing one adminlevel works properlty
48        presenter.setSite(site);
49        presenter.onSelectionChanged(3, new AdminEntityDTO(3, 9221, "Ruizi"));
50
51        Map<String,Object> properties = presenter.getPropertyMap();
52
53        Assert.assertEquals("Nord Kivu", ((AdminEntityDTO) properties.get(AdminLevelDTO.getPropertyName(1))).getName());
54        Assert.assertEquals("Beni", ((AdminEntityDTO) properties.get(AdminLevelDTO.getPropertyName(2))).getName());
55        Assert.assertEquals("Ruizi", ((AdminEntityDTO) properties.get(AdminLevelDTO.getPropertyName(3))).getName());
56
57    }
58
59}