@Override public WildflyRuntimeExecConfig asNewClone(final WildflyRuntimeExecConfig origin) { return new ContextAwareWildflyRuntimeExecConfig( origin.getRuntimeName(), origin.getProviderId(), origin.getWarPath(), origin.getRedeployStrategy() ); }
@Override public WildflyRuntimeExecConfig asNewClone(final WildflyRuntimeExecConfig origin) { return new ContextAwareWildflyRuntimeExecConfig( origin.getRuntimeName(), origin.getProviderId(), origin.getWarPath(), origin.getRedeployStrategy() ); }
@Test public void testDefaultExpression() { assertEquals(WAR_PATH_DEFAULT_EXPRESSION, new ContextAwareWildflyRuntimeExecConfig().getWarPath()); assertEquals(REDEPLOY_STRATEGY_DEFAULT_EXPRESSION, new ContextAwareWildflyRuntimeExecConfig().getRedeployStrategy()); assertEquals(RUNTIME_NAME_DEFAULT_EXPRESSION, new ContextAwareWildflyRuntimeExecConfig().getRuntimeName()); }
@Override public WildflyRuntime getValue() { return new WildflyRuntime(RUNTIME_ID, RUNTIME_NAME, new ContextAwareWildflyRuntimeExecConfig(RUNTIME_NAME, createWildflyProvider(), WAR_PATH, REDEPLOY_STRATEGY), createWildflyProvider(), new WildflyRuntimeEndpoint(PROTOCOL, HOST, PORT, CONTEXT), new WildflyRuntimeInfo(new ContextAwareWildflyRuntimeExecConfig(RUNTIME_NAME, createWildflyProvider(), WAR_PATH, REDEPLOY_STRATEGY)), new WildflyRuntimeState(STATE, STARTED_AT)); } }
@Test public void testContextUsingMavenBinary() { final ContextAwareWildflyRuntimeExecConfig config = new ContextAwareWildflyRuntimeExecConfig(); final Map<String, Object> context = new HashMap<>(); final WildflyProvider provider = mock(WildflyProvider.class); context.put("wildfly-provider", provider); final MavenBinary binary = mock(MavenBinary.class); final Path path = mock(Path.class); when(binary.getPath()).thenReturn(path); when(path.toString()).thenReturn(FILE_PATH); context.put("binary", binary); config.setContext(context); assertEquals(provider, config.getProviderId()); assertEquals(FILE_PATH, config.getWarPath()); final WildflyRuntimeExecConfig configClone = config.asNewClone(config); assertEquals(provider, configClone.getProviderId()); assertEquals(FILE_PATH, configClone.getWarPath()); }
@Test public void testVariablesResolution() { Map<String, String> values = new HashMap<>(); values.put(ContextAwareWildflyRuntimeExecConfig.WAR_PATH, FILE_PATH); values.put(ContextAwareWildflyRuntimeExecConfig.REDEPLOY_STRATEGY, REDEPLOY_OPTION); values.put(ContextAwareWildflyRuntimeExecConfig.RUNTIME_NAME, RUNTIME_NAME); final ContextAwareWildflyRuntimeExecConfig config = new ContextAwareWildflyRuntimeExecConfig(); final ContextAwareWildflyRuntimeExecConfig varConfig = interpolate(singletonMap("input", values), config); assertEquals(FILE_PATH, varConfig.getWarPath()); assertEquals(REDEPLOY_OPTION, varConfig.getRedeployStrategy()); assertEquals(RUNTIME_NAME, varConfig.getRuntimeName()); } }
@Test public void testContextUsingPath() { final ContextAwareWildflyRuntimeExecConfig config = new ContextAwareWildflyRuntimeExecConfig(); final WildflyProvider provider = mock(WildflyProvider.class); final Map<String, Object> context = singletonMap("wildfly-provider", provider); config.setContext(context); assertEquals(provider, config.getProviderId()); assertEquals(WAR_PATH_DEFAULT_EXPRESSION, config.getWarPath()); final WildflyRuntimeExecConfig configClone = config.asNewClone(config); assertEquals(provider, configClone.getProviderId()); assertEquals(WAR_PATH_DEFAULT_EXPRESSION, configClone.getWarPath()); }