summaryrefslogtreecommitdiffstats
blob: f270976c97dc5eb2210956c85b38cff9b807224d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * Copyright (c) 2012-2014 Isode Limited, London, England.
 * All rights reserved.
 */
/*
 * Copyright (c) 2010 Remko Tronçon
 * All rights reserved.
 */

package com.isode.stroke.elements;

import static org.junit.Assert.assertEquals;

import org.junit.BeforeClass;
import org.junit.Test;

import com.isode.stroke.elements.FormField.Type;

public class FormTest {
    @BeforeClass
    public static void init() throws Exception {
    }

    @Test
    public void testGetFormType() {
        Form form = new Form();

        form.addField(new FormField(Type.FIXED_TYPE, "Foo"));

        FormField field = new FormField(Type.HIDDEN_TYPE, "jabber:bot");
        field.setName("FORM_TYPE");
        form.addField(field);

        form.addField(new FormField(Type.FIXED_TYPE, "Bar"));

        assertEquals("jabber:bot", form.getFormType());
    }

    @Test
    public void testGetFormType_InvalidFormType() {
        Form form = new Form();

        FormField field = new FormField(Type.FIXED_TYPE, "jabber:bot");
        field.setName("FORM_TYPE");
        form.addField(field);

        assertEquals("", form.getFormType());
    }

    @Test
    public void testGetFormType_NoFormType() {
        Form form = new Form();

        form.addField(new FormField(Type.FIXED_TYPE, "Foo"));

        assertEquals("", form.getFormType());
    }
}