unit-test: Utilize common code for endpoint remove

Testing: Previous test cases get us 100% coverage here

Change-Id: I3b96872bf25ce7ddcc96422f1d453f153f9dd39c
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/src/associations.cpp b/src/associations.cpp
index 9bb7a34..181f510 100644
--- a/src/associations.cpp
+++ b/src/associations.cpp
@@ -31,40 +31,8 @@
 
     for (const auto& [assocPath, endpointsToRemove] : assocs->second)
     {
-        // Get the association D-Bus object for this assocPath
-        auto target = assocInterfaces.find(assocPath);
-        if (target == assocInterfaces.end())
-        {
-            continue;
-        }
-
-        // Remove the entries in the endpoints D-Bus property for this
-        // path/owner/association-path.
-        auto& existingEndpoints = std::get<endpointsPos>(target->second);
-        for (const auto& endpointToRemove : endpointsToRemove)
-        {
-            auto e = std::find(existingEndpoints.begin(),
-                               existingEndpoints.end(), endpointToRemove);
-
-            if (e != existingEndpoints.end())
-            {
-                existingEndpoints.erase(e);
-            }
-        }
-
-        // Remove the association from D-Bus if there are no more endpoints,
-        // otherwise just update the endpoints property.
-        if (existingEndpoints.empty())
-        {
-            server.remove_interface(std::get<ifacePos>(target->second));
-            std::get<ifacePos>(target->second) = nullptr;
-            std::get<endpointsPos>(target->second).clear();
-        }
-        else
-        {
-            std::get<ifacePos>(target->second)
-                ->set_property("endpoints", existingEndpoints);
-        }
+        removeAssociationEndpoints(server, assocPath, endpointsToRemove,
+                                   assocInterfaces);
     }
 
     // Remove the associationOwners entries for this owning path/service.