-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
111 lines (94 loc) · 3.02 KB
/
main.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package main
import (
"encoding/json"
"fmt"
"log"
"strconv"
lib "github.com/dineshr93/sw360api/lib"
"github.com/dineshr93/sw360api/lib/model"
)
var (
configfile = "config.yml"
contenttype = "Content-Type"
Authorization = "Authorization"
appjson = "application/json"
apphaljson = "application/hal+json"
appxml = "application/xml"
mulformdata = "multipart/form-data"
API_URL = ""
Token = ""
)
func prettyPrint(i interface{}) string {
s, _ := json.MarshalIndent(i, "", "\t")
return string(s)
}
func main() {
apicfg := lib.Sw360(configfile)
fmt.Println("No of projects in server: ", apicfg.GetTotalProjects())
fmt.Println("=================Testing FindProjectswithName=======================")
no, names := apicfg.FindProjectswithName("ada")
fmt.Println("No of projects matched is: ", no)
for _, name := range names {
fmt.Println(name)
}
fmt.Println("=================Testing Testing GetProjectDetails=======================")
// err, data := apicfg.GetProjectDetails("ZF_Middleware_Program", "IOLITHFBL_0500")
err, ProjectDetail := apicfg.GetProjectDetails("gradle_single", "1.0")
if err != nil {
log.Fatalln("Error getting details for given project")
} else {
fmt.Println(ProjectDetail.LinkedProjects)
}
fmt.Println("===================Testing GetLinkedReleases=====================")
err, releases := apicfg.GetLinkedReleases("gradle_single", "1.0")
if err != nil {
log.Fatalln(err)
} else {
for i, release := range *releases {
i++
fmt.Println(strconv.Itoa(i), release.Name, " ", release.Version)
}
}
fmt.Println("=================Testing GetLinkedProjects=======================")
err, projects := apicfg.GetLinkedProjects("gradle_single", "1.0")
if err != nil {
log.Fatalln(err)
} else {
for i, project := range *projects {
i++
fmt.Println(strconv.Itoa(i), project.Name, " ", project.Version)
}
}
fmt.Println("================Testing GetProjectlink========================")
err, projectlink := apicfg.GetProjectlink("gradle_single", "1.0")
if err != nil {
log.Fatalln(err)
} else {
fmt.Println(projectlink)
}
fmt.Println("=================Testing GetLinkedReleasesTransitive=======================")
err, releases = apicfg.GetLinkedReleasesTransitive("gradle_single", "1.0")
if err != nil {
log.Fatalln(err)
} else {
for i, release := range *releases {
i++
fmt.Println(strconv.Itoa(i), release.Name, " ", release.Version)
}
}
fmt.Println("==================Testing CreateProject======================")
data := model.ProjectCreationModel{Name: "fromDinesh", Version: "2.0", Description: "Sample Project"}
err, msg := apicfg.CreateProject(&data)
if err != nil {
log.Fatalln(err)
}
fmt.Println(prettyPrint(msg))
fmt.Println("=================Testing DeleteProject=======================")
errormsg, msgdelete := apicfg.DeleteProject("fromDinesh", "2.0")
if errormsg != nil {
log.Fatalln(errormsg)
}
fmt.Println(msgdelete)
fmt.Println("========================================")
fmt.Println("========================================")
}