func TestGetAllServiceAPIs(t *testing.T) {
var err error
+ apiName1 := "apiName1"
+ apiName2 := "apiName2"
apiList := []publishapi.ServiceAPIDescription{
- getAPI("apiName1", "aefId", "apiCategory", "v1", nil, nil, ""),
- getAPI("apiName2", "aefId", "apiCategory", "v1", nil, nil, ""),
+ getAPI(apiName1, "aefId", "apiCategory", "v1", nil, nil, ""),
+ getAPI(apiName2, "aefId", "apiCategory", "v1", nil, nil, ""),
}
invokerId := "api_invoker_id"
invokerRegisterrMock := getInvokerRegisterMock(invokerId, apiList)
err = result.UnmarshalBodyToObject(&resultInvoker)
assert.NoError(t, err, "error unmarshaling response")
assert.Equal(t, 2, len(*resultInvoker.ServiceAPIDescriptions))
- assert.Equal(t, "apiName1", (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
- assert.Equal(t, "apiName2", (*resultInvoker.ServiceAPIDescriptions)[1].ApiName)
+ assert.Equal(t, apiName1, (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
+ assert.Equal(t, apiName2, (*resultInvoker.ServiceAPIDescriptions)[1].ApiName)
assert.Equal(t, 2, len(*resultInvoker.ServiceAPIDescriptions))
}
assert.NoError(t, err, "error unmarshaling response")
notFound := http.StatusNotFound
assert.Equal(t, ¬Found, problemDetails.Status)
- errMsg := "Invoker not registered"
- assert.Equal(t, &errMsg, problemDetails.Cause)
+ assert.Contains(t, *problemDetails.Cause, invokerId)
+ assert.Contains(t, *problemDetails.Cause, "not registered")
}
func TestFilterApiName(t *testing.T) {
err = result.UnmarshalBodyToObject(&resultInvoker)
assert.NoError(t, err, "error unmarshaling response")
assert.Equal(t, 1, len(*resultInvoker.ServiceAPIDescriptions))
- assert.Equal(t, "apiName1", (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
+ assert.Equal(t, apiName, (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
}
func TestFilterAefId(t *testing.T) {
var err error
+ apiName := "apiName1"
aefId := "aefId"
apiList := []publishapi.ServiceAPIDescription{
- getAPI("apiName1", aefId, "", "", nil, nil, ""),
+ getAPI(apiName, aefId, "", "", nil, nil, ""),
getAPI("apiName2", "otherAefId", "", "", nil, nil, ""),
}
invokerId := "api_invoker_id"
err = result.UnmarshalBodyToObject(&resultInvoker)
assert.NoError(t, err, "error unmarshaling response")
assert.Equal(t, 1, len(*resultInvoker.ServiceAPIDescriptions))
- assert.Equal(t, "apiName1", (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
+ assert.Equal(t, apiName, (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
}
func TestFilterVersion(t *testing.T) {
var err error
+ apiName := "apiName1"
version := "v1"
apiList := []publishapi.ServiceAPIDescription{
- getAPI("apiName1", "", "", version, nil, nil, ""),
+ getAPI(apiName, "", "", version, nil, nil, ""),
getAPI("apiName2", "", "", "v2", nil, nil, ""),
}
invokerId := "api_invoker_id"
err = result.UnmarshalBodyToObject(&resultInvoker)
assert.NoError(t, err, "error unmarshaling response")
assert.Equal(t, 1, len(*resultInvoker.ServiceAPIDescriptions))
- assert.Equal(t, "apiName1", (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
+ assert.Equal(t, apiName, (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
}
func TestFilterCommType(t *testing.T) {
var err error
+ apiName := "apiName1"
commType := publishapi.CommunicationTypeREQUESTRESPONSE
apiList := []publishapi.ServiceAPIDescription{
- getAPI("apiName1", "", "", "", nil, nil, commType),
+ getAPI(apiName, "", "", "", nil, nil, commType),
getAPI("apiName2", "", "", "", nil, nil, publishapi.CommunicationTypeSUBSCRIBENOTIFY),
}
invokerId := "api_invoker_id"
err = result.UnmarshalBodyToObject(&resultInvoker)
assert.NoError(t, err, "error unmarshaling response")
assert.Equal(t, 1, len(*resultInvoker.ServiceAPIDescriptions))
- assert.Equal(t, "apiName1", (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
+ assert.Equal(t, apiName, (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
}
func TestFilterVersionAndCommType(t *testing.T) {
var err error
+ apiName := "apiName2"
version := "v1"
commType := publishapi.CommunicationTypeSUBSCRIBENOTIFY
apiList := []publishapi.ServiceAPIDescription{
getAPI("apiName1", "", "", version, nil, nil, publishapi.CommunicationTypeREQUESTRESPONSE),
- getAPI("apiName2", "", "", version, nil, nil, commType),
+ getAPI(apiName, "", "", version, nil, nil, commType),
getAPI("apiName3", "", "", "v2", nil, nil, commType),
}
invokerId := "api_invoker_id"
err = result.UnmarshalBodyToObject(&resultInvoker)
assert.NoError(t, err, "error unmarshaling response")
assert.Equal(t, 1, len(*resultInvoker.ServiceAPIDescriptions))
- assert.Equal(t, "apiName2", (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
+ assert.Equal(t, apiName, (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
}
func TestFilterAPICategory(t *testing.T) {
var err error
+ apiName := "apiName1"
apiCategory := "apiCategory"
apiList := []publishapi.ServiceAPIDescription{
- getAPI("apiName1", "", apiCategory, "", nil, nil, ""),
+ getAPI(apiName, "", apiCategory, "", nil, nil, ""),
getAPI("apiName2", "", "", "", nil, nil, ""),
}
invokerId := "api_invoker_id"
err = result.UnmarshalBodyToObject(&resultInvoker)
assert.NoError(t, err, "error unmarshaling response")
assert.Equal(t, 1, len(*resultInvoker.ServiceAPIDescriptions))
- assert.Equal(t, "apiName1", (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
+ assert.Equal(t, apiName, (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
}
func TestFilterProtocol(t *testing.T) {
var err error
+ apiName := "apiName1"
apiList := []publishapi.ServiceAPIDescription{
- getAPI("apiName1", "", "", "", &protocolHTTP11, nil, ""),
+ getAPI(apiName, "", "", "", &protocolHTTP11, nil, ""),
getAPI("apiName2", "", "", "", nil, nil, ""),
}
invokerId := "api_invoker_id"
err = result.UnmarshalBodyToObject(&resultInvoker)
assert.NoError(t, err, "error unmarshaling response")
assert.Equal(t, 1, len(*resultInvoker.ServiceAPIDescriptions))
- assert.Equal(t, "apiName1", (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
+ assert.Equal(t, apiName, (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
}
var DataFormatOther publishapi.DataFormat = "OTHER"
func TestFilterDataFormat(t *testing.T) {
var err error
+ apiName := "apiName1"
apiList := []publishapi.ServiceAPIDescription{
- getAPI("apiName1", "", "", "", nil, &dataFormatJSON, ""),
+ getAPI(apiName, "", "", "", nil, &dataFormatJSON, ""),
getAPI("apiName2", "", "", "", nil, nil, ""),
}
invokerId := "api_invoker_id"
err = result.UnmarshalBodyToObject(&resultInvoker)
assert.NoError(t, err, "error unmarshaling response")
assert.Equal(t, 1, len(*resultInvoker.ServiceAPIDescriptions))
- assert.Equal(t, "apiName1", (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
+ assert.Equal(t, apiName, (*resultInvoker.ServiceAPIDescriptions)[0].ApiName)
}
func getEcho(invokerManager invokermanagement.InvokerRegister) *echo.Echo {