Search in sources :

Example 1 with BillingProfileModel

use of bio.terra.model.BillingProfileModel in project jade-data-repo by DataBiosphere.

the class ResourcesApiController method retrieveProfile.

@Override
public ResponseEntity<BillingProfileModel> retrieveProfile(String id) {
    UUID profileId = UUID.fromString(id);
    BillingProfile profile = profileService.getProfileById(profileId);
    BillingProfileModel profileModel = profileService.makeModelFromBillingProfile(profile);
    return new ResponseEntity<>(profileModel, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) UUID(java.util.UUID) BillingProfileModel(bio.terra.model.BillingProfileModel) EnumerateBillingProfileModel(bio.terra.model.EnumerateBillingProfileModel)

Example 2 with BillingProfileModel

use of bio.terra.model.BillingProfileModel in project jade-data-repo by DataBiosphere.

the class ProfileTest method testCreateReadDelete.

@Test
public void testCreateReadDelete() throws Exception {
    String accountId = ProfileFixtures.randomBillingAccountId();
    billingProfileRequest.billingAccountId(accountId);
    String responseJson = mvc.perform(post("/api/resources/v1/profiles").contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer: faketoken").content(TestUtils.mapToJson(billingProfileRequest))).andExpect(status().isCreated()).andExpect(jsonPath("$.profileName").value("Test billing account")).andExpect(jsonPath("$.biller").value("direct")).andExpect(jsonPath("$.billingAccountId").value(accountId)).andReturn().getResponse().getContentAsString();
    BillingProfileModel profileModel = objectMapper.readerFor(BillingProfileModel.class).readValue(responseJson);
    String profileId = profileModel.getId();
    mvc.perform(get("/api/resources/v1/profiles/" + profileId).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer: faketoken")).andExpect(status().isOk()).andExpect(jsonPath("$.profileName").value("Test billing account")).andExpect(jsonPath("$.biller").value("direct")).andExpect(jsonPath("$.billingAccountId").value(accountId)).andExpect(jsonPath("$.id").value(profileId));
    mvc.perform(delete("/api/resources/v1/profiles/" + profileId).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer: faketoken")).andExpect(status().isOk()).andExpect(jsonPath("$.objectState").value("deleted"));
    mvc.perform(delete("/api/resources/v1/profiles/" + profileId).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer: faketoken")).andExpect(status().isOk()).andExpect(jsonPath("$.objectState").value("not_found"));
    mvc.perform(get("/api/resources/v1/profiles/" + profileId).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer: faketoken")).andExpect(status().isNotFound());
}
Also used : BillingProfileModel(bio.terra.model.BillingProfileModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with BillingProfileModel

use of bio.terra.model.BillingProfileModel in project jade-data-repo by DataBiosphere.

the class DataRepoFixtures method createDatasetRaw.

// datasets
public DataRepoResponse<JobModel> createDatasetRaw(TestConfiguration.User user, String filename) throws Exception {
    DatasetRequestModel requestModel = jsonLoader.loadObject(filename, DatasetRequestModel.class);
    BillingProfileModel billingProfileModel = this.createBillingProfile(user);
    requestModel.setDefaultProfileId(billingProfileModel.getId());
    requestModel.setName(Names.randomizeName(requestModel.getName()));
    String json = TestUtils.mapToJson(requestModel);
    return dataRepoClient.post(user, "/api/repository/v1/datasets", json, JobModel.class);
}
Also used : DatasetRequestModel(bio.terra.model.DatasetRequestModel) BillingProfileModel(bio.terra.model.BillingProfileModel)

Example 4 with BillingProfileModel

use of bio.terra.model.BillingProfileModel in project jade-data-repo by DataBiosphere.

the class DataRepoFixtures method createSnapshotWithRequestLaunch.

public DataRepoResponse<JobModel> createSnapshotWithRequestLaunch(TestConfiguration.User user, String datasetName, SnapshotRequestModel requestModel) throws Exception {
    BillingProfileModel billingProfileModel = this.createBillingProfile(user);
    requestModel.setName(Names.randomizeName(requestModel.getName()));
    requestModel.getContents().get(0).setDatasetName(datasetName);
    requestModel.setProfileId(billingProfileModel.getId());
    String json = TestUtils.mapToJson(requestModel);
    return dataRepoClient.post(user, "/api/repository/v1/snapshots", json, JobModel.class);
}
Also used : BillingProfileModel(bio.terra.model.BillingProfileModel)

Example 5 with BillingProfileModel

use of bio.terra.model.BillingProfileModel 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)

Aggregations

BillingProfileModel (bio.terra.model.BillingProfileModel)10 BillingProfileRequestModel (bio.terra.model.BillingProfileRequestModel)4 DatasetSummaryModel (bio.terra.model.DatasetSummaryModel)4 Test (org.junit.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 SnapshotModel (bio.terra.model.SnapshotModel)2 SnapshotSummaryModel (bio.terra.model.SnapshotSummaryModel)2 Dataset (bio.terra.service.dataset.Dataset)2 DatasetRequestModel (bio.terra.model.DatasetRequestModel)1 EnumerateBillingProfileModel (bio.terra.model.EnumerateBillingProfileModel)1 ErrorModel (bio.terra.model.ErrorModel)1 IngestRequestModel (bio.terra.model.IngestRequestModel)1 Snapshot (bio.terra.service.snapshot.Snapshot)1 BigQuery (com.google.cloud.bigquery.BigQuery)1 Blob (com.google.cloud.storage.Blob)1 Storage (com.google.cloud.storage.Storage)1 UUID (java.util.UUID)1 ResponseEntity (org.springframework.http.ResponseEntity)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1