unit-test: Move associationChanged()

Make it easier to unit test and continue reduction of main.cpp

Change-Id: Ic549e096343e7a2fb11985f1c48879ed4486e40b
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/src/associations.hpp b/src/associations.hpp
index 7fa15ab..7cd3842 100644
--- a/src/associations.hpp
+++ b/src/associations.hpp
@@ -8,6 +8,9 @@
 #include <tuple>
 #include <vector>
 
+constexpr const char* XYZ_ASSOCIATION_INTERFACE =
+    "xyz.openbmc_project.Association";
+
 //  Associations and some metadata are stored in associationInterfaces.
 //  The fields are:
 //   * ifacePos - holds the D-Bus interface object
@@ -42,6 +45,8 @@
 using AssociationOwnersType = boost::container::flat_map<
     std::string, boost::container::flat_map<std::string, AssociationPaths>>;
 
+using Association = std::tuple<std::string, std::string, std::string>;
+
 /** @brief Remove input association
  *
  * @param[in] sourcePath          - Path of the object that contains the
@@ -102,3 +107,25 @@
     const AssociationPaths& newAssociations,
     sdbusplus::asio::object_server& objectServer,
     AssociationOwnersType& assocOwners, AssociationInterfaces& assocInterfaces);
+
+/** @brief Handle new or changed association interfaces
+ *
+ * Called when either a new org.openbmc.Associations interface was
+ * created, or the associations property on that interface changed
+ *
+ * @param[in,out] objectServer    - sdbus system object
+ * @param[in] associations        - New associations to look at for change
+ * @param[in] path                - Path of the object that contains the
+ *                                  org.openbmc.Associations
+ * @param[in] owner               - The Dbus service having it's associatons
+ *                                  changed
+ * @param[in,out] assocOwners     - Owners of associations
+ * @param[in,out] assocInterfaces - Associations endpoints
+ *
+ * @return Void, objectServer and assocOwners updated if needed
+ */
+void associationChanged(sdbusplus::asio::object_server& objectServer,
+                        const std::vector<Association>& associations,
+                        const std::string& path, const std::string& owner,
+                        AssociationOwnersType& assocOwners,
+                        AssociationInterfaces& assocInterfaces);