-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from gappc/implement-support-for-2022-10
Add support for AlpineBits HotelData 2022-10
- Loading branch information
Showing
26 changed files
with
4,490 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...n/java/it/bz/opendatahub/alpinebitsserver/application/common/routing/RoutesFor202210.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// SPDX-FileCopyrightText: NOI Techpark <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package it.bz.opendatahub.alpinebitsserver.application.common.routing; | ||
|
||
import it.bz.opendatahub.alpinebits.common.constants.AlpineBitsCapability; | ||
import it.bz.opendatahub.alpinebits.common.constants.AlpineBitsVersion; | ||
import it.bz.opendatahub.alpinebits.handshaking.DefaultContextSerializer; | ||
import it.bz.opendatahub.alpinebits.handshaking.middleware.HandshakingMiddleware; | ||
import it.bz.opendatahub.alpinebits.routing.DefaultRouter; | ||
import it.bz.opendatahub.alpinebits.routing.RoutingBuilder; | ||
import it.bz.opendatahub.alpinebits.routing.constants.Action; | ||
import it.bz.opendatahub.alpinebitsserver.odh.freerooms.HotelInvCountNotifPushMiddlewareBuilder; | ||
import it.bz.opendatahub.alpinebitsserver.odh.inventory.v_2022_10.InventoryPullMiddlewareBuilder; | ||
import it.bz.opendatahub.alpinebitsserver.odh.inventory.v_2022_10.InventoryPushMiddlewareBuilder; | ||
|
||
/** | ||
* Route definitions for AlpineBits 2022-10. | ||
*/ | ||
public final class RoutesFor202210 { | ||
|
||
private RoutesFor202210() { | ||
// Empty | ||
} | ||
|
||
/** | ||
* Add 2022-10 routes to the given builder. | ||
* | ||
* @param builder The routes will be added to this builder. | ||
* @return A {@link RoutingBuilder.FinalBuilder} that can be used for further route building. | ||
*/ | ||
public static RoutingBuilder.FinalBuilder routes(DefaultRouter.Builder builder) { | ||
if (builder == null) { | ||
throw new IllegalArgumentException("The builder must not be null"); | ||
} | ||
return builder.version(AlpineBitsVersion.V_2022_10) | ||
.supportsAction(Action.HANDSHAKING) | ||
.withCapabilities(AlpineBitsCapability.HANDSHAKING) | ||
.using(new HandshakingMiddleware(new DefaultContextSerializer(AlpineBitsVersion.V_2022_10))) | ||
.and() | ||
.supportsAction(Action.INVENTORY_BASIC_PULL) | ||
.withCapabilities(AlpineBitsCapability.INVENTORY_HOTEL_DESCRIPTIVE_INFO_INVENTORY) | ||
.using(InventoryPullMiddlewareBuilder.buildInventoryPullMiddleware()) | ||
.and() | ||
.supportsAction(Action.INVENTORY_HOTEL_INFO_PULL) | ||
.withCapabilities(AlpineBitsCapability.INVENTORY_HOTEL_DESCRIPTIVE_INFO_INFO) | ||
.using(InventoryPullMiddlewareBuilder.buildInventoryPullMiddleware()) | ||
.and() | ||
.supportsAction(Action.INVENTORY_BASIC_PUSH) | ||
.withCapabilities( | ||
AlpineBitsCapability.INVENTORY_HOTEL_DESCRIPTIVE_CONTENT_NOTIF_INVENTORY, | ||
AlpineBitsCapability.INVENTORY_HOTEL_DESCRIPTIVE_CONTENT_NOTIF_INVENTORY_USE_ROOMS, | ||
AlpineBitsCapability.INVENTORY_HOTEL_DESCRIPTIVE_CONTENT_NOTIF_OCCUPANCY_CHILDREN | ||
) | ||
.using(InventoryPushMiddlewareBuilder.buildInventoryPushMiddleware()) | ||
.and() | ||
.supportsAction(Action.INVENTORY_HOTEL_INFO_PUSH) | ||
.withCapabilities(AlpineBitsCapability.INVENTORY_HOTEL_DESCRIPTIVE_CONTENT_NOTIF_INFO) | ||
.using(InventoryPushMiddlewareBuilder.buildInventoryPushMiddleware()) | ||
.and() | ||
.supportsAction(Action.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF_FREE_ROOMS) | ||
.withCapabilities( | ||
AlpineBitsCapability.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF, | ||
AlpineBitsCapability.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF_ACCEPT_ROOMS, | ||
AlpineBitsCapability.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF_ACCEPT_CATEGORIES, | ||
AlpineBitsCapability.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF_ACCEPT_OUT_OF_ORDER, | ||
AlpineBitsCapability.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF_ACCEPT_OUT_OF_MARKET, | ||
AlpineBitsCapability.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF_ACCEPT_CLOSING_SEASONS, | ||
AlpineBitsCapability.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF_ACCEPT_COMPLETE_SET | ||
) | ||
.using(HotelInvCountNotifPushMiddlewareBuilder.buildFreeRoomsPushMiddleware(AlpineBitsVersion.V_2022_10)) | ||
.versionComplete(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...va/it/bz/opendatahub/alpinebitsserver/application/common/routing/RoutesFor202210Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// SPDX-FileCopyrightText: NOI Techpark <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package it.bz.opendatahub.alpinebitsserver.application.common.routing; | ||
|
||
import it.bz.opendatahub.alpinebits.common.constants.AlpineBitsCapability; | ||
import it.bz.opendatahub.alpinebits.common.constants.AlpineBitsVersion; | ||
import it.bz.opendatahub.alpinebits.routing.DefaultRouter; | ||
import it.bz.opendatahub.alpinebits.routing.Router; | ||
import it.bz.opendatahub.alpinebits.routing.RoutingBuilder; | ||
import it.bz.opendatahub.alpinebits.routing.constants.Action; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Set; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
/** | ||
* Tests for {@link RoutesFor202210}. | ||
*/ | ||
public class RoutesFor202210Test { | ||
|
||
private static final String ALPINEBITS_VERSION = AlpineBitsVersion.V_2022_10; | ||
|
||
@Test(expectedExceptions = IllegalArgumentException.class) | ||
public void testRoutes_ShouldThrow_WhenBuilderIsNull() { | ||
RoutesFor202210.routes(null); | ||
} | ||
|
||
@Test | ||
public void testRoutes_ShouldReturnFinalBuild_OnSuccess() { | ||
RoutingBuilder.FinalBuilder builder = RoutesFor202210.routes(new DefaultRouter.Builder()); | ||
Router router = builder.buildRouter(); | ||
|
||
assertEquals(router.getVersions().size(), 1); | ||
assertTrue(router.getVersions().contains(ALPINEBITS_VERSION)); | ||
|
||
assertTrue(router.getActionsForVersion(ALPINEBITS_VERSION).isPresent()); | ||
Set<Action> actions = router.getActionsForVersion(ALPINEBITS_VERSION).get(); | ||
|
||
assertEquals(actions.size(), 6); | ||
assertTrue(actions.contains(Action.HANDSHAKING)); | ||
assertTrue(actions.contains(Action.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF_FREE_ROOMS)); | ||
|
||
assertTrue(router.getCapabilitiesForVersion(ALPINEBITS_VERSION).isPresent()); | ||
Set<String> capabilities = router.getCapabilitiesForVersion(ALPINEBITS_VERSION).get(); | ||
|
||
assertEquals(capabilities.size(), 14); | ||
assertTrue(capabilities.contains(AlpineBitsCapability.HANDSHAKING)); | ||
assertTrue(capabilities.contains(AlpineBitsCapability.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF)); | ||
assertTrue(capabilities.contains(AlpineBitsCapability.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF_ACCEPT_CATEGORIES)); | ||
assertTrue(capabilities.contains(AlpineBitsCapability.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF_ACCEPT_ROOMS)); | ||
assertTrue(capabilities.contains(AlpineBitsCapability.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF_ACCEPT_OUT_OF_ORDER)); | ||
assertTrue(capabilities.contains(AlpineBitsCapability.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF_ACCEPT_OUT_OF_MARKET)); | ||
assertTrue(capabilities.contains(AlpineBitsCapability.FREE_ROOMS_HOTEL_INV_COUNT_NOTIF_ACCEPT_CLOSING_SEASONS)); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.