Search in sources :

Example 1 with BillingProfileRequestModel

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();
}
Also used : BillingProfileRequestModel(bio.terra.model.BillingProfileRequestModel) BillingProfileModel(bio.terra.model.BillingProfileModel)

Example 2 with BillingProfileRequestModel

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));
}
Also used : Snapshot(bio.terra.service.snapshot.Snapshot) SnapshotSummaryModel(bio.terra.model.SnapshotSummaryModel) BillingProfileRequestModel(bio.terra.model.BillingProfileRequestModel) DatasetSummaryModel(bio.terra.model.DatasetSummaryModel) BillingProfileModel(bio.terra.model.BillingProfileModel) SnapshotModel(bio.terra.model.SnapshotModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with BillingProfileRequestModel

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");
        }
    }
}
Also used : BillingProfileRequestModel(bio.terra.model.BillingProfileRequestModel)

Example 4 with BillingProfileRequestModel

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));
}
Also used : Dataset(bio.terra.service.dataset.Dataset) BillingProfileRequestModel(bio.terra.model.BillingProfileRequestModel) DatasetSummaryModel(bio.terra.model.DatasetSummaryModel) BillingProfileModel(bio.terra.model.BillingProfileModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with BillingProfileRequestModel

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));
}
Also used : Dataset(bio.terra.service.dataset.Dataset) BillingProfileRequestModel(bio.terra.model.BillingProfileRequestModel) DatasetSummaryModel(bio.terra.model.DatasetSummaryModel) BillingProfileModel(bio.terra.model.BillingProfileModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

BillingProfileRequestModel (bio.terra.model.BillingProfileRequestModel)5 BillingProfileModel (bio.terra.model.BillingProfileModel)4 DatasetSummaryModel (bio.terra.model.DatasetSummaryModel)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Dataset (bio.terra.service.dataset.Dataset)2 SnapshotModel (bio.terra.model.SnapshotModel)1 SnapshotSummaryModel (bio.terra.model.SnapshotSummaryModel)1 Snapshot (bio.terra.service.snapshot.Snapshot)1