diff --git a/commerce/domain/inventory/service/classes/CommerceInventoryServiceSampleTest.cls b/commerce/domain/inventory/service/classes/CommerceInventoryServiceSampleTest.cls index 57e79c2..e972bab 100644 --- a/commerce/domain/inventory/service/classes/CommerceInventoryServiceSampleTest.cls +++ b/commerce/domain/inventory/service/classes/CommerceInventoryServiceSampleTest.cls @@ -4,34 +4,34 @@ public class CommerceInventoryServiceSampleTest { @IsTest public static void testUpsertReservation() { // Arrange - commerce_inventory.UpsertItemReservationRequest itemRequest = new commerce_inventory.UpsertItemReservationRequest(double.valueOf('10.0'), Id.valueOf('0ghSG0000000JFbYAM'), Id.valueOf('0a9SG000003AfY1YAK'), Id.valueOf('01tSG000001NNgKYAW')); + commerce_inventory.UpsertItemReservationRequest itemRequest = new commerce_inventory.UpsertItemReservationRequest(double.valueOf('10.0'), Id.valueOf('0ghSG0000000JFbYAM'), Id.valueOf('0a9SG000003AfY1YAK'), Id.valueOf('01tSG000001NNgKYAW'), null); List itemReqeustList = new List(); itemReqeustList.add(itemRequest); - commerce_inventory.upsertReservationRequest request = new commerce_inventory.upsertReservationRequest('4y2ml0e1oG2qrcfdbNnNyk', '0a9SG000003AfY1YAK', itemReqeustList); + commerce_inventory.upsertReservationRequest request = new commerce_inventory.upsertReservationRequest(Integer.valueOf(100),'4y2ml0e1oG2qrcfdbNnNyk', '0a9SG000003AfY1YAK', itemReqeustList); CommerceInventoryServiceSample inventoryService = new CommerceInventoryServiceSample(); - + // Act Test.startTest(); commerce_inventory.UpsertReservationResponse actualResponse = inventoryService.upsertReservation(request, null,''); Test.stopTest(); - + // Assert commerce_inventory.UpsertItemReservationResponse itemActualResponse = actualResponse.getItems().get(0); commerce_inventory.UpsertReservationResponse expectedResponse = createUpsertReservationResponse(); commerce_inventory.UpsertItemReservationResponse itemExpectedResponse = expectedResponse.getItems().get(0); - + System.assertEquals(itemExpectedResponse.getProductId(), itemActualResponse.getProductId()); - + } - + @IsTest public static void testDeleteReservation() { // Arrange CommerceInventoryServiceSampleMock inventoryServiceMock = new CommerceInventoryServiceSampleMock(); - + // Act commerce_inventory.DeleteReservationResponse response = inventoryServiceMock.deleteReservation('10rxx000007LbIRAA0', null); - + // Assert System.assertEquals(true, response.getSucceed()); } @@ -41,7 +41,7 @@ public class CommerceInventoryServiceSampleTest { // Arrange CommerceInventoryServiceSampleMock inventoryServiceMock = new CommerceInventoryServiceSampleMock(); - + // Act commerce_inventory.InventoryReservation response = inventoryServiceMock.getReservation('10rxx000007LbIRAA0'); commerce_inventory.InventoryReservation response2 = inventoryServiceMock.getReservation('10rxx000007LbIRAA1'); @@ -50,15 +50,15 @@ public class CommerceInventoryServiceSampleTest { System.assertNotEquals(null, response); System.assertEquals(null, response2); } - + @IsTest public static void testCheckInventory() { // Arrange - commerce_inventory.InventoryCheckItemAvailability itemRequest = new commerce_inventory.InventoryCheckItemAvailability(); + commerce_inventory.InventoryCheckItemAvailability itemRequest = new commerce_inventory.InventoryCheckItemAvailability(double.valueOf('10.0'),double.valueOf('10.0'),double.valueOf('10.0'),double.valueOf('10.0'),'OnHand','10rxx000007LbIRAA0','10rxx000007LbIRAA0','LocationGroup'); Set itemReqeustSet = new Set(); itemReqeustSet.add(itemRequest); commerce_inventory.InventoryCheckAvailability request = new commerce_inventory.InventoryCheckAvailability(itemReqeustSet); - + CommerceInventoryServiceSample inventoryService = new CommerceInventoryServiceSample(); // Act Test.startTest(); @@ -70,14 +70,14 @@ public class CommerceInventoryServiceSampleTest { itemActualResponse = item; break; } - System.assertEquals(true, itemActualResponse.isAvailable()); + System.assertEquals(true, itemActualResponse.isAvailable()); } @IsTest public static void testgetInventoryLevel() { // Arrange - commerce_inventory.InventoryLevelsItemRequest itemRequest = new commerce_inventory.InventoryLevelsItemRequest(Id.valueOf('01txx0000001aBcAAI'), 'sku1', Id.valueOf('a1Bxx0000005T9E')); - Set itemRequestSet = new Set(); + commerce_inventory.InventoryLevelsItemRequest itemRequest = new commerce_inventory.InventoryLevelsItemRequest('01txx0000001aBcAAI', 'sku1','a1Bxx0000005T9E'); + Set itemRequestSet = new Set(); itemRequestSet.add(itemRequest); commerce_inventory.InventoryLevelsRequest request = new commerce_inventory.InventoryLevelsRequest(null, itemRequestSet); @@ -99,7 +99,7 @@ public class CommerceInventoryServiceSampleTest { break; } - System.assertEquals(itemExpectedResponse.getProductId(), itemActualResponse.getProductId()); + System.assertEquals(itemExpectedResponse.getProductId(), itemActualResponse.getProductId()); } @IsTest @@ -119,7 +119,7 @@ public class CommerceInventoryServiceSampleTest { errorMessage = 'Sucess Response'; } catch(InventoryValidationException validationtEx) { errorMessage = validationtEx.getMessage(); - + } Test.stopTest(); @@ -154,24 +154,24 @@ public class CommerceInventoryServiceSampleTest { response.setItemsInventoryLevels(items); return response; } - + private class CommerceInventoryServiceSampleMock extends CommerceInventoryServiceSample { - + public override commerce_inventory.DeleteReservationResponse callDefaultDeleteReservation(String reservationId, commerce_inventory.InventoryReservation currentReservation) { commerce_inventory.DeleteReservationResponse responseMock = new commerce_inventory.DeleteReservationResponse(); responseMock.setSucceed(true); return responseMock; } - - + + public override commerce_inventory.InventoryReservation callDefaultGetReservation(String reservationId) { if (reservationId == '10rxx000007LbIRAA0') { commerce_inventory.InventoryReservation responseMock = new commerce_inventory.InventoryReservation(); responseMock.setReservationIdentifier(reservationId); - return responseMock; + return responseMock; } else { return null; - } + } } - } + } } \ No newline at end of file