• 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/MetapropertiesSample.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.Metaproperty;
7
import com.bynder.sdk.model.MetapropertyOption;
8
import com.bynder.sdk.query.MetapropertyQuery;
9
import com.bynder.sdk.service.BynderClient;
10
import com.bynder.sdk.service.asset.AssetService;
11
import com.bynder.sdk.service.oauth.OAuthService;
12
import com.bynder.sdk.util.Utils;
13
import org.slf4j.Logger;
14
import org.slf4j.LoggerFactory;
15

16
import java.awt.*;
17
import java.io.IOException;
18
import java.net.URI;
19
import java.net.URISyntaxException;
20
import java.net.URL;
21
import java.util.*;
22
import java.util.List;
23

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

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

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

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

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

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

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

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

63
        // get metaproperties
NEW
64
        MetapropertyQuery metapropertyQuery = new MetapropertyQuery();
×
65

NEW
66
        Map<String, Metaproperty> metapropertiesMap = assetService.getMetaproperties(metapropertyQuery).blockingSingle().body();
×
67

NEW
68
        if (metapropertiesMap != null) {
×
NEW
69
            for (Map.Entry<String, Metaproperty> metapropertyEntry : metapropertiesMap.entrySet()) {
×
NEW
70
                LOG.info("current metaproperty");
×
NEW
71
                LOG.info("Key: " + metapropertyEntry.getKey());
×
NEW
72
                Metaproperty currentMetaproperty = metapropertyEntry.getValue();
×
73

NEW
74
                LOG.info("ID: " + currentMetaproperty.getId());
×
NEW
75
                LOG.info("Name: " + currentMetaproperty.getName());
×
NEW
76
                LOG.info("Label: " + currentMetaproperty.getLabel());
×
NEW
77
                LOG.info("Type: " + currentMetaproperty.getType());
×
NEW
78
                List<MetapropertyOption> metapropertyOptionList = currentMetaproperty.getOptions();
×
79

80
                // metaproperty options if found
NEW
81
                if (metapropertyOptionList != null && !metapropertyOptionList.isEmpty()) {
×
NEW
82
                    for (MetapropertyOption metapropertyOption : metapropertyOptionList) {
×
NEW
83
                        LOG.info("Metaproperty Option ID: " + metapropertyOption.getId());
×
NEW
84
                        LOG.info("Metaproperty Option Label: " + metapropertyOption.getLabel());
×
NEW
85
                        LOG.info("Metaproperty Name: " + metapropertyOption.getName());
×
NEW
86
                    }
×
87
                }
NEW
88
            }
×
89
        }
NEW
90
        System.exit(0);
×
NEW
91
    }
×
92
}
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