diff options
Diffstat (limited to 'tests/testimplementations.h')
-rw-r--r-- | tests/testimplementations.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/testimplementations.h b/tests/testimplementations.h index 785c408..234e99d 100644 --- a/tests/testimplementations.h +++ b/tests/testimplementations.h | |||
@@ -26,9 +26,12 @@ | |||
26 | #include <common/resourceaccess.h> | 26 | #include <common/resourceaccess.h> |
27 | #include <common/facade.h> | 27 | #include <common/facade.h> |
28 | #include <common/genericresource.h> | 28 | #include <common/genericresource.h> |
29 | #include <common/commands.h> | ||
29 | 30 | ||
30 | //Replace with something different | 31 | //Replace with something different |
31 | #include "event_generated.h" | 32 | #include "event_generated.h" |
33 | #include "mail_generated.h" | ||
34 | #include "createentity_generated.h" | ||
32 | 35 | ||
33 | class TestEventAdaptorFactory : public DomainTypeAdaptorFactory<Sink::ApplicationDomain::Event, Sink::ApplicationDomain::Buffer::Event, Sink::ApplicationDomain::Buffer::EventBuilder> | 36 | class TestEventAdaptorFactory : public DomainTypeAdaptorFactory<Sink::ApplicationDomain::Event, Sink::ApplicationDomain::Buffer::Event, Sink::ApplicationDomain::Buffer::EventBuilder> |
34 | { | 37 | { |
@@ -41,6 +44,17 @@ public: | |||
41 | virtual ~TestEventAdaptorFactory() {}; | 44 | virtual ~TestEventAdaptorFactory() {}; |
42 | }; | 45 | }; |
43 | 46 | ||
47 | class TestMailAdaptorFactory : public DomainTypeAdaptorFactory<Sink::ApplicationDomain::Mail, Sink::ApplicationDomain::Buffer::Mail, Sink::ApplicationDomain::Buffer::MailBuilder> | ||
48 | { | ||
49 | public: | ||
50 | TestMailAdaptorFactory() | ||
51 | : DomainTypeAdaptorFactory() | ||
52 | { | ||
53 | } | ||
54 | |||
55 | virtual ~TestMailAdaptorFactory() {}; | ||
56 | }; | ||
57 | |||
44 | class TestResourceAccess : public Sink::ResourceAccessInterface | 58 | class TestResourceAccess : public Sink::ResourceAccessInterface |
45 | { | 59 | { |
46 | Q_OBJECT | 60 | Q_OBJECT |
@@ -69,6 +83,20 @@ public: | |||
69 | } | 83 | } |
70 | }; | 84 | }; |
71 | 85 | ||
86 | class TestMailResourceFacade : public Sink::GenericFacade<Sink::ApplicationDomain::Mail> | ||
87 | { | ||
88 | public: | ||
89 | TestMailResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::ResourceAccessInterface> resourceAccess) | ||
90 | : Sink::GenericFacade<Sink::ApplicationDomain::Mail>(instanceIdentifier, QSharedPointer<TestMailAdaptorFactory>::create(), resourceAccess) | ||
91 | { | ||
92 | |||
93 | } | ||
94 | virtual ~TestMailResourceFacade() | ||
95 | { | ||
96 | |||
97 | } | ||
98 | }; | ||
99 | |||
72 | class TestResource : public Sink::GenericResource | 100 | class TestResource : public Sink::GenericResource |
73 | { | 101 | { |
74 | public: | 102 | public: |
@@ -82,3 +110,20 @@ public: | |||
82 | return KAsync::null<void>(); | 110 | return KAsync::null<void>(); |
83 | } | 111 | } |
84 | }; | 112 | }; |
113 | |||
114 | template <typename DomainType> | ||
115 | QByteArray createCommand(const DomainType &domainObject, DomainTypeAdaptorFactoryInterface &domainTypeAdaptorFactory) | ||
116 | { | ||
117 | flatbuffers::FlatBufferBuilder entityFbb; | ||
118 | domainTypeAdaptorFactory.createBuffer(domainObject, entityFbb); | ||
119 | flatbuffers::FlatBufferBuilder fbb; | ||
120 | auto type = fbb.CreateString(Sink::ApplicationDomain::getTypeName<DomainType>().toStdString().data()); | ||
121 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); | ||
122 | Sink::Commands::CreateEntityBuilder builder(fbb); | ||
123 | builder.add_domainType(type); | ||
124 | builder.add_delta(delta); | ||
125 | auto location = builder.Finish(); | ||
126 | Sink::Commands::FinishCreateEntityBuffer(fbb, location); | ||
127 | return QByteArray(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | ||
128 | } | ||
129 | |||