Implement graceful shutdown of consumer
[nonrtric.git] / dmaap-mediator-producer / internal / jobs / jobs_test.go
index b301c2f..9fe27c3 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)
 
@@ -164,7 +165,6 @@ func TestDeleteJob(t *testing.T) {
 func TestPollAndDistributeMessages(t *testing.T) {
        assertions := require.New(t)
 
-       wg := sync.WaitGroup{}
        messages := `[{"message": {"data": "data"}}]`
        pollClientMock := NewTestClient(func(req *http.Request) *http.Response {
                if req.URL.String() == "http://mrAddr/topicUrl" {
@@ -211,6 +211,7 @@ func TestPollAndDistributeMessages(t *testing.T) {
                handlerUnderTest.clearAll()
        })
 
+       wg := sync.WaitGroup{}
        wg.Add(2) // Two calls should be made to the server, one to poll and one to distribute
        handlerUnderTest.pollAndDistributeMessages("http://mrAddr")