Merge "NONRTRIC - Implement DMaaP mediator producer service in Java"
[nonrtric.git] / dmaap-mediator-producer / internal / jobs / jobs_test.go
index b301c2f..555285c 100644 (file)
@@ -31,6 +31,7 @@ import (
        "time"
 
        "github.com/stretchr/testify/require"
+       "oransc.org/nonrtric/dmaapmediatorproducer/internal/config"
 )
 
 const typeDefinition = `{"types": [{"id": "type1", "dmaapTopicUrl": "events/unauthenticated.SEC_FAULT_OUTPUT/dmaapmediatorproducer/type1"}]}`
@@ -51,11 +52,11 @@ func TestGetTypes_filesOkShouldReturnSliceOfTypesAndProvideSupportedTypes(t *tes
                t.Errorf("Unable to create temporary config file for types due to: %v", err)
        }
        types, err := handlerUnderTest.GetTypes()
-       wantedType := TypeDefinition{
+       wantedType := config.TypeDefinition{
                Id:            "type1",
                DmaapTopicURL: "events/unauthenticated.SEC_FAULT_OUTPUT/dmaapmediatorproducer/type1",
        }
-       wantedTypes := []TypeDefinition{wantedType}
+       wantedTypes := []config.TypeDefinition{wantedType}
        assertions.EqualValues(wantedTypes, types)
        assertions.Nil(err)
 
@@ -184,7 +185,7 @@ func TestPollAndDistributeMessages(t *testing.T) {
                if req.URL.String() == "http://consumerHost/target" {
                        assertions.Equal(req.Method, "POST")
                        assertions.Equal(messages, getBodyAsString(req))
-                       assertions.Equal("application/json; charset=utf-8", req.Header.Get("Content-Type"))
+                       assertions.Equal("application/json", req.Header.Get("Content-Type"))
                        wg.Done() // Signal that the distribution call has been made
                        return &http.Response{
                                StatusCode: 200,
@@ -196,7 +197,9 @@ func TestPollAndDistributeMessages(t *testing.T) {
                t.Fail()
                return nil
        })
+
        handlerUnderTest := NewJobHandlerImpl("", pollClientMock, distributeClientMock)
+
        jobInfo := JobInfo{
                InfoTypeIdentity: "type1",
                InfoJobIdentity:  "job1",
@@ -204,7 +207,7 @@ func TestPollAndDistributeMessages(t *testing.T) {
        }
        handlerUnderTest.allTypes["type1"] = TypeData{
                TypeId:        "type1",
-               DMaaPTopicURL: "topicUrl",
+               DMaaPTopicURL: "/topicUrl",
                Jobs:          map[string]JobInfo{"job1": jobInfo},
        }
        t.Cleanup(func() {