Skip to content

Commit

Permalink
Add !uuid as a wiki symbol to generate a UUID (#36)
Browse files Browse the repository at this point in the history
Add !randomUuid as a wiki symbol to generate a UUID
  • Loading branch information
tcnh authored Feb 6, 2020
1 parent e428b98 commit 6391145
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void registerSymbolTypes(SymbolProvider symbolProvider) throws PluginExce
add(symbolProvider, new DefineDefault());
add(symbolProvider, new DefineFromProperties());
add(symbolProvider, new DefineDefaultFromProperties());
add(symbolProvider, new RandomUuid());
}

private void add(SymbolProvider provider, SymbolType symbolType) {
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/nl/hsac/fitnesse/symbols/RandomUuid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package nl.hsac.fitnesse.symbols;

import fitnesse.wikitext.parser.*;
import java.util.UUID;

public class RandomUuid extends SymbolBase implements Rule, Translation {

public RandomUuid() {
super("Uuid");
wikiMatcher(new Matcher().string("!randomUuid"));
wikiRule(this);
htmlTranslation(this);
}

@Override
public Maybe<Symbol> parse(Symbol current, Parser parser) {
return new Maybe<>(current);
}

@Override
public String toTarget(Translator translator, Symbol symbol) {
return UUID.randomUUID().toString();
}
}
1 change: 1 addition & 0 deletions src/test/wiki/FitNesseRoot/HsacPlugin/Symbols.wiki
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ Some extra Wiki symbols that can be used:
|random Iban (country code) |{{{!-!randomIBAN (FR)-! }}} |!randomIBAN (FR) |
|random Postal Code (using default NL) |{{{!-!randomPostalCode-! }}} |!randomPostalCode |
|random Postal Code (possible: AU, BE, BR, CA, CH, DE, GL, FR, IT, NL, NO, US) |{{{!-!randomPostalCode (FR)-! }}} |!randomPostalCode (FR) |
|random universally unique identifier (UUID) |{{{!-!randomUuid-! }}} |!randomUuid |

0 comments on commit 6391145

Please sign in to comment.