This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 105
ALR Skunkworks testing: Java as a docs language #1267
Draft
ALRubinger
wants to merge
1
commit into
main
Choose a base branch
from
alr-skunkworks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module version="4"> | ||
<component name="AutoImportedSourceRoots"> | ||
<option name="directories"> | ||
<list> | ||
<option value="$MODULE_DIR$/testsuite-kotlin/src/main/java" /> | ||
<option value="$MODULE_DIR$/testsuite-kotlin/src/main/kotlin" /> | ||
<option value="$MODULE_DIR$/testsuite-kotlin/src/test/java" /> | ||
<option value="$MODULE_DIR$/testsuite-kotlin/src/test/kotlin" /> | ||
</list> | ||
</option> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module version="4"> | ||
<component name="AutoImportedSourceRoots"> | ||
<option name="directories"> | ||
<list> | ||
<option value="$MODULE_DIR$/src/main/java" /> | ||
<option value="$MODULE_DIR$/src/main/kotlin" /> | ||
<option value="$MODULE_DIR$/src/test/java" /> | ||
<option value="$MODULE_DIR$/src/test/kotlin" /> | ||
</list> | ||
</option> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
.../tbd/developer/site/java/docs/web5/build/decentralizedidentifiers/HowToCreateDidTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package website.tbd.developer.site.java.docs.web5.build.decentralizedidentifiers; | ||
|
||
import foundation.identity.did.DIDDocument; | ||
import org.junit.jupiter.api.Test; | ||
import web5.sdk.crypto.InMemoryKeyManager; | ||
import web5.sdk.dids.DidResolutionResult; | ||
import web5.sdk.dids.methods.dht.CreateDidDhtOptions; | ||
import web5.sdk.dids.methods.dht.DidDht; | ||
import web5.sdk.dids.methods.jwk.DidJwk; | ||
import web5.sdk.dids.methods.key.DidKey; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class HowToCreateDidTest | ||
{ | ||
|
||
@Test | ||
void createDidDht(){ | ||
|
||
// :snippet-start: createDidDhtJava | ||
// Creates a DID using the DHT method and publishes the DID Document to the DHT | ||
final DidDht didDht = DidDht.Default.create( | ||
new InMemoryKeyManager(), | ||
new CreateDidDhtOptions(null,null,true,null,null)); | ||
|
||
// DID String | ||
final String did = didDht.getUri(); | ||
|
||
// DID and its associated data which can be exported and used in different contexts/apps | ||
final DidResolutionResult portableDid = DidDht.Default.resolve(did,null); | ||
|
||
// DID Document | ||
final DIDDocument didDocument = portableDid.getDidDocument(); | ||
// :snippet-end: | ||
|
||
assertNotNull(did,"DID should not be null"); | ||
assertTrue(did.startsWith("did:dht"),"Did should start with 'did:dht'"); | ||
assertEquals(did, didDocument.getId().toString(),"ID of DID Document should match DID"); | ||
} | ||
|
||
@Test | ||
void createDidJwt() { | ||
// :snippet-start: createDidJwkJava | ||
// Creates a DID using the did:jwk method | ||
final DidJwk didJwk = DidJwk.Companion.create(new InMemoryKeyManager(), null); | ||
|
||
// DID and its associated data which can be exported and used in different contexts/apps | ||
final DidResolutionResult portableDid = didJwk.resolve(); | ||
|
||
// DID String | ||
final String did = didJwk.getUri(); | ||
|
||
// DID Document | ||
final DIDDocument didDocument = portableDid.getDidDocument(); | ||
// :snippet-end: | ||
|
||
assertNotNull(did, "DID should not be null"); | ||
assertTrue(did.startsWith("did:jwk"), "DID should start with 'did:jwk'"); | ||
assertNotNull(didDocument, "DID Document should not be null"); | ||
assertEquals(did, didDocument.getId().toString(),"ID od DID Document should match DID"); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make a clone of this doc and experiment with that one. I'm trying to get everyone to stop experimenting in our most widely used guide, as we've had to urgently do a fast-follow twice before (late at night) when changes have been merged and this top priority doc has been broken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pay no attention to that man behind the curtain. 🤣
Looks like I picked a hot article to port over as my end-to-end test. Not to worry - this PR isn't destined for any merge to
main
until we have cross-team coordination. It introduces an experimental feature I'm vetting. You won't be needing any late night fixes from this, my Island of Misfit Toys.