@Test void testGetPrimaryGatewayInstanceIdWhenPresent() { Stack stack = mock(Stack.class); GatewayConfig gatewayConfig = mock(GatewayConfig.class); when(gatewayConfigService.getPrimaryGatewayConfig(any())).thenReturn(gatewayConfig); when(gatewayConfig.getInstanceId()).thenReturn(INSTANCE_ID_1); assertEquals(Optional.of(INSTANCE_ID_1), underTest.getPrimaryGatewayInstanceId(stack)); verify(gatewayConfigService).getPrimaryGatewayConfig(eq(stack)); }
public Optional<String> getPrimaryGatewayInstanceId(Stack stack) { Optional<String> primaryGatewayInstanceId = Optional.empty(); try { primaryGatewayInstanceId = Optional.of(gatewayConfigService.getPrimaryGatewayConfig(stack).getInstanceId()); } catch (NotFoundException e) { LOGGER.debug("No active primary gateway found"); } return primaryGatewayInstanceId; }
ChangePrimaryGatewayService { public Optional<String> getPrimaryGatewayInstanceId(Stack stack) { Optional<String> primaryGatewayInstanceId = Optional.empty(); try { primaryGatewayInstanceId = Optional.of(gatewayConfigService.getPrimaryGatewayConfig(stack).getInstanceId()); } catch (NotFoundException e) { LOGGER.debug("No active primary gateway found"); } return primaryGatewayInstanceId; } }
ChangePrimaryGatewayService { public Optional<String> getPrimaryGatewayInstanceId(Stack stack) { Optional<String> primaryGatewayInstanceId = Optional.empty(); try { primaryGatewayInstanceId = Optional.of(gatewayConfigService.getPrimaryGatewayConfig(stack).getInstanceId()); } catch (NotFoundException e) { LOGGER.debug("No active primary gateway found"); } return primaryGatewayInstanceId; }  }
ChangePrimaryGatewayService { public Optional<String> getPrimaryGatewayInstanceId(Stack stack) { Optional<String> primaryGatewayInstanceId = Optional.empty(); try { primaryGatewayInstanceId = Optional.of(gatewayConfigService.getPrimaryGatewayConfig(stack).getInstanceId()); } catch (NotFoundException e) { LOGGER.debug("No active primary gateway found"); } return primaryGatewayInstanceId; }  Optional<String> getPrimaryGatewayInstanceId(Stack stack); String selectNewPrimaryGatewayInstanceId(Stack stack, List<String> repairInstanceIds); void changePrimaryGatewayMetadata(Stack stack, Optional<String> formerPrimaryGatwayInstanceId, String newPrimaryGatewayInstanceId); }
ChangePrimaryGatewayService { public Optional<String> getPrimaryGatewayInstanceId(Stack stack) { Optional<String> primaryGatewayInstanceId = Optional.empty(); try { primaryGatewayInstanceId = Optional.of(gatewayConfigService.getPrimaryGatewayConfig(stack).getInstanceId()); } catch (NotFoundException e) { LOGGER.debug("No active primary gateway found"); } return primaryGatewayInstanceId; }  Optional<String> getPrimaryGatewayInstanceId(Stack stack); String selectNewPrimaryGatewayInstanceId(Stack stack, List<String> repairInstanceIds); void changePrimaryGatewayMetadata(Stack stack, Optional<String> formerPrimaryGatwayInstanceId, String newPrimaryGatewayInstanceId);  }