19TEST(CredentialTests, BuilderSettersRoundTrip)
39 previousTxnLgrSeqValue
49 EXPECT_TRUE(builder.validate());
51 auto const entry = builder.build(index);
53 EXPECT_TRUE(entry.validate());
56 auto const& expected = subjectValue;
57 auto const actual = entry.getSubject();
62 auto const& expected = issuerValue;
63 auto const actual = entry.getIssuer();
68 auto const& expected = credentialTypeValue;
69 auto const actual = entry.getCredentialType();
74 auto const& expected = issuerNodeValue;
75 auto const actual = entry.getIssuerNode();
80 auto const& expected = previousTxnIDValue;
81 auto const actual = entry.getPreviousTxnID();
86 auto const& expected = previousTxnLgrSeqValue;
87 auto const actual = entry.getPreviousTxnLgrSeq();
92 auto const& expected = expirationValue;
93 auto const actualOpt = entry.getExpiration();
94 ASSERT_TRUE(actualOpt.has_value());
96 EXPECT_TRUE(entry.hasExpiration());
100 auto const& expected = uRIValue;
101 auto const actualOpt = entry.getURI();
102 ASSERT_TRUE(actualOpt.has_value());
104 EXPECT_TRUE(entry.hasURI());
108 auto const& expected = subjectNodeValue;
109 auto const actualOpt = entry.getSubjectNode();
110 ASSERT_TRUE(actualOpt.has_value());
112 EXPECT_TRUE(entry.hasSubjectNode());
115 EXPECT_TRUE(entry.hasLedgerIndex());
116 auto const ledgerIndex = entry.getLedgerIndex();
117 ASSERT_TRUE(ledgerIndex.has_value());
118 EXPECT_EQ(*ledgerIndex, index);
119 EXPECT_EQ(entry.getKey(), index);
124TEST(CredentialTests, BuilderFromSleRoundTrip)
140 sle->at(sfSubject) = subjectValue;
141 sle->at(sfIssuer) = issuerValue;
142 sle->at(sfCredentialType) = credentialTypeValue;
143 sle->at(sfExpiration) = expirationValue;
144 sle->at(sfURI) = uRIValue;
145 sle->at(sfIssuerNode) = issuerNodeValue;
146 sle->at(sfSubjectNode) = subjectNodeValue;
147 sle->at(sfPreviousTxnID) = previousTxnIDValue;
148 sle->at(sfPreviousTxnLgrSeq) = previousTxnLgrSeqValue;
151 EXPECT_TRUE(builderFromSle.validate());
153 auto const entryFromBuilder = builderFromSle.build(index);
156 EXPECT_TRUE(entryFromBuilder.validate());
157 EXPECT_TRUE(entryFromSle.validate());
160 auto const& expected = subjectValue;
162 auto const fromSle = entryFromSle.getSubject();
163 auto const fromBuilder = entryFromBuilder.getSubject();
170 auto const& expected = issuerValue;
172 auto const fromSle = entryFromSle.getIssuer();
173 auto const fromBuilder = entryFromBuilder.getIssuer();
180 auto const& expected = credentialTypeValue;
182 auto const fromSle = entryFromSle.getCredentialType();
183 auto const fromBuilder = entryFromBuilder.getCredentialType();
190 auto const& expected = issuerNodeValue;
192 auto const fromSle = entryFromSle.getIssuerNode();
193 auto const fromBuilder = entryFromBuilder.getIssuerNode();
200 auto const& expected = previousTxnIDValue;
202 auto const fromSle = entryFromSle.getPreviousTxnID();
203 auto const fromBuilder = entryFromBuilder.getPreviousTxnID();
210 auto const& expected = previousTxnLgrSeqValue;
212 auto const fromSle = entryFromSle.getPreviousTxnLgrSeq();
213 auto const fromBuilder = entryFromBuilder.getPreviousTxnLgrSeq();
220 auto const& expected = expirationValue;
222 auto const fromSleOpt = entryFromSle.getExpiration();
223 auto const fromBuilderOpt = entryFromBuilder.getExpiration();
225 ASSERT_TRUE(fromSleOpt.has_value());
226 ASSERT_TRUE(fromBuilderOpt.has_value());
233 auto const& expected = uRIValue;
235 auto const fromSleOpt = entryFromSle.getURI();
236 auto const fromBuilderOpt = entryFromBuilder.getURI();
238 ASSERT_TRUE(fromSleOpt.has_value());
239 ASSERT_TRUE(fromBuilderOpt.has_value());
246 auto const& expected = subjectNodeValue;
248 auto const fromSleOpt = entryFromSle.getSubjectNode();
249 auto const fromBuilderOpt = entryFromBuilder.getSubjectNode();
251 ASSERT_TRUE(fromSleOpt.has_value());
252 ASSERT_TRUE(fromBuilderOpt.has_value());
258 EXPECT_EQ(entryFromSle.getKey(), index);
259 EXPECT_EQ(entryFromBuilder.getKey(), index);
299TEST(CredentialTests, OptionalFieldsReturnNullopt)
316 previousTxnLgrSeqValue
319 auto const entry = builder.build(index);
322 EXPECT_FALSE(entry.hasExpiration());
323 EXPECT_FALSE(entry.getExpiration().has_value());
324 EXPECT_FALSE(entry.hasURI());
325 EXPECT_FALSE(entry.getURI().has_value());
326 EXPECT_FALSE(entry.hasSubjectNode());
327 EXPECT_FALSE(entry.getSubjectNode().has_value());
std::shared_ptr< SLE const > getSle() const
Get the underlying SLE object.
Derived & setLedgerIndex(uint256 const &value)
Set the ledger index.
Derived & setFlags(uint32_t value)
Set the flags.