+func TestPostUnpublishedServiceWithUnregisteredFunction(t *testing.T) {
+ aefId := "aefId"
+ serviceRegisterMock := serviceMocks.ServiceRegister{}
+ serviceRegisterMock.On("IsFunctionRegistered", aefId).Return(false)
+ _, requestHandler := getEcho(&serviceRegisterMock, nil)
+
+ domainName := "domain"
+ var protocol publishapi.Protocol = "HTTP_1_1"
+ description := "Description"
+ newServiceDescription := getServiceAPIDescription(aefId, domainName, description, protocol)
+
+ // Publish a service
+ result := testutil.NewRequest().Post("/aefId/service-apis").WithJsonBody(newServiceDescription).Go(t, requestHandler)
+
+ assert.Equal(t, http.StatusNotFound, result.Code())
+ var resultError common29122.ProblemDetails
+ err := result.UnmarshalBodyToObject(&resultError)
+ assert.NoError(t, err, "error unmarshaling response")
+ errMsg := "Function not registered, aefId"
+ assert.Equal(t, &errMsg, resultError.Cause)
+ notFound := http.StatusNotFound
+ assert.Equal(t, ¬Found, resultError.Status)
+}
+