PageRenderTime 20ms CodeModel.GetById 15ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://sigma-h.googlecode.com/
Java | 86 lines | 39 code | 26 blank | 21 comment | 0 complexity | 65df264b25ca51cdc635196abc5b95ce 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.Ignore;
10import org.junit.Test;
11import org.sigmah.client.mock.DispatcherStub;
12import org.sigmah.client.mock.DummyData;
13import org.sigmah.client.mock.MockEventBus;
14import org.sigmah.client.page.common.toolbar.UIActions;
15import org.sigmah.client.page.entry.editor.mock.MockSiteForm;
16import org.sigmah.shared.dto.SchemaDTO;
17
18import com.google.gwt.junit.GWTMockUtilities;
19
20/**
21 * @author Alex Bertram (akbertram@gmail.com)
22 */
23public class SiteFormTest {
24
25
26	@Ignore("needs to be converted to GWT test")
27    @Test
28    public void testAdminInit() {
29
30    	GWTMockUtilities.disarm();
31    	
32        // Test data
33        SchemaDTO schema = DummyData.PEAR();
34
35        // Collaborator: EventBus
36        MockEventBus eventBus = new MockEventBus();
37
38        // Collaborator: Command Service
39        DispatcherStub service = new DispatcherStub();
40
41        // Collaborator: View
42        MockSiteForm form = new MockSiteForm();
43
44        // CLASS UNDER TEST
45        SiteForm presenter = new SiteForm(service, schema.getActivityById(91));
46        presenter.setSite(DummyData.PEAR_Sites().get(4));
47
48        // Verify that the admin field set is intialzed
49        Assert.assertEquals("province is set", "Nord Kivu", form.adminFieldSet.getValue(1).getName());
50
51        // Verify the save button is disabled
52        Assert.assertFalse("save action is disabled", form.isEnabled(UIActions.save));
53
54        // Verify that a change to the admin field set enables the save button
55        form.adminFieldSet.setValueAndFire(1, DummyData.SudKivu);
56
57        Assert.assertTrue("save button is now enabled", form.isEnabled(UIActions.save));
58
59    }
60
61	@Ignore("needs to be converted to GWT test")
62    @Test
63    public void testMapBoundsSetOnInit() {
64        // Test data
65        SchemaDTO schema = DummyData.PEAR();
66
67        // Collaborator: EventBus
68        MockEventBus eventBus = new MockEventBus();
69
70        // Collaborator: Command Service
71        DispatcherStub service = new DispatcherStub();
72
73        // Collaborator: View
74        MockSiteForm form = new MockSiteForm();
75
76        // CLASS UNDER TEST
77        SiteFormPresenter presenter = new SiteFormPresenter(eventBus,service, schema.getActivityById(91), form);
78        presenter.setSite(DummyData.PEAR_Sites().get(4));
79
80        // Verify that the map view has been centered on the admin bounds
81        Assert.assertTrue(form.mapView.getMapView().contains(DummyData.Beni.getBounds()));
82
83
84    }
85
86}