File: GetSCU.cpp

package info (click to toggle)
odil 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,476 kB
  • sloc: cpp: 55,982; python: 3,947; javascript: 460; xml: 182; makefile: 99; sh: 36
file content (91 lines) | stat: -rw-r--r-- 2,660 bytes parent folder | download | duplicates (4)
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
#define BOOST_TEST_MODULE GetSCU
#include <boost/test/unit_test.hpp>

#include "odil/DataSet.h"
#include "odil/GetSCU.h"
#include "odil/registry.h"

#include "../PeerFixtureBase.h"

struct Fixture: public PeerFixtureBase
{
    static bool store_callback_called;
    static bool get_callback_called;

    std::shared_ptr<odil::DataSet> query;

    Fixture()
    : PeerFixtureBase({
            {
                1, odil::registry::PatientRootQueryRetrieveInformationModelGet,
                { odil::registry::ImplicitVRLittleEndian }, 
                odil::AssociationParameters::PresentationContext::Role::SCU
            },
            {
                3, odil::registry::RawDataStorage,
                { odil::registry::ImplicitVRLittleEndian }, 
                odil::AssociationParameters::PresentationContext::Role::SCP
            }
        }),
        query(std::make_shared<odil::DataSet>())
    {
        Fixture::store_callback_called = false;
        Fixture::get_callback_called = false;

        this->query->add("QueryRetrieveLevel", {"PATIENT"});
        this->query->add("PatientName", {"Doe^John"});
    }


    static void store_callback(std::shared_ptr<odil::DataSet const>)
    {
        Fixture::store_callback_called = true;
    }

    static void get_callback(std::shared_ptr<odil::message::CGetResponse const>)
    {
        Fixture::get_callback_called = true;
    }
};

bool Fixture::store_callback_called = false;
bool Fixture::get_callback_called = false;

BOOST_FIXTURE_TEST_CASE(Get, Fixture)
{
    odil::GetSCU scu(this->association);

    scu.set_affected_sop_class(
        odil::registry::PatientRootQueryRetrieveInformationModelGet);
    auto const results = scu.get(this->query);

    BOOST_REQUIRE_EQUAL(results.size(), 1);
    BOOST_CHECK(
        results[0]->as_string("SOPInstanceUID") ==
            odil::Value::Strings(
                {"2.25.95090344942250266709587559073467305647"}));
}

BOOST_FIXTURE_TEST_CASE(GetBothCallbacks, Fixture)
{
    odil::GetSCU scu(this->association);

    scu.set_affected_sop_class(
        odil::registry::PatientRootQueryRetrieveInformationModelGet);
    scu.get(this->query, Fixture::store_callback, Fixture::get_callback);

    BOOST_CHECK(Fixture::store_callback_called);
    BOOST_CHECK(Fixture::get_callback_called);
}

BOOST_FIXTURE_TEST_CASE(GetOnlyStoreCallback, Fixture)
{
    odil::GetSCU scu(this->association);

    scu.set_affected_sop_class(
        odil::registry::PatientRootQueryRetrieveInformationModelGet);
    scu.get(this->query, Fixture::store_callback);

    BOOST_CHECK(Fixture::store_callback_called);
    BOOST_CHECK(!Fixture::get_callback_called);
}