-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeatureofinterest_test.go
80 lines (64 loc) · 1.77 KB
/
featureofinterest_test.go
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package core
import (
"encoding/json"
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
func TestSetLinks(t *testing.T) {
// arrange
foi := &FeatureOfInterest{}
foi.ID = "0"
obs1 := &Observation{}
obs2 := &Observation{}
obs := []*Observation{obs1, obs2}
foi.Observations = obs
// act
foi.SetAllLinks("http://www.nu.nl")
propertynames := foi.GetPropertyNames()
// assert
assert.NotNil(t, foi.NavSelf, "NavSelf should be filled in")
assert.True(t, len(propertynames) > 0)
}
func TestParseEntityFoi(t *testing.T) {
// arrange
foi := &FeatureOfInterest{}
foi.ID = "0"
dsjson, _ := json.Marshal(foi)
// act
foi.ParseEntity(dsjson)
// assert
assert.True(t, foi.ID == "0")
}
func TestParseEntityFoiFails(t *testing.T) {
// arrange
foi := &FeatureOfInterest{}
dsjson, _ := json.Marshal("hoho")
// act
err := foi.ParseEntity(dsjson)
// assert
assert.True(t, err != nil)
}
func TestMissingMandatoryParametersFeatureOfInterest(t *testing.T) {
//arrange
featureofinterest := &FeatureOfInterest{}
//act
_, err := featureofinterest.ContainsMandatoryParams()
//assert
assert.NotNil(t, err, "FeatureOfInterest mandatory param description not filled in should have returned error")
if len(err) > 0 {
assert.Contains(t, fmt.Sprintf("%v", err[0]), "name")
}
}
func TestMissingMandatoryParametersFeatureOfInterestSucceeds(t *testing.T) {
//arrange
featureofinterest := &FeatureOfInterest{}
featureofinterest.Name = "name"
featureofinterest.Description = "desc"
featureofinterest.EncodingType = "type"
featureofinterest.Feature = map[string]interface{}{"name": "location name 1"}
//act
_, err := featureofinterest.ContainsMandatoryParams()
//assert
assert.Nil(t, err, "FeatureOfInterest mandatory param description filled in should not have returned error")
}