EacNavigatorFactory implements UserConsentNavigatorFactory<EacGui> { @Override public UserConsentNavigator createFrom(UserConsentDescription uc) { if (! this.canCreateFrom(uc)) { throw new IllegalArgumentException("This factory explicitly does not support the given user consent description."); } ifaceReceiver.setUiInterface(new EacGuiImpl()); return new EacNavigator(uc, ifaceReceiver); }  @Override boolean canCreateFrom(UserConsentDescription uc); @Override UserConsentNavigator createFrom(UserConsentDescription uc); @Override Promise<? extends EacGui> getIfacePromise();  }
@Test public void testGivenCorrectValuesThenCreateFromShouldCreateCorrectInstance() { final List<Step> expectedSteps = createInitialSteps(); new Expectations() {{ ucd.getDialogType(); result = "EAC"; ucd.getSteps(); result = expectedSteps; }}; EacNavigatorFactory sut = new EacNavigatorFactory(); final UserConsentNavigator result = sut.createFrom(ucd); assertEquals(result.getClass(), EacNavigator.class); }
@Test public void testGivenCorrectValuesThenCreateFromShouldBeCorrect() { final List<Step> expectedSteps = createInitialSteps(); new Expectations() {{ ucd.getDialogType(); result = "EAC"; ucd.getSteps(); result = expectedSteps; }}; EacNavigatorFactory sut = new EacNavigatorFactory(); final UserConsentNavigator result = sut.createFrom(ucd); assertNotNull(result); assertTrue(result.hasNext()); }