Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ Providers
* Avatar
* Aviation
* AWS
* Azure
* Babylon 5
* Back To The Future
* Barcode
Expand Down
147 changes: 147 additions & 0 deletions src/main/java/net/datafaker/providers/base/Azure.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
package net.datafaker.providers.base;


/**
* Generates data for Azure services. This is based on the Azure best practices of naming conventions:
* <a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/resource-naming">...</a>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small mistake here, I think you used IntelliJ to autofix the urls? (I had a similar issue.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Intellij :o) Thanks for fixing it

* <a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/resource-abbreviations">...</a>
*
* @since 1.7.0
*/
public class Azure extends AbstractProvider<BaseProviders> {

protected Azure(BaseProviders faker) {
super(faker);
}

public String region() {
return resolve("azure.regions");
}

public String subscriptionId() {
return faker.regexify("[a-f0-9]{8}") + '-' +
faker.regexify("[a-f0-9]{4}") + '-' +
faker.regexify("[a-f0-9]{4}") + '-' +
faker.regexify("[a-f0-9]{4}") + '-' +
faker.regexify("[a-f0-9]{12}");
}

public String tenantId() {
return subscriptionId();
}
public String resourceGroup() {
return "rg-" + randHex();
}

public String managementGroup() {
return "mg-" + randHex();
}

public String applicationGateway() {
return "agw-" + randHex();
}

public String bastionHost() {
return "bas-" + randHex();
}

public String firewall() {
return "afw-" + randHex();
}

public String loadBalancer() {
return "lbi-" + randHex();
}

public String networkSecurityGroup() {
return "nsg-" + randHex();
}

public String virtualNetwork() {
return "vnet-" + randHex();
}

public String virtualWan() {
return "vwan-" + randHex();
}

public String appServiceEnvironment() {
return "ase-" + randHex();
}

public String appServicePlan() {
return "asp-" + randHex();
}

public String loadTesting() {
return "lt-" + randHex();
}

public String staticWebApp() {
return "stapp-" + randHex();
}

public String virtualMachine() {
return "vm-" + randHex();
}

public String storageAccount() {
return "st-" + randHex();
}

public String containerRegistry() {
return "cr-" + randHex();
}

public String containerApps() {
return "ca-" + randHex();
}

public String containerAppsEnvironment() {
return "cae-" + randHex();
}

public String containerInstance() {
return "ci-" + randHex();
}

public String cosmosDBDatabase() {
return "cosmos-" + randHex();
}

public String sqlDatabase() {
return "sql-" + randHex();
}

public String mysqlDatabase() {
return "mysql-" + randHex();
}

public String postgreSQLDatabase() {
return "psql-" + randHex();
}

public String serviceBus() {
return "sb-" + randHex();
}

public String serviceBusQueue() {
return "sbq-" + randHex();
}

public String serviceBusTopic() {
return "sbt-" + randHex();
}

public String keyVault() {
return "kv-" + randHex();
}

public String logAnalytics() {
return "log-" + randHex();
}

private String randHex() {
return faker.regexify("[a-f0-9]{16}");
}
}
4 changes: 4 additions & 0 deletions src/main/java/net/datafaker/providers/base/BaseProviders.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ default Aws aws() {
return getProvider(Aws.class, Aws::new);
}

default Azure azure() {
return getProvider(Azure.class, Azure::new);
}

