afawcett / custommetadataapi Goto Github PK
View Code? Open in Web Editor NEWApex and Lightning Components for working with Custom Metadata Records
License: BSD 3-Clause "New" or "Revised" License
Apex and Lightning Components for working with Custom Metadata Records
License: BSD 3-Clause "New" or "Revised" License
Given
When
Then
System.AsyncException: Metadata cannot be deployed from within a test
Class CustomMetadataTest
conveniently includes public inner class MockPlatform
that does useful stuff. However, if you code in your testmethod
CustomMetadataTest.MockPlatform mockPlatform = new CustomMetadataTest.MockPlatform();
mockPlatform.xxx = ... // cloning examples from CustomMetadataTest.whenUpsertingByFieldMapSendsEvent
....
you get compiler exception that CustomMetadataTest Type is not visible.
There are some workarounds:
CustomMetadataTest.MockPlatform
in your own namespace/org (meh)!Test.isRunningTest()
to decide whether to execute String deployId = CustomMetadata.Operations...
(ugh)Or, the GitHub lib can move class MockPlatform
to a outer public class
Or, the GitHub lib could make CustomMetadata
public instead of private
Or ... ?
Since you made CustomMetadataTest.MockPlatform
public, you must have intended it to be reused in other classes.
Happy to do a PR once I understand your intent.
"On your blog, I suggested adding a custom field "context" to the
Platform Event SObject (someone else on the blog comments suggested
something similar - "topic") so the Platform Event consumer would have some
idea what use case generated the MD deployment action."
CustomMetadataValue
only handles primitives, so it fails on relationship fields. The value just needs to be converted to a string before being assigned.
I've gotten it to work by changing line 140 to this: cmv.value = dsr.soapType == Schema.SoapType.ID ? String.valueOf(fieldValue) : fieldValue;
As far as I can tell this is the only type that needs special handling.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.