@@ -5,10 +5,12 @@ import ch.qos.logback.classic.Logger
55import ch.qos.logback.classic.LoggerContext
66import com.jfrog.bintray.client.api.BintrayCallException
77import com.jfrog.bintray.client.api.details.Attribute
8+ import com.jfrog.bintray.client.api.details.ObjectMapperHelper
89import com.jfrog.bintray.client.api.details.PackageDetails
910import com.jfrog.bintray.client.api.details.VersionDetails
1011import com.jfrog.bintray.client.api.handle.Bintray
1112import com.jfrog.bintray.client.api.handle.PackageHandle
13+ import com.jfrog.bintray.client.api.handle.RepositoryHandle
1214import com.jfrog.bintray.client.api.handle.VersionHandle
1315import com.jfrog.bintray.client.api.model.Pkg
1416import com.jfrog.bintray.client.api.model.Subject
@@ -98,7 +100,7 @@ class BintrayClientSpec extends Specification {
98100 assert this . connectionProperties. username
99101 assert this . connectionProperties. apiKey
100102 assert this . connectionProperties. email
101- bintray = BintrayClient . create(this . connectionProperties. username as String , this . connectionProperties. apiKey as String , null , null )
103+ bintray = BintrayClient . create(this . connectionProperties. username as String , this . connectionProperties. apiKey as String )
102104 restClient = createClient()
103105 pkgBuilder = new PackageDetails (PKG_NAME ). description(' bla-bla' ). labels([' l1' , ' l2' ]). licenses([' Apache-2.0' ])
104106 versionBuilder = new VersionDetails (VERSION ). description(' versionDesc' )
@@ -412,7 +414,7 @@ class BintrayClientSpec extends Specification {
412414
413415 def ' on error response is returned without parsing' () {
414416 setup :
415- Bintray wrongBintray = BintrayClient . create(this . connectionProperties. username as String , this . connectionProperties. apiKey as String , null , null )
417+ Bintray wrongBintray = BintrayClient . create(this . connectionProperties. username as String , this . connectionProperties. apiKey as String )
416418 when :
417419 wrongBintray. subject(' bla' ). get()
418420 then :
@@ -596,6 +598,70 @@ class BintrayClientSpec extends Specification {
596598
597599 }
598600
601+ def ' send empty values - verify they are not null' () {
602+
603+ String minimalPkgName = " MyPackage"
604+
605+ String minimalPkgJson = " {\n " +
606+ " \t\t\" name\" : \" " + minimalPkgName + " \" ,\n " +
607+ " \t\t\" repo\" : \" " + REPO_NAME + " \" ,\n " +
608+ " \t\t\" owner\" : \" " + connectionProperties. username + " \" ,\n " +
609+ " \t\t\" desc\" : \"\" ,\n " +
610+ " \t\t\" website_url\" : \"\" ,\n " +
611+ " \t\t\" labels\" : [],\n " +
612+ " \t\t\" licenses\" : [\" MIT\" ]\n " +
613+ " }"
614+
615+ String minimalVerJson = " {\n " +
616+ " \t\t\" name\" : \" 3.3.3\" ,\n " +
617+ " \t\t\" vcs_tag\" : \"\" ,\n " +
618+ " \t\t\" labels\" : null,\n " +
619+ " \t\t\" description\" : \"\"\n " +
620+ " }"
621+
622+ setup :
623+ ObjectMapper mapper = ObjectMapperHelper . objectMapper
624+
625+ ArrayList<String > licenses = new ArrayList<> ();
626+ licenses. add(" Apache-2.0" )
627+ PackageDetails newPkgDetails = new PackageDetails (minimalPkgName);
628+ newPkgDetails. licenses(licenses);
629+ newPkgDetails. setRepo(REPO_NAME )
630+ newPkgDetails. setSubject(connectionProperties. username)
631+ newPkgDetails. setVcsUrl(" " )
632+ newPkgDetails. setDescription(" " )
633+
634+ VersionDetails newVerDetails = new VersionDetails (" 2.2.0" )
635+ newVerDetails. setDescription(" " )
636+
637+ PackageDetails pkgDetailsFromJson = mapper. readValue(minimalPkgJson, PackageDetails . class)
638+ VersionDetails verDetailsFromJson = mapper. readValue(minimalVerJson, VersionDetails . class)
639+
640+ when :
641+ RepositoryHandle repo = bintray. subject(connectionProperties. username). repository(REPO_NAME )
642+
643+ PackageHandle pkg = repo. createPkg(newPkgDetails)
644+ VersionHandle ver = pkg. createVersion(newVerDetails)
645+
646+ pkg. update(pkgDetailsFromJson)
647+ ver. update(verDetailsFromJson)
648+
649+ String pkgJsonContent = PackageImpl . getCreateUpdateJson(pkgDetailsFromJson);
650+ String verJsonContent = VersionImpl . getCreateUpdateJson(verDetailsFromJson);
651+
652+ then :
653+ pkgJsonContent. equals(" {\" name\" :\" MyPackage\" ,\" labels\" :[],\" licenses\" :[\" MIT\" ],\" desc\" :\"\" ,\" website_url\" :\"\" }" )
654+ verJsonContent. contentEquals(" {\" name\" :\" 3.3.3\" ,\" vcs_tag\" :\"\" }" )
655+
656+ cleanup :
657+ try {
658+ String cleanPkg = " /packages/" + connectionProperties. username + " /" + REPO_NAME + " /" + minimalPkgName
659+ restClient. delete(cleanPkg, null )
660+ } catch (Exception e) {
661+ System . err. println (" cleanup: " + e)
662+ }
663+ }
664+
599665
600666 def cleanup () {
601667 try {
0 commit comments