Improve DMaaP Mediator Producer

Issue-ID: NONRTRIC-586
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
Change-Id: Iab915f878874b687b1c1b2effc05293582fb254c
diff --git a/dmaap-mediator-producer/internal/server/server.go b/dmaap-mediator-producer/internal/server/server.go
index c3a1331..0b5e5b8 100644
--- a/dmaap-mediator-producer/internal/server/server.go
+++ b/dmaap-mediator-producer/internal/server/server.go
@@ -29,8 +29,11 @@
 	"oransc.org/nonrtric/dmaapmediatorproducer/internal/jobs"
 )
 
+const StatusCallbackPath = "/status"
+const JobsCallbackPath = "/jobs"
+
 func StatusHandler(w http.ResponseWriter, r *http.Request) {
-	if r.URL.Path != "/" {
+	if r.URL.Path != StatusCallbackPath {
 		http.Error(w, "404 not found.", http.StatusNotFound)
 		return
 	}
@@ -44,7 +47,7 @@
 }
 
 func CreateInfoJobHandler(w http.ResponseWriter, r *http.Request) {
-	if r.URL.Path != "/producer_simulator/info_job" {
+	if r.URL.Path != JobsCallbackPath {
 		http.Error(w, "404 not found.", http.StatusNotFound)
 		return
 	}
@@ -68,14 +71,3 @@
 		http.Error(w, fmt.Sprintf("Invalid job info. Cause: %v", err), http.StatusBadRequest)
 	}
 }
-
-func CreateServer(port int, handlerFunc func(http.ResponseWriter, *http.Request)) *http.Server {
-
-	mux := http.NewServeMux()
-	mux.HandleFunc("/", handlerFunc)
-	server := http.Server{
-		Addr:    fmt.Sprintf(":%v", port), // :{port}
-		Handler: mux,
-	}
-	return &server
-}
diff --git a/dmaap-mediator-producer/internal/server/server_test.go b/dmaap-mediator-producer/internal/server/server_test.go
index 444deba..a4b19c4 100644
--- a/dmaap-mediator-producer/internal/server/server_test.go
+++ b/dmaap-mediator-producer/internal/server/server_test.go
@@ -51,7 +51,7 @@
 			name: "StatusHandler with correct path and method, should return OK",
 			args: args{
 				responseRecorder: httptest.NewRecorder(),
-				r:                newRequest("GET", "/", nil, t),
+				r:                newRequest("GET", "/status", nil, t),
 			},
 			wantedStatus: http.StatusOK,
 			wantedBody:   "All is well!",
@@ -69,7 +69,7 @@
 			name: "StatusHandler with incorrect method, should return MethodNotAllowed",
 			args: args{
 				responseRecorder: httptest.NewRecorder(),
-				r:                newRequest("PUT", "/", nil, t),
+				r:                newRequest("PUT", "/status", nil, t),
 			},
 			wantedStatus: http.StatusMethodNotAllowed,
 			wantedBody:   "Method is not supported.\n",
@@ -119,7 +119,7 @@
 			name: "CreateInfoJobHandler with correct path and method, should return OK",
 			args: args{
 				responseRecorder: httptest.NewRecorder(),
-				r:                newRequest("POST", "/producer_simulator/info_job", &goodJobInfo, t),
+				r:                newRequest("POST", "/jobs", &goodJobInfo, t),
 			},
 			wantedStatus: http.StatusOK,
 			wantedBody:   "",
@@ -128,7 +128,7 @@
 			name: "CreateInfoJobHandler with incorrect job info, should return BadRequest",
 			args: args{
 				responseRecorder: httptest.NewRecorder(),
-				r:                newRequest("POST", "/producer_simulator/info_job", &badJobInfo, t),
+				r:                newRequest("POST", "/jobs", &badJobInfo, t),
 			},
 			wantedStatus: http.StatusBadRequest,
 			wantedBody:   "Invalid job info. Cause: error",
@@ -146,7 +146,7 @@
 			name: "CreateInfoJobHandler with incorrect method, should return MethodNotAllowed",
 			args: args{
 				responseRecorder: httptest.NewRecorder(),
-				r:                newRequest("PUT", "/producer_simulator/info_job", nil, t),
+				r:                newRequest("PUT", "/jobs", nil, t),
 			},
 			wantedStatus: http.StatusMethodNotAllowed,
 			wantedBody:   "Method is not supported.",