return (obj->second);
}
- /// @brief Returns the sole mapped object.
+ /// @brief Returns the default mapped object.
///
/// @return Mapped object.
- /// @throw InvalidOperation when there is no mapped object or if there
- /// are multiple mapped objects.
+ /// @throw InvalidOperation when there is no mapped object.
MappedTypePtr get() const {
- if (vector_.empty() || vector_.size() > 1) {
+ if (vector_.empty()) {
isc_throw(InvalidOperation, "expected one relationship to be configured");
}
return (vector_[0]);
EXPECT_EQ(rel2, all[1]);
}
-/// Tests that getting a sole mapped object fails when there are multiple.
-TEST(HARelationshipMapper, multipleMappingsGetError) {
- HARelationshipMapper<HAConfig> mapper;
-
- auto rel1 = HAConfig::create();
- auto rel2 = HAConfig::create();
- EXPECT_NO_THROW(mapper.map("server1", rel1));
- EXPECT_NO_THROW(mapper.map("server2", rel2));
-
- EXPECT_THROW(mapper.get(), InvalidOperation);
-}
-
/// Tests that the same server can't be associated with many relationships.
TEST(HARelationshipMapper, existingMappingError) {
HARelationshipMapper<HAConfig> mapper;