@Test public void testUpdateFundWithEmptyParams() { FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)) .externalId(Utils.randomNameGenerator("fund-", 5)) .build(); String jsonData = fh.toJSON(); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); Assert.assertNotNull(fundID); FundsHelper fh2 = FundsResourceHandler.updateFund( fundID, null, null, this.requestSpec, this.statusOkResponseSpec); Assert.assertNull(fh2.getName()); Assert.assertNull(fh2.getExternalId()); // assert that there was no change in // the name and external ID of the fund jsonData = FundsResourceHandler.retrieveFund(fundID, this.requestSpec, this.statusOkResponseSpec); FundsHelper fh3 = new Gson().fromJson(jsonData, FundsHelper.class); Assert.assertEquals(fh.getName(), fh3.getName()); Assert.assertEquals(fh.getExternalId(), fh3.getExternalId()); }
@Test public void testUpdateFundWithNewExternalId() { FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)) .externalId(Utils.randomNameGenerator("fund-", 5)) .build(); String jsonData = fh.toJSON(); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); Assert.assertNotNull(fundID); String newExternalId = Utils.randomNameGenerator("fund-", 5); FundsHelper fh2 = FundsResourceHandler.updateFund( fundID, null, newExternalId, this.requestSpec, this.statusOkResponseSpec); Assert.assertEquals(newExternalId, fh2.getExternalId()); }
@Test public void testCreateFundWithDuplicateExternalId() { FundsHelper fh = FundsHelper.create(Utils.randomNameGenerator("", 10)) .externalId(Utils.randomNameGenerator("fund-", 5)) .build(); String jsonData = fh.toJSON(); final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec); Assert.assertNotNull(fundID); FundsHelper fh2 = FundsHelper.create(Utils.randomNameGenerator("", 10)) .externalId(fh.getExternalId()) .build(); jsonData = fh2.toJSON(); ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build(); final Long fundID2 = createFund(jsonData, this.requestSpec, responseSpec); Assert.assertNull(fundID2); }