use of bio.terra.model.BillingProfileRequestModel in project jade-data-repo by DataBiosphere.
the class DataRepoFixtures method createBillingProfile.
// Create a Billing Profile model: expect successful creation
public BillingProfileModel createBillingProfile(TestConfiguration.User user) throws Exception {
BillingProfileRequestModel billingProfileRequestModel = ProfileFixtures.randomBillingProfileRequest();
String json = TestUtils.mapToJson(billingProfileRequestModel);
DataRepoResponse<BillingProfileModel> postResponse = dataRepoClient.post(user, "/api/resources/v1/profiles", json, BillingProfileModel.class);
assertThat("billing profile model is successfuly created", postResponse.getStatusCode(), equalTo(HttpStatus.CREATED));
assertTrue("create billing profile model response is present", postResponse.getResponseObject().isPresent());
return postResponse.getResponseObject().get();
}
use of bio.terra.model.BillingProfileRequestModel in project jade-data-repo by DataBiosphere.
the class OneProjectPerProfileIdSelectorTest method shouldGetCorrectIdForSnapshot.
@Test
public void shouldGetCorrectIdForSnapshot() throws Exception {
String coreBillingAccountId = resourceConfiguration.getCoreBillingAccount();
String profileName = ProfileFixtures.randomHex(16);
BillingProfileRequestModel billingProfileRequestModel = ProfileFixtures.randomBillingProfileRequest().billingAccountId(coreBillingAccountId).profileName(profileName);
BillingProfileModel profile = profileService.createProfile(billingProfileRequestModel);
DatasetSummaryModel datasetSummaryModel = connectedOperations.createDataset(profile, "snapshot-test-dataset.json");
SnapshotSummaryModel snapshotSummaryModel = connectedOperations.createSnapshot(datasetSummaryModel, "snapshot-test-snapshot.json", "");
SnapshotModel snapshotModel = connectedOperations.getSnapshot(snapshotSummaryModel.getId());
Snapshot snapshot = snapshotService.retrieve(UUID.fromString(snapshotModel.getId()));
// TODO: we can test this once configuring firestore is programatic
String projectId = oneProjectPerProfileIdSelector.projectIdForSnapshot(snapshot);
String expectedProfileId = resourceConfiguration.getProjectId() + "-" + profileName;
assertThat("Project ID is what we expect", projectId, equalTo(expectedProfileId));
}
use of bio.terra.model.BillingProfileRequestModel in project jade-data-repo by DataBiosphere.
the class BillingProfileRequestValidator method validate.
@Override
public void validate(@NotNull Object target, Errors errors) {
if (target != null && target instanceof BillingProfileRequestModel) {
BillingProfileRequestModel billingProfileRequestModel = (BillingProfileRequestModel) target;
String billingAccountId = billingProfileRequestModel.getBillingAccountId();
if (!isValidAccountId(billingAccountId)) {
errors.rejectValue("billingAccountId", "The id must be 3 sets of 6 capitalized alphanumeric characters separated by dashes");
}
}
}
use of bio.terra.model.BillingProfileRequestModel in project jade-data-repo by DataBiosphere.
the class OneProjectPerProfileIdSelectorTest method shouldGetCorrectIdForDataset.
@Test
public void shouldGetCorrectIdForDataset() throws Exception {
String coreBillingAccountId = resourceConfiguration.getCoreBillingAccount();
String profileName = ProfileFixtures.randomHex(16);
BillingProfileRequestModel billingProfileRequestModel = ProfileFixtures.randomBillingProfileRequest().billingAccountId(coreBillingAccountId).profileName(profileName);
BillingProfileModel profile = profileService.createProfile(billingProfileRequestModel);
DatasetSummaryModel datasetSummaryModel = connectedOperations.createDataset(profile, "dataset-minimal.json");
Dataset dataset = datasetService.retrieve(UUID.fromString(datasetSummaryModel.getId()));
String projectId = oneProjectPerProfileIdSelector.projectIdForDataset(dataset);
String expectedProfileId = resourceConfiguration.getProjectId() + "-" + profileName;
assertThat("Project ID is what we expect", projectId, equalTo(expectedProfileId));
}
use of bio.terra.model.BillingProfileRequestModel in project jade-data-repo by DataBiosphere.
the class OneProjectPerProfileIdSelectorTest method shouldGetCorrectIdForDatasetWithSpecialChars.
@Test
public void shouldGetCorrectIdForDatasetWithSpecialChars() throws Exception {
String coreBillingAccountId = resourceConfiguration.getCoreBillingAccount();
String namePrefix = "chars ";
String hexDigits = ProfileFixtures.randomHex(8);
String profileName = namePrefix + hexDigits;
BillingProfileRequestModel billingProfileRequestModel = ProfileFixtures.randomBillingProfileRequest().billingAccountId(coreBillingAccountId).profileName(profileName);
BillingProfileModel profile = profileService.createProfile(billingProfileRequestModel);
DatasetSummaryModel datasetSummaryModel = connectedOperations.createDataset(profile, "dataset-minimal.json");
Dataset dataset = datasetService.retrieve(UUID.fromString(datasetSummaryModel.getId()));
String projectId = oneProjectPerProfileIdSelector.projectIdForDataset(dataset);
String expectedProfileId = resourceConfiguration.getProjectId() + "-" + "chars--" + hexDigits;
assertThat("Project ID is what we expect", projectId, equalTo(expectedProfileId));
}
Aggregations