1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
#define BOOST_TEST_MODULE CMoveResponse
#include <boost/test/unit_test.hpp>
#include "odil/message/CMoveResponse.h"
#include "odil/DataSet.h"
#include "odil/message/Message.h"
#include "odil/registry.h"
#include "../../MessageFixtureBase.h"
struct Fixture: public MessageFixtureBase<odil::message::CMoveResponse>
{
std::shared_ptr<odil::DataSet> command_set;
std::shared_ptr<odil::DataSet> data_set;
Fixture()
: command_set(std::make_shared<odil::DataSet>()),
data_set(std::make_shared<odil::DataSet>())
{
this->command_set->add(
"CommandField", {odil::message::Message::Command::C_MOVE_RSP});
this->command_set->add("MessageIDBeingRespondedTo", {1234});
this->command_set->add("Status", {odil::message::Response::Success});
this->command_set->add("MessageID", {5678});
this->command_set->add("AffectedSOPClassUID",
{odil::registry::StudyRootQueryRetrieveInformationModelMove});
this->command_set->add(odil::registry::NumberOfRemainingSuboperations, {1});
this->command_set->add(odil::registry::NumberOfCompletedSuboperations, {2});
this->command_set->add(odil::registry::NumberOfFailedSuboperations, {3});
this->command_set->add(odil::registry::NumberOfWarningSuboperations, {4});
this->data_set->add("PatientName", {"Doe^John"});
this->data_set->add("PatientID", {"DJ123"});
this->data_set->add("StudyDescription", {"Brain"});
this->data_set->add("StudyInstanceUID", {"1.2.3"});
}
virtual void check(odil::message::CMoveResponse const & message)
{
BOOST_CHECK_EQUAL(
message.get_command_field(),
odil::message::Message::Command::C_MOVE_RSP);
BOOST_CHECK_EQUAL(message.get_message_id_being_responded_to(), 1234);
BOOST_CHECK_EQUAL(
message.get_status(), odil::message::Response::Success);
BOOST_CHECK(message.has_message_id());
BOOST_CHECK_EQUAL(message.get_message_id(), 5678);
BOOST_CHECK(message.has_affected_sop_class_uid());
BOOST_CHECK_EQUAL(
message.get_affected_sop_class_uid(),
odil::registry::StudyRootQueryRetrieveInformationModelMove);
BOOST_CHECK(message.has_number_of_remaining_sub_operations());
BOOST_CHECK_EQUAL(message.get_number_of_remaining_sub_operations(), 1);
BOOST_CHECK(message.has_number_of_completed_sub_operations());
BOOST_CHECK_EQUAL(message.get_number_of_completed_sub_operations(), 2);
BOOST_CHECK(message.has_number_of_failed_sub_operations());
BOOST_CHECK_EQUAL(message.get_number_of_failed_sub_operations(), 3);
BOOST_CHECK(message.has_number_of_warning_sub_operations());
BOOST_CHECK_EQUAL(message.get_number_of_warning_sub_operations(), 4);
BOOST_CHECK(message.has_data_set());
BOOST_CHECK(*message.get_data_set() == *this->data_set);
}
};
BOOST_FIXTURE_TEST_CASE(Constructor, Fixture)
{
odil::message::CMoveResponse message(
1234, odil::message::Response::Success, this->data_set);
message.set_message_id(5678);
message.set_affected_sop_class_uid(
odil::registry::StudyRootQueryRetrieveInformationModelMove);
message.set_number_of_remaining_sub_operations(1);
message.set_number_of_completed_sub_operations(2);
message.set_number_of_failed_sub_operations(3);
message.set_number_of_warning_sub_operations(4);
this->check(message);
}
BOOST_FIXTURE_TEST_CASE(MessageConstructor, Fixture)
{
this->check_message_constructor(this->command_set, this->data_set);
}
BOOST_FIXTURE_TEST_CASE(MessageConstructorWrongCommandField, Fixture)
{
this->command_set->as_int("CommandField") = {
odil::message::Message::Command::C_ECHO_RQ};
this->check_message_constructor_throw(this->command_set, this->data_set);
}
BOOST_AUTO_TEST_CASE(StatusWarning)
{
std::vector<odil::Value::Integer> const statuses = {
odil::message::CMoveResponse::SubOperationsCompleteOneOrMoreFailuresOrWarnings
};
for(auto const status:statuses)
{
odil::message::CMoveResponse response(1234, status);
BOOST_REQUIRE(!response.is_pending());
BOOST_REQUIRE(response.is_warning());
BOOST_REQUIRE(!response.is_failure());
}
}
BOOST_AUTO_TEST_CASE(StatusFailure)
{
std::vector<odil::Value::Integer> const statuses = {
odil::message::CMoveResponse::RefusedOutOfResourcesUnableToCalculateNumberOfMatches,
odil::message::CMoveResponse::RefusedOutOfResourcesUnableToPerformSubOperations,
odil::message::CMoveResponse::RefusedMoveDestinationUnknown,
odil::message::CMoveResponse::IdentifierDoesNotMatchSOPClass,
odil::message::CMoveResponse::UnableToProcess
};
for(auto const status:statuses)
{
odil::message::CMoveResponse response(1234, status);
BOOST_REQUIRE(!response.is_pending());
BOOST_REQUIRE(!response.is_warning());
BOOST_REQUIRE(response.is_failure());
}
}
|