SpotifyCouchbaseLoader { public void loadJson(Bucket bucket, String artistId) { SpotifyLoaderService loaderService = new SpotifyLoaderServiceImpl(); String jsonU2Artist = loaderService.getArtist(artistId); JsonObject json = JsonObject.fromJson(jsonU2Artist); JsonDocument docs = JsonDocument.create("artist", json); bucket.upsert(docs); String jsonU2Albums = loaderService.getAlbums(artistId); json = JsonObject.fromJson(jsonU2Albums); docs = JsonDocument.create("albums", json); bucket.upsert(docs); String jsonU2RelatedArtists = loaderService.getRelatedArtists(artistId); json = JsonObject.fromJson(jsonU2RelatedArtists); docs = JsonDocument.create("relArtists", json); bucket.upsert(docs); }  void loadJson(Bucket bucket, String artistId);  }
@Test public void loadJSONDocumentsTest() { System.out.println("starting db..."); Cluster cluster = CouchbaseCluster.create(); System.out.println("creted db..."); System.out.println("opening bucket..."); Bucket defaultBucket = cluster.openBucket("default"); System.out.println("opened bucket..."); SpotifyCouchbaseLoader loader = new SpotifyCouchbaseLoader(); String u2ArtistId = "51Blml2LZPmy7TTiAg47vQ"; loader.loadJson(defaultBucket, u2ArtistId); JsonDocument jsonDocument = defaultBucket.get("albums"); cluster.disconnect(); Assert.assertNotNull(jsonDocument); Object items = jsonDocument.content().get("items"); Assert.assertNotNull(items); }