default Barcode barcode() {
return getProvider(Barcode.class, Barcode::new);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/datafaker/service/files/EnFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public String getPath() {
"australia.yml",
"aviation.yml",
"aws.yml",
"azure.yml",
"babylon5.yml",
"back_to_the_future.yml",
"barcode.yml",
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/en/azure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
en:
faker:
azure:
regions: [eastus, eastus2, southcentralus, westus2, westus3, australiaeast, southeastasia, northeurope, swedencentral, uksouth, westeurope, centralus, southafricanorth, centralindia, eastasia, japaneast, koreacentral, canadacentral, francecentral, germanywestcentral, norwayeast, switzerlandnorth, uaenorth, brazilsouth, eastus2euap, qatarcentral, centralusstage, eastusstage, eastus2stage, northcentralusstage, southcentralusstage, westusstage, westus2stage, asia, asiapacific, australia, brazil, canada, europe, france, germany, global, india, japan, korea, norway, singapore, southafrica, switzerland, uae, uk, unitedstates, unitedstateseuap, eastasiastage, southeastasiastage, eastusstg, southcentralusstg, northcentralus, westus, jioindiawest, centraluseuap, westcentralus, southafricawest, australiacentral, australiacentral2, australiasoutheast, japanwest, jioindiacentral, koreasouth, southindia, westindia, canadaeast, francesouth, germanynorth, norwaywest, switzerlandwest, ukwest, uaecentral, brazilsoutheast]
164 changes: 164 additions & 0 deletions src/test/java/net/datafaker/providers/base/AzureTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package net.datafaker.providers.base;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class AzureTest extends BaseFakerTest<BaseFaker> {

@Test
void testRegion() {
String region = faker.azure().region();
assertThat(region).matches("(eastus|eastus2|southcentralus|westus2|westus3|australiaeast|southeastasia|northeurope|swedencentral|uksouth|westeurope|centralus|southafricanorth|centralindia|eastasia|japaneast|koreacentral|canadacentral|francecentral|germanywestcentral|norwayeast|switzerlandnorth|uaenorth|brazilsouth|eastus2euap|qatarcentral|centralusstage|eastusstage|eastus2stage|northcentralusstage|southcentralusstage|westusstage|westus2stage|asia|asiapacific|australia|brazil|canada|europe|france|germany|global|india|japan|korea|norway|singapore|southafrica|switzerland|uae|uk|unitedstates|unitedstateseuap|eastasiastage|southeastasiastage|eastusstg|southcentralusstg|northcentralus|westus|jioindiawest|centraluseuap|westcentralus|southafricawest|australiacentral|australiacentral2|australiasoutheast|japanwest|jioindiacentral|koreasouth|southindia|westindia|canadaeast|francesouth|germanynorth|norwaywest|switzerlandwest|ukwest|uaecentral|brazilsoutheast)");
}

@Test
void testAccountId() {
assertThat(faker.azure().subscriptionId()).matches("[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}");
}

@Test
void testTenantId() {
assertThat(faker.azure().tenantId()).matches("[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}");
}

@Test
void testResourceGroup() {
assertThat(faker.azure().resourceGroup()).matches("^rg-[0-9a-f]{16}$");
}

@Test
void testManagementGroup() {
assertThat(faker.azure().managementGroup()).matches("^mg-[0-9a-f]{16}$");
}

@Test
void testApplicationGateway() {
assertThat(faker.azure().applicationGateway()).matches("^agw-[0-9a-f]{16}$");
}

@Test
void testBastionHost() {
assertThat(faker.azure().bastionHost()).matches("^bas-[0-9a-f]{16}$");
}

@Test
void testFirewall() {
assertThat(faker.azure().firewall()).matches("^afw-[0-9a-f]{16}$");
}

@Test
void testLoadBalancer() {
assertThat(faker.azure().loadBalancer()).matches("^lbi-[0-9a-f]{16}$");
}

@Test
void testNetworkSecurityGroup() {
assertThat(faker.azure().networkSecurityGroup()).matches("^nsg-[0-9a-f]{16}$");
}

@Test
void testVirtualNetwork() {
assertThat(faker.azure().virtualNetwork()).matches("^vnet-[0-9a-f]{16}$");
}

@Test
void testVirtualWan() {
assertThat(faker.azure().virtualWan()).matches("^vwan-[0-9a-f]{16}$");
}

@Test
void testAppServiceEnvironment() {
assertThat(faker.azure().appServiceEnvironment()).matches("^ase-[0-9a-f]{16}$");
}

@Test
void testAppServicePlan() {
assertThat(faker.azure().appServicePlan()).matches("^asp-[0-9a-f]{16}$");
}

@Test
void testLoadTesting() {
assertThat(faker.azure().loadTesting()).matches("^lt-[0-9a-f]{16}$");
}

@Test
void testStaticWebApp() {
assertThat(faker.azure().staticWebApp()).matches("^stapp-[0-9a-f]{16}$");
}

@Test
void testVirtualMachine() {
assertThat(faker.azure().virtualMachine()).matches("^vm-[0-9a-f]{16}$");
}

@Test
void testStorageAccount() {
assertThat(faker.azure().storageAccount()).matches("^st-[0-9a-f]{16}$");
}

@Test
void testContainerRegistry() {
assertThat(faker.azure().containerRegistry()).matches("^cr-[0-9a-f]{16}$");
}

@Test
void testContainerApps() {
assertThat(faker.azure().containerApps()).matches("^ca-[0-9a-f]{16}$");
}

@Test
void testContainerAppsEnvironment() {
assertThat(faker.azure().containerAppsEnvironment()).matches("^cae-[0-9a-f]{16}$");
}

@Test
void testContainerInstance() {
assertThat(faker.azure().containerInstance()).matches("^ci-[0-9a-f]{16}$");
}

@Test
void testCosmosDBDatabase() {
assertThat(faker.azure().cosmosDBDatabase()).matches("^cosmos-[0-9a-f]{16}$");
}

@Test
void testSqlDatabase() {
assertThat(faker.azure().sqlDatabase()).matches("^sql-[0-9a-f]{16}$");
}

@Test
void testMysqlDatabase() {
assertThat(faker.azure().mysqlDatabase()).matches("^mysql-[0-9a-f]{16}$");
}

@Test
void testPostgreSQLDatabase() {
assertThat(faker.azure().postgreSQLDatabase()).matches("^psql-[0-9a-f]{16}$");
}

@Test
void testServiceBus() {
assertThat(faker.azure().serviceBus()).matches("^sb-[0-9a-f]{16}$");
}

@Test
void testServiceBusQueue() {
assertThat(faker.azure().serviceBusQueue()).matches("^sbq-[0-9a-f]{16}$");
}

@Test
void testServiceBusTopic() {
assertThat(faker.azure().serviceBusTopic()).matches("^sbt-[0-9a-f]{16}$");
}

@Test
void testKeyVault() {
assertThat(faker.azure().keyVault()).matches("^kv-[0-9a-f]{16}$");
}

@Test
void testLogAnalytics() {
assertThat(faker.azure().logAnalytics()).matches("^log-[0-9a-f]{16}$");
}
}