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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skunkworks testing: Java as a docs language
* Configure Kotlin and Java sources to coexist in the testsuite * Make a real Java port of an existing Kotlin test * Hook Java snippets into docs * Add Java support to Shnippet * Configure Docusaurus CodeBlock component for Java syntax highlighting * Add Java support to CodeSnippet component * Work around a ReDoc bug (java language support needs scala too)
- Loading branch information
1 parent
df7b4c0
commit cac3666
Showing
8 changed files
with
174 additions
and
7 deletions.
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"); | ||
} | ||
|
||
} |