• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Bynder / bynder-java-sdk / 7130807638

07 Dec 2023 04:07PM UTC coverage: 38.562%. First build
7130807638

push

github

web-flow
API-1822 [BE] [SDK] Implement Sample Files for JAVA-SDK Functionality Testing (#114)

* API-1822 setup sample files for java sdk api calls

* API-1822 add upload sample, smart filters sample, usage sample

* API-1822 add metaproperties sample, update logging for samples, setup methods for collection sample

* API-1822 update collections sample with share, add media, remove media

* API-1822 resolve package name

* API-1822 setup asset usage sample

* API-1822 use OAuth for client, add testasset image for upload

* API-1822 add media removal, add README, add null checks for collections

* API-1822 update readme for sample files

* API-1822 get derivatives for portal

* API-1822 update readme for derivatives method

* API-1822 cleanup

* API-1822 add System.exit(0) to terminate processes

* API-1822 cleanup

0 of 351 new or added lines in 8 files covered. (0.0%)

708 of 1836 relevant lines covered (38.56%)

0.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/bynder/sdk/sample/SmartFiltersSample.java
1
package com.bynder.sdk.sample;
2

3
import com.bynder.sdk.configuration.Configuration;
4
import com.bynder.sdk.configuration.HttpConnectionSettings;
5
import com.bynder.sdk.configuration.OAuthSettings;
6
import com.bynder.sdk.model.Smartfilter;
7
import com.bynder.sdk.service.BynderClient;
8
import com.bynder.sdk.service.asset.AssetService;
9
import com.bynder.sdk.service.oauth.OAuthService;
10
import com.bynder.sdk.util.Utils;
11

12

13
import java.awt.*;
14
import java.io.IOException;
15
import java.net.URI;
16
import java.net.URISyntaxException;
17
import java.net.URL;
18

19
import java.util.*;
20
import java.util.List;
21

22
import org.slf4j.Logger;
23
import org.slf4j.LoggerFactory;
24

NEW
25
public class SmartFiltersSample {
×
NEW
26
    private static final Logger LOG = LoggerFactory.getLogger(SmartFiltersSample.class);
×
27

28
    public static void main(final String[] args) throws URISyntaxException, IOException {
29
        /**
30
         * Loads app.properties file under src/main/resources
31
         */
NEW
32
        Properties appProperties = Utils.loadConfig("app");
×
33

34
        // Initialize BynderClient with OAuth
NEW
35
        OAuthSettings oAuthSettings = new OAuthSettings(appProperties.getProperty("CLIENT_ID"), appProperties.getProperty("CLIENT_SECRET"), new URI(appProperties.getProperty("REDIRECT_URI")));
×
NEW
36
        BynderClient client = BynderClient.Builder.create(
×
NEW
37
                new Configuration.Builder(new URL(appProperties.getProperty("BASE_URL")))
×
NEW
38
                        .setOAuthSettings(oAuthSettings)
×
NEW
39
                        .setHttpConnectionSettings(new HttpConnectionSettings()).build());
×
NEW
40
        List<String> scopes = Arrays.asList("offline", "asset:read", "asset:write", "asset.usage:read",
×
41
                "asset.usage:write", "collection:read", "collection:write", "meta.assetbank:read",
42
                "meta.assetbank:write", "meta.workflow:read");
43

44
        // Initialize OAuthService
NEW
45
        OAuthService oauthService = client.getOAuthService();
×
NEW
46
        URL authorizationUrl = oauthService.getAuthorizationUrl("state example", scopes);
×
47

48
        // Open browser with authorization URL
NEW
49
        Desktop desktop = Desktop.getDesktop();
×
NEW
50
        desktop.browse(authorizationUrl.toURI());
×
51

52
        // Ask for the code returned in the redirect URI
NEW
53
        System.out.println("Insert the code: ");
×
NEW
54
        Scanner scanner = new Scanner(System.in);
×
NEW
55
        String code = scanner.nextLine();
×
NEW
56
        scanner.close();
×
57

58
        // Get the access token
NEW
59
        oauthService.getAccessToken(code, scopes).blockingSingle();
×
60

61
        // Initialize asset service
NEW
62
        AssetService assetService = client.getAssetService();
×
63

NEW
64
        List<Smartfilter> smartFilters = assetService.getSmartfilters().blockingSingle().body();
×
NEW
65
        if (smartFilters != null && !smartFilters.isEmpty()) {
×
NEW
66
            for (Smartfilter smartFilter : smartFilters) {
×
NEW
67
                LOG.info("Smart Filter ID: " + smartFilter.getId());
×
68
                // smart filter metaproperties
NEW
69
                List<String> smartFilterMetaproperties = smartFilter.getMetaproperties();
×
NEW
70
                if (!smartFilterMetaproperties.isEmpty()) {
×
NEW
71
                    LOG.info("smart filter metaproperty ids:");
×
NEW
72
                    for (String metaproperty : smartFilterMetaproperties) {
×
NEW
73
                        LOG.info("Smart Filter Metaproperty ID: " + metaproperty);
×
NEW
74
                    }
×
75
                }
76

77
                // smart filter labels
NEW
78
                Map<String, String> smartFilterLabels = smartFilter.getLabels();
×
NEW
79
                for (Map.Entry<String, String> entry : smartFilterLabels.entrySet()) {
×
NEW
80
                    LOG.info("smart filter label: " + entry.getKey() + " " + entry.getValue());
×
NEW
81
                }
×
NEW
82
            }
×
83
        }
NEW
84
        System.exit(0);
×
NEW
85
    }
×
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc