@@ -35,7 +35,7 @@ public class NftRepositoryTests {
3535 private AccountClient accountClient ;
3636
3737 @ Autowired
38- private Account adminAccount ;
38+ private Account operatorAccount ;
3939
4040 private <T > List <T > getAll (Page <T > page ) {
4141 if (!page .isFirst ()) {
@@ -163,8 +163,8 @@ void findByAccountId() throws Exception {
163163 final byte [] metadata2 = "https://example.com/metadata2" .getBytes (StandardCharsets .UTF_8 );
164164 final TokenId tokenId = nftClient .createNftType (name , symbol );
165165 final List <Long > serial = nftClient .mintNfts (tokenId , metadata1 , metadata2 );
166- final AccountId adminAccountId = adminAccount .accountId ();
167- final PrivateKey adminAccountPrivateKey = adminAccount .privateKey ();
166+ final AccountId adminAccountId = operatorAccount .accountId ();
167+ final PrivateKey adminAccountPrivateKey = operatorAccount .privateKey ();
168168 final Account account = accountClient .createAccount ();
169169 final AccountId newOwner = account .accountId ();
170170 final PrivateKey newOwnerPrivateKey = account .privateKey ();
@@ -174,65 +174,64 @@ void findByAccountId() throws Exception {
174174 hederaTestUtils .waitForMirrorNodeRecords ();
175175
176176 //when
177- final Page <Nft > slice = nftRepository .findByOwner (newOwner );
178- final List <Nft > result = getAll (slice );
179-
180- // then
181- Assertions .assertNotNull (result );
182- Assertions .assertEquals (2 , result .size ());
183- Assertions .assertTrue (result .stream ().anyMatch (nft -> nft .serial () == serial .get (0 )));
184- Assertions .assertTrue (result .stream ().anyMatch (nft -> nft .serial () == serial .get (1 )));
185- }
186-
187- @ Test
188- void findByAccountIdForSomePages () throws Exception {
189- // given
190- final String name = "Tokemon cards" ;
191- final String symbol = "TOK" ;
192-
193- final AccountId adminAccountId = adminAccount .accountId ();
194- final PrivateKey adminAccountPrivateKey = adminAccount .privateKey ();
195- final Account account = accountClient .createAccount ();
196- final AccountId newOwner = account .accountId ();
197- final PrivateKey newOwnerPrivateKey = account .privateKey ();
198- final List <byte []> metadata = IntStream .range (0 , 40 ).mapToObj (i -> "metadata" + i )
199- .map (s -> s .getBytes (StandardCharsets .UTF_8 )).toList ();
200- final TokenId tokenId = nftClient .createNftType (name , symbol );
201- final int batchSize = 10 ;
202- for (int i = 0 ; i < metadata .size (); i += batchSize ) {
203- final int start = i ;
204- final int end = Math .min (i + batchSize , metadata .size ());
205- final List <Long > serial = nftClient .mintNfts (tokenId , metadata .subList (start , end ).toArray (new byte [0 ][]));
206- nftClient .transferNft (tokenId , serial .get (i ), adminAccountId , adminAccountPrivateKey , newOwner );
207-
208- }
209- nftClient .associateNft (tokenId , newOwner , newOwnerPrivateKey );
210- hederaTestUtils .waitForMirrorNodeRecords ();
211-
212- // when
213- final Page <Nft > slice = nftRepository .findByOwner (newOwner );
214- final List <Nft > result = getAll (slice );
215-
216- // then
217- Assertions .assertNotNull (result );
218- Assertions .assertEquals (metadata .size (), result .size ());
219-
220- }
221-
222- @ Test
223- void findByAccountIdWIthZeroResult () throws Exception {
224- // given
225- final String name = "Tokemon cards" ;
226- final String symbol = "TOK" ;
227- final TokenId tokenId = nftClient .createNftType (name , symbol );
228- final Account account = accountClient .createAccount ();
229- final AccountId newOwner = account .accountId ();
230- final PrivateKey newOwnerPrivateKey = account .privateKey ();
231- nftClient .associateNft (tokenId , newOwner , newOwnerPrivateKey );
232- hederaTestUtils .waitForMirrorNodeRecords ();
233-
234- // when
235- final Page <Nft > slice = nftRepository .findByOwner (newOwner );
177+ final Page <Nft > slice = nftRepository .findByOwner (newOwner );
178+ final List <Nft > result = getAll (slice );
179+
180+ // then
181+ Assertions .assertNotNull (result );
182+ Assertions .assertEquals (2 , result .size ());
183+ Assertions .assertTrue (result .stream ().anyMatch (nft -> nft .serial () == serial .get (0 )));
184+ Assertions .assertTrue (result .stream ().anyMatch (nft -> nft .serial () == serial .get (1 )));
185+ }
186+
187+ @ Test
188+ void findByAccountIdForSomePages () throws Exception {
189+ // given
190+ final String name = "Tokemon cards" ;
191+ final String symbol = "TOK" ;
192+
193+ final List <byte []> metadata = IntStream .range (0 , 40 ).mapToObj (i -> "metadata" + i )
194+ .map (s -> s .getBytes (StandardCharsets .UTF_8 )).toList ();
195+ final TokenId tokenId = nftClient .createNftType (name , symbol );
196+
197+ final Account newOwnerAccount = accountClient .createAccount ();
198+ final PrivateKey newOwnerPrivateKey = newOwnerAccount .privateKey ();
199+ final AccountId newOwnerId = newOwnerAccount .accountId ();
200+ nftClient .associateNft (tokenId , newOwnerId , newOwnerPrivateKey );
201+
202+ final int transferBatchSize = 10 ;
203+ for (int i = 0 ; i < metadata .size (); i += transferBatchSize ) {
204+ final int start = i ;
205+ final int end = Math .min (i + transferBatchSize , metadata .size ());
206+ final List <Long > serial = nftClient .mintNfts (tokenId , metadata .subList (start , end ).toArray (new byte [0 ][]));
207+ nftClient .transferNfts (tokenId , serial , operatorAccount , newOwnerId );
208+ }
209+ hederaTestUtils .waitForMirrorNodeRecords ();
210+
211+ // when
212+ final Page <Nft > slice = nftRepository .findByOwner (newOwnerId );
213+ final List <Nft > result = getAll (slice );
214+
215+ // then
216+ Assertions .assertNotNull (result );
217+ Assertions .assertEquals (metadata .size (), result .size ());
218+
219+ }
220+
221+ @ Test
222+ void findByAccountIdWIthZeroResult () throws Exception {
223+ // given
224+ final String name = "Tokemon cards" ;
225+ final String symbol = "TOK" ;
226+ final TokenId tokenId = nftClient .createNftType (name , symbol );
227+ final Account account = accountClient .createAccount ();
228+ final AccountId newOwner = account .accountId ();
229+ final PrivateKey newOwnerPrivateKey = account .privateKey ();
230+ nftClient .associateNft (tokenId , newOwner , newOwnerPrivateKey );
231+ hederaTestUtils .waitForMirrorNodeRecords ();
232+
233+ // when
234+ final Page <Nft > slice = nftRepository .findByOwner (newOwner );
236235 final List <Nft > result = getAll (slice );
237236
238237 //then
@@ -250,8 +249,8 @@ void findByTokenIdAndAccountId() throws Exception {
250249 final byte [] metadata2 = "https://example.com/metadata2" .getBytes (StandardCharsets .UTF_8 );
251250 final TokenId tokenId = nftClient .createNftType (name , symbol );
252251 final List <Long > serial = nftClient .mintNfts (tokenId , metadata1 , metadata2 );
253- final AccountId adminAccountId = adminAccount .accountId ();
254- final PrivateKey adminAccountPrivateKey = adminAccount .privateKey ();
252+ final AccountId adminAccountId = operatorAccount .accountId ();
253+ final PrivateKey adminAccountPrivateKey = operatorAccount .privateKey ();
255254 final Account account = accountClient .createAccount ();
256255 final AccountId newOwner = account .accountId ();
257256 final PrivateKey newOwnerPrivateKey = account .privateKey ();
@@ -270,40 +269,38 @@ void findByTokenIdAndAccountId() throws Exception {
270269 Assertions .assertTrue (result .stream ().anyMatch (nft -> nft .serial () == serial .get (0 )));
271270 Assertions .assertTrue (result .stream ().anyMatch (nft -> nft .serial () == serial .get (1 )));
272271 }
273-
274- @ Test
275- void findByTokenIdAndAccountIdForSomePages () throws Exception {
276- // given
277- final String name = "Tokemon cards" ;
278- final String symbol = "TOK" ;
279- final List <byte []> metadata = IntStream .range (0 , 40 ).mapToObj (i -> "metadata" + i )
280- .map (s -> s .getBytes (StandardCharsets .UTF_8 )).toList ();
281- final TokenId tokenId = nftClient .createNftType (name , symbol );
282-
283- final AccountId adminAccountId = adminAccount .accountId ();
284- final PrivateKey adminAccountPrivateKey = adminAccount .privateKey ();
285- final Account account = accountClient .createAccount ();
286- final AccountId newOwner = account .accountId ();
287- final PrivateKey newOwnerPrivateKey = account .privateKey ();
288- final int batchSize = 10 ;
289- for (int i = 0 ; i < metadata .size (); i += batchSize ) {
290- final int start = i ;
291- final int end = Math .min (i + batchSize , metadata .size ());
292- final List <Long > serial = nftClient .mintNfts (tokenId , metadata .subList (start , end ).toArray (new byte [0 ][]));
293- nftClient .transferNft (tokenId , serial .get (i ), adminAccountId , adminAccountPrivateKey , newOwner );
294-
295- }
296- nftClient .associateNft (tokenId , newOwner , newOwnerPrivateKey );
297- hederaTestUtils .waitForMirrorNodeRecords ();
298-
299- // when
300- final Page <Nft > slice = nftRepository .findByOwnerAndType (newOwner , tokenId );
301- final List <Nft > result = getAll (slice );
302-
303- // then
304- Assertions .assertNotNull (result );
305- Assertions .assertEquals (metadata .size (), result .size ());
306- }
272+
273+ @ Test
274+ void findByTokenIdAndAccountIdForSomePages () throws Exception {
275+ // given
276+ final String name = "Tokemon cards" ;
277+ final String symbol = "TOK" ;
278+ final List <byte []> metadata = IntStream .range (0 , 40 ).mapToObj (i -> "metadata" + i )
279+ .map (s -> s .getBytes (StandardCharsets .UTF_8 )).toList ();
280+ final TokenId tokenId = nftClient .createNftType (name , symbol );
281+
282+ final Account newOwnerAccount = accountClient .createAccount ();
283+ final AccountId newOwnerId = newOwnerAccount .accountId ();
284+ final PrivateKey newOwnerPrivateKey = newOwnerAccount .privateKey ();
285+ nftClient .associateNft (tokenId , newOwnerId , newOwnerPrivateKey );
286+
287+ final int transferBatchSize = 10 ;
288+ for (int i = 0 ; i < metadata .size (); i += transferBatchSize ) {
289+ final int start = i ;
290+ final int end = Math .min (i + transferBatchSize , metadata .size ());
291+ final List <Long > serial = nftClient .mintNfts (tokenId , metadata .subList (start , end ).toArray (new byte [0 ][]));
292+ nftClient .transferNfts (tokenId , serial , operatorAccount , newOwnerId );
293+ }
294+ hederaTestUtils .waitForMirrorNodeRecords ();
295+
296+ // when
297+ final Page <Nft > slice = nftRepository .findByOwnerAndType (newOwnerId , tokenId );
298+ final List <Nft > result = getAll (slice );
299+
300+ // then
301+ Assertions .assertNotNull (result );
302+ Assertions .assertEquals (metadata .size (), result .size ());
303+ }
307304
308305 @ Test
309306 void findByTokenIdAndAccountIdWithZeroResult () throws Exception {
@@ -372,8 +369,8 @@ void findByTokenIdAndAccountIdAndSerial() throws Exception {
372369 final byte [] metadata = "https://example.com/metadata1" .getBytes (StandardCharsets .UTF_8 );
373370 final TokenId tokenId = nftClient .createNftType (name , symbol );
374371 final long serial = nftClient .mintNft (tokenId , metadata );
375- final AccountId adminAccountId = adminAccount .accountId ();
376- final PrivateKey adminAccountPrivateKey = adminAccount .privateKey ();
372+ final AccountId adminAccountId = operatorAccount .accountId ();
373+ final PrivateKey adminAccountPrivateKey = operatorAccount .privateKey ();
377374 final Account account = accountClient .createAccount ();
378375 final AccountId newOwner = account .accountId ();
379376 final PrivateKey newOwnerPrivateKey = account .privateKey ();
0 commit comments