Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<commerce_inventory.UpsertItemReservationRequest> itemReqeustList = new List<commerce_inventory.UpsertItemReservationRequest>();
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());
}
Expand All @@ -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');
Expand All @@ -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<commerce_inventory.InventoryCheckItemAvailability> itemReqeustSet = new Set<commerce_inventory.InventoryCheckItemAvailability>();
itemReqeustSet.add(itemRequest);
commerce_inventory.InventoryCheckAvailability request = new commerce_inventory.InventoryCheckAvailability(itemReqeustSet);

CommerceInventoryServiceSample inventoryService = new CommerceInventoryServiceSample();
// Act
Test.startTest();
Expand All @@ -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<commerce_inventory.InventoryLevelsItemRequest> itemRequestSet = new Set<commerce_inventory.InventoryLevelsItemRequest>();
commerce_inventory.InventoryLevelsItemRequest itemRequest = new commerce_inventory.InventoryLevelsItemRequest('01txx0000001aBcAAI', 'sku1','a1Bxx0000005T9E');
Set<commerce_inventory.InventoryLevelsItemRequest> itemRequestSet = new Set<commerce_inventory.InventoryLevelsItemRequest>();
itemRequestSet.add(itemRequest);
commerce_inventory.InventoryLevelsRequest request = new commerce_inventory.InventoryLevelsRequest(null, itemRequestSet);

Expand All @@ -99,7 +99,7 @@ public class CommerceInventoryServiceSampleTest {
break;
}

System.assertEquals(itemExpectedResponse.getProductId(), itemActualResponse.getProductId());
System.assertEquals(itemExpectedResponse.getProductId(), itemActualResponse.getProductId());
}

@IsTest
Expand All @@ -119,7 +119,7 @@ public class CommerceInventoryServiceSampleTest {
errorMessage = 'Sucess Response';
} catch(InventoryValidationException validationtEx) {
errorMessage = validationtEx.getMessage();

}
Test.stopTest();

Expand Down Expand Up @@ -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;
}
}
}
}
}
}