@Test public void getCidrBlocks() { Road road = new Road(); Authorisation authorisation = new Authorisation(); Onramp onramp = new Onramp(); List<String> cidrBlocks = singletonList("cidrBlock"); onramp.setCidrBlocks(cidrBlocks); authorisation.setOnramp(onramp); road.setAuthorisation(authorisation); when(underTest.getRoad()).thenReturn(road); List<String> result = underTest.getCidrBlocks(); assertThat(result, is(cidrBlocks)); }
@Override public List<String> getCidrBlocks() { return Optional .of(getRoad()) .map(Road::getAuthorisation) .map(Authorisation::getOnramp) .map(Authorisation.Onramp::getCidrBlocks) .filter(l -> l.size() > 0) .orElseGet(() -> singletonList("0.0.0.0/0")); }
OnrampTemplate implements Onramp { @Override public List<String> getCidrBlocks() { return Optional .of(getRoad()) .map(Road::getAuthorisation) .map(Authorisation::getOnramp) .map(Authorisation.Onramp::getCidrBlocks) .filter(l -> l.size() > 0) .orElseGet(() -> singletonList("0.0.0.0/0")); } }
OnrampTemplate implements Onramp { @Override public List<String> getCidrBlocks() { return Optional .of(getRoad()) .map(Road::getAuthorisation) .map(Authorisation::getOnramp) .map(Authorisation.Onramp::getCidrBlocks) .filter(l -> l.size() > 0) .orElseGet(() -> singletonList("0.0.0.0/0")); } protected  OnrampTemplate(Road road); }
OnrampTemplate implements Onramp { @Override public List<String> getCidrBlocks() { return Optional .of(getRoad()) .map(Road::getAuthorisation) .map(Authorisation::getOnramp) .map(Authorisation.Onramp::getCidrBlocks) .filter(l -> l.size() > 0) .orElseGet(() -> singletonList("0.0.0.0/0")); } protected  OnrampTemplate(Road road); @Override Future<Boolean> sendEvent(JsonNode jsonEvent); @Override boolean isAvailable(); @Override List<String> getCidrBlocks(); }
OnrampTemplate implements Onramp { @Override public List<String> getCidrBlocks() { return Optional .of(getRoad()) .map(Road::getAuthorisation) .map(Authorisation::getOnramp) .map(Authorisation.Onramp::getCidrBlocks) .filter(l -> l.size() > 0) .orElseGet(() -> singletonList("0.0.0.0/0")); } protected  OnrampTemplate(Road road); @Override Future<Boolean> sendEvent(JsonNode jsonEvent); @Override boolean isAvailable(); @Override List<String> getCidrBlocks();  }