@Test public void shouldCreateFileSystemAwareUiHttpContext() { HttpContext httpContext = mock(HttpContext.class); PowerMockito.mockStatic(ApplicationEnvironment.class); MockBundle bundle = new MockBundle("org.motechproject.com-sms-api-bundle"); when(ApplicationEnvironment.isInDevelopmentMode()).thenReturn(true); when(ApplicationEnvironment.getModulePath(new BundleName("org.motechproject.com-sms-api-bundle"))).thenReturn("/Users/s/project/motech/modules/sms/src/main/resources"); FileSystemAwareUIHttpContext fileSystemAwareUIHttpContext = (FileSystemAwareUIHttpContext) HttpContextFactory.getHttpContext(httpContext, bundle); assertThat(fileSystemAwareUIHttpContext, IsNot.not(notNull())); assertThat(fileSystemAwareUIHttpContext.getResourceRootDirectoryPath(), Is.is("/Users/s/project/motech/modules/sms/src/main/resources")); }
public static HttpContext getHttpContext(HttpContext httpContext, Bundle bundle) { LOGGER.info("Environment is " + ApplicationEnvironment.getEnvironment()); if (!ApplicationEnvironment.isInDevelopmentMode()) { return httpContext; } String resourceDirPath = ApplicationEnvironment.getModulePath(new BundleName(bundle.getSymbolicName())); if (isBlank(resourceDirPath)) { LOGGER.info(String.format("Resource path not given for bundle %s", bundle.getSymbolicName())); return httpContext; } LOGGER.info(String.format("Resource path for bundle %s is %s", bundle.getSymbolicName(), resourceDirPath)); return new FileSystemAwareUIHttpContext(httpContext, resourceDirPath); }
HttpContextFactory { public static HttpContext getHttpContext(HttpContext httpContext, Bundle bundle) { LOGGER.info("Environment is " + ApplicationEnvironment.getEnvironment()); if (!ApplicationEnvironment.isInDevelopmentMode()) { return httpContext; } String resourceDirPath = ApplicationEnvironment.getModulePath(new BundleName(bundle.getSymbolicName())); if (isBlank(resourceDirPath)) { LOGGER.info(String.format("Resource path not given for bundle %s", bundle.getSymbolicName())); return httpContext; } LOGGER.info(String.format("Resource path for bundle %s is %s", bundle.getSymbolicName(), resourceDirPath)); return new FileSystemAwareUIHttpContext(httpContext, resourceDirPath); } }
HttpContextFactory { public static HttpContext getHttpContext(HttpContext httpContext, Bundle bundle) { LOGGER.info("Environment is " + ApplicationEnvironment.getEnvironment()); if (!ApplicationEnvironment.isInDevelopmentMode()) { return httpContext; } String resourceDirPath = ApplicationEnvironment.getModulePath(new BundleName(bundle.getSymbolicName())); if (isBlank(resourceDirPath)) { LOGGER.info(String.format("Resource path not given for bundle %s", bundle.getSymbolicName())); return httpContext; } LOGGER.info(String.format("Resource path for bundle %s is %s", bundle.getSymbolicName(), resourceDirPath)); return new FileSystemAwareUIHttpContext(httpContext, resourceDirPath); } private  HttpContextFactory(); }
HttpContextFactory { public static HttpContext getHttpContext(HttpContext httpContext, Bundle bundle) { LOGGER.info("Environment is " + ApplicationEnvironment.getEnvironment()); if (!ApplicationEnvironment.isInDevelopmentMode()) { return httpContext; } String resourceDirPath = ApplicationEnvironment.getModulePath(new BundleName(bundle.getSymbolicName())); if (isBlank(resourceDirPath)) { LOGGER.info(String.format("Resource path not given for bundle %s", bundle.getSymbolicName())); return httpContext; } LOGGER.info(String.format("Resource path for bundle %s is %s", bundle.getSymbolicName(), resourceDirPath)); return new FileSystemAwareUIHttpContext(httpContext, resourceDirPath); } private  HttpContextFactory(); static HttpContext getHttpContext(HttpContext httpContext, Bundle bundle); }
HttpContextFactory { public static HttpContext getHttpContext(HttpContext httpContext, Bundle bundle) { LOGGER.info("Environment is " + ApplicationEnvironment.getEnvironment()); if (!ApplicationEnvironment.isInDevelopmentMode()) { return httpContext; } String resourceDirPath = ApplicationEnvironment.getModulePath(new BundleName(bundle.getSymbolicName())); if (isBlank(resourceDirPath)) { LOGGER.info(String.format("Resource path not given for bundle %s", bundle.getSymbolicName())); return httpContext; } LOGGER.info(String.format("Resource path for bundle %s is %s", bundle.getSymbolicName(), resourceDirPath)); return new FileSystemAwareUIHttpContext(httpContext, resourceDirPath); } private  HttpContextFactory(); static HttpContext getHttpContext(HttpContext httpContext, Bundle bundle);  }