Public Vars

Back

bean (clj)

(source)

function

(bean x)
Takes a Java object and returns a read-only implementation of the map abstraction based upon its JavaBean properties.

Examples

typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

cc/method-sig [java.lang.reflect.Method :-> '[t/Any t/AnyNilableNonEmptySeq t/Any]]
cc/proxy-name [Class (t/Seqable Class) :-> t/Str]
cc/get-proxy-class [Class :* :-> Class]
cc/construct-proxy [Class t/Any :* :-> t/Any]
cc/init-proxy [t/Proxy (t/Map t/Str t/Any) :-> t/Proxy]
cc/update-proxy [t/Proxy (t/Map t/Str t/Any) :-> t/Proxy]
cc/proxy-mappings [t/Proxy :-> (t/Map t/Str t/Any)]
cc/proxy-call-with-super (t/All [x] [[:-> x] t/Proxy t/Str :-> x])
cc/bean [Object :-> (t/Map t/Any t/Any)]
])
fluree/ledger
(ns fluree.db.ledger.docs.examples.supply-chain
  (:require [clojure.test :refer :all]
            [fluree.db.test-helpers :as test]
            [fluree.db.ledger.docs.getting-started.basic-schema :as basic]
            [fluree.db.api :as fdb]
            [clojure.core.async :as async]
            [clojure.java.io :as io]
            [clojure.tools.reader.edn :as edn]
            [clojure.string :as str]))


;; Invalid transaction - Block 9
(deftest invalid-txns-9
  (let [createPO                 {:_id       "purchaseOrder",
                                  :id        "124",
                                  :name      "myPurchaseOrder2",
                                  :issuer    ["organization/name" "The Roastery"],
                                  :issueDate "#(now)",
                                  :product   {:_id           "product",
                                              :id            "a4t57",
                                              :name          "Tuesday Coffee",
                                              :description   "Our regular monday shipment of roasted coffee",
                                              :category      "coffee",
                                              :strain        "Colombian Arabica",
                                              :quantity      100,
                                              :unitOfMeasure "lb"}}
        createPOResp             (-> (async/<!! (fdb/transact-async (basic/get-conn) test/ledger-supplychain [createPO] roastery-opts))
                                     test/extract-errors)
        createPORespErrors       (->> createPOResp :meta :errors (map :message) (into #{}))
        createPO2                (assoc createPO :issuer ["organization/name" "Coffee on the Block"])
        createPOResp2            (-> (async/<!! (fdb/transact-async (basic/get-conn) test/ledger-supplychain [createPO2] farm-opts))
                                     test/extract-errors)
        createPOResp2Errors      (->> createPOResp2 :meta :errors (map :message) (into #{}))
        createPO3                (dissoc createPO2 :name)
        createPOResp3            (-> (async/<!! (fdb/transact-async (basic/get-conn) test/ledger-supplychain [createPO3] cafe-opts))
                                     test/extract-errors)
        createPOResp3Errors      (->> createPOResp3 :meta :errors (map :message) (into #{}))
        createShipment           [{:_id                     "shipment$1",
                                   :name                    "123BeanShip",
                                   :sentBy                  ["organization/name" "McDonald's Farm"],
                                   :intendedRecipient       ["organization/name" "The Roastery"],
                                   :intendedReceiptLocation "Miami, FL",
                                   :sentLocation            "McDonLand",
                                   :itemDescription         "Got the beans harvested!",
                                   :id                      "growShip123",
                                   :sentDate                "#(now)"}]
        createShipmentResp       (-> (async/<!! (fdb/transact-async (basic/get-conn) test/ledger-supplychain createShipment farm-opts))
                                     test/extract-errors)
        createShipmentRespErrors (->> createShipmentResp :meta :errors (map :message) (into #{}))]

;; Invalid transaction - Block 10
(deftest invalid-txns-10
  (let [addGrowerToPO      [{:_id ["purchaseOrder/id" "123"], :grower ["organization/name" "McDonald's Farm"]}]
        addGrowerToPOResp  (-> (async/<!! (fdb/transact-async (basic/get-conn) test/ledger-supplychain addGrowerToPO farm-opts))
                               test/safe-Throwable->map
                               :cause)
        createShipment     [{:_id                     "shipment$1",
                             :name                    "123BeanShip",
                             :sentBy                  ["organization/name" "McDonald's Farm"],
                             :intendedRecipient       ["organization/name" "The Roastery"],
                             :intendedReceiptLocation "Miami, FL",
                             :sentLocation            "McDonLand",
                             :itemDescription         "Got the beans harvested!",
                             :id                      "growShip123",
                             :sentDate                "#(now)"}
                            {:_id ["purchaseOrder/id" "123"], :shipments ["shipment$1"]}]
        createShipmentResp (-> (async/<!! (fdb/transact-async (basic/get-conn) test/ledger-supplychain createShipment cafe-opts))
                               test/safe-Throwable->map
                               :cause)]

;; Valid transaction - Block 13
(deftest valid-txn-13
  (let [txn                [{:_id ["purchaseOrder/id" "123"], :shipments ["shipment$1"]}
                            {:_id                     "shipment$1",
                             :sentSignature           ["organization/name" "McDonald's Farm"],
                             :name                    "123BeanShip",
                             :sentBy                  ["organization/name" "McDonald's Farm"],
                             :intendedRecipient       ["organization/name" "The Roastery"],
                             :intendedReceiptLocation "Miami, FL",
                             :sentLocation            "McDonLand",
                             :itemDescription         "Got the beans harvested!",
                             :id                      "growShip123",
                             :sentDate                "#(now)"}]
        createShipmentResp (async/<!! (fdb/transact-async (basic/get-conn) test/ledger-supplychain txn farm-opts))]

;; Valid transaction - Block 18 - 20
(deftest valid-txn-18-to-20
  (let [receiveShipment     [{:_id ["shipment/id" "growShip123"], :receivedSignature ["organization/name" "The Roastery"]}]
        receiveShipmentResp (async/<!! (fdb/transact-async (basic/get-conn) test/ledger-supplychain receiveShipment roastery-opts))
        addRoastInfo        [{:_id       ["purchaseOrder/id" "123"],
                              :roaster   ["organization/name" "The Roastery"],
                              :roastDate "#(now)",
                              :approved  [["organization/name" "The Roastery"]]}]
        addRoastInfoResp    (async/<!! (fdb/transact-async (basic/get-conn) test/ledger-supplychain addRoastInfo roastery-opts))
        createShipment      [{:_id       ["purchaseOrder/id" "123"],
                              :shipments [{:_id                     "shipment",
                                           :sentSignature           ["organization/name" "The Roastery"],
                                           :name                    "123RoastShip",
                                           :sentBy                  ["organization/name" "The Roastery"],
                                           :intendedRecipient       ["organization/name" "Coffee on the Block"],
                                           :intendedReceiptLocation "Portland, OR",
                                           :sentLocation            "Miami, FL",
                                           :itemDescription         "Got the beans roasted!",
                                           :id                      "roasterShip123",
                                           :sentDate                "#(now)"}]}]
        createShipmentResp  (async/<!! (fdb/transact-async (basic/get-conn) test/ledger-supplychain createShipment roastery-opts))]