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);
}
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());
}
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);
}
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);
}
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();
}
Aggregations