repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandlerTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/ErrorResponse.java
// public class ErrorResponse {
//
// private final String error;
//
// @JsonCreator
// public ErrorResponse(@JsonProperty("error") final String error) {
// this.error = error;
// }
//
// public String getError() {
// return error;
// }
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
| import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.learning.by.example.reactive.microservices.model.ErrorResponse;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import java.util.function.Consumer;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; | package org.learning.by.example.reactive.microservices.handlers;
@UnitTest
@DisplayName("ErrorHandler Unit Tests")
class ErrorHandlerTest {
private static final String NOT_FOUND = "not found";
@Autowired
private ErrorHandler errorHandler;
@Test
void notFoundTest() {
errorHandler.notFound(null)
.subscribe(checkResponse(HttpStatus.NOT_FOUND, NOT_FOUND));
}
@Test
void throwableErrorTest() {
errorHandler.throwableError(new PathNotFoundException(NOT_FOUND))
.subscribe(checkResponse(HttpStatus.NOT_FOUND, NOT_FOUND));
}
@Test
void getResponseTest() {
Mono.just(new PathNotFoundException(NOT_FOUND)).transform(errorHandler::getResponse)
.subscribe(checkResponse(HttpStatus.NOT_FOUND, NOT_FOUND));
}
private static Consumer<ServerResponse> checkResponse(final HttpStatus httpStatus, final String message) {
return serverResponse -> {
assertThat(serverResponse.statusCode(), is(httpStatus)); | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/ErrorResponse.java
// public class ErrorResponse {
//
// private final String error;
//
// @JsonCreator
// public ErrorResponse(@JsonProperty("error") final String error) {
// this.error = error;
// }
//
// public String getError() {
// return error;
// }
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandlerTest.java
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.learning.by.example.reactive.microservices.model.ErrorResponse;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import java.util.function.Consumer;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
package org.learning.by.example.reactive.microservices.handlers;
@UnitTest
@DisplayName("ErrorHandler Unit Tests")
class ErrorHandlerTest {
private static final String NOT_FOUND = "not found";
@Autowired
private ErrorHandler errorHandler;
@Test
void notFoundTest() {
errorHandler.notFound(null)
.subscribe(checkResponse(HttpStatus.NOT_FOUND, NOT_FOUND));
}
@Test
void throwableErrorTest() {
errorHandler.throwableError(new PathNotFoundException(NOT_FOUND))
.subscribe(checkResponse(HttpStatus.NOT_FOUND, NOT_FOUND));
}
@Test
void getResponseTest() {
Mono.just(new PathNotFoundException(NOT_FOUND)).transform(errorHandler::getResponse)
.subscribe(checkResponse(HttpStatus.NOT_FOUND, NOT_FOUND));
}
private static Consumer<ServerResponse> checkResponse(final HttpStatus httpStatus, final String message) {
return serverResponse -> {
assertThat(serverResponse.statusCode(), is(httpStatus)); | assertThat(HandlersHelper.extractEntity(serverResponse, ErrorResponse.class).getError(), is(message)); |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/application/ApplicationConfig.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
// public class ApiHandler {
//
// private static final String ADDRESS = "address";
// private static final String EMPTY_STRING = "";
//
// private final ErrorHandler errorHandler;
//
// private final GeoLocationService geoLocationService;
// private final SunriseSunsetService sunriseSunsetService;
//
// public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
// final ErrorHandler errorHandler) {
// this.errorHandler = errorHandler;
// this.geoLocationService = geoLocationService;
// this.sunriseSunsetService = sunriseSunsetService;
// }
//
// public Mono<ServerResponse> postLocation(final ServerRequest request) {
// return request.bodyToMono(LocationRequest.class)
// .map(LocationRequest::getAddress)
// .onErrorResume(throwable -> Mono.just(EMPTY_STRING))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// public Mono<ServerResponse> getLocation(final ServerRequest request) {
// return Mono.just(request.pathVariable(ADDRESS))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// Mono<ServerResponse> buildResponse(final Mono<String> address) {
// return address
// .transform(geoLocationService::fromAddress)
// .zipWhen(this::sunriseSunset, LocationResponse::new)
// .transform(this::serverResponse);
// }
//
// private Mono<SunriseSunset> sunriseSunset(GeographicCoordinates geographicCoordinates) {
// return Mono.just(geographicCoordinates).transform(sunriseSunsetService::fromGeographicCoordinates);
// }
//
// Mono<ServerResponse> serverResponse(Mono<LocationResponse> locationResponseMono) {
// return locationResponseMono.flatMap(locationResponse ->
// ServerResponse.ok().body(Mono.just(locationResponse), LocationResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java
// public class ErrorHandler {
//
// private static final String NOT_FOUND = "not found";
// private static final String ERROR_RAISED = "error raised";
// private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
//
// public Mono<ServerResponse> notFound(final ServerRequest request) {
// return Mono.just(new PathNotFoundException(NOT_FOUND)).transform(this::getResponse);
// }
//
// Mono<ServerResponse> throwableError(final Throwable error) {
// logger.error(ERROR_RAISED, error);
// return Mono.just(error).transform(this::getResponse);
// }
//
// <T extends Throwable> Mono<ServerResponse> getResponse(final Mono<T> monoError) {
// return monoError.transform(ThrowableTranslator::translate)
// .flatMap(translation -> ServerResponse
// .status(translation.getHttpStatus())
// .body(Mono.just(new ErrorResponse(translation.getMessage())), ErrorResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/routers/MainRouter.java
// public class MainRouter {
//
// public static RouterFunction<?> doRoute(final ApiHandler handler, final ErrorHandler errorHandler) {
// return ApiRouter
// .doRoute(handler, errorHandler)
// .andOther(StaticRouter.doRoute());
// }
// }
| import org.learning.by.example.reactive.microservices.handlers.ApiHandler;
import org.learning.by.example.reactive.microservices.handlers.ErrorHandler;
import org.learning.by.example.reactive.microservices.routers.MainRouter;
import org.learning.by.example.reactive.microservices.services.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.config.EnableWebFlux;
import org.springframework.web.reactive.function.server.RouterFunction; | package org.learning.by.example.reactive.microservices.application;
@Configuration
@EnableWebFlux
class ApplicationConfig {
@Bean | // Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
// public class ApiHandler {
//
// private static final String ADDRESS = "address";
// private static final String EMPTY_STRING = "";
//
// private final ErrorHandler errorHandler;
//
// private final GeoLocationService geoLocationService;
// private final SunriseSunsetService sunriseSunsetService;
//
// public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
// final ErrorHandler errorHandler) {
// this.errorHandler = errorHandler;
// this.geoLocationService = geoLocationService;
// this.sunriseSunsetService = sunriseSunsetService;
// }
//
// public Mono<ServerResponse> postLocation(final ServerRequest request) {
// return request.bodyToMono(LocationRequest.class)
// .map(LocationRequest::getAddress)
// .onErrorResume(throwable -> Mono.just(EMPTY_STRING))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// public Mono<ServerResponse> getLocation(final ServerRequest request) {
// return Mono.just(request.pathVariable(ADDRESS))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// Mono<ServerResponse> buildResponse(final Mono<String> address) {
// return address
// .transform(geoLocationService::fromAddress)
// .zipWhen(this::sunriseSunset, LocationResponse::new)
// .transform(this::serverResponse);
// }
//
// private Mono<SunriseSunset> sunriseSunset(GeographicCoordinates geographicCoordinates) {
// return Mono.just(geographicCoordinates).transform(sunriseSunsetService::fromGeographicCoordinates);
// }
//
// Mono<ServerResponse> serverResponse(Mono<LocationResponse> locationResponseMono) {
// return locationResponseMono.flatMap(locationResponse ->
// ServerResponse.ok().body(Mono.just(locationResponse), LocationResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java
// public class ErrorHandler {
//
// private static final String NOT_FOUND = "not found";
// private static final String ERROR_RAISED = "error raised";
// private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
//
// public Mono<ServerResponse> notFound(final ServerRequest request) {
// return Mono.just(new PathNotFoundException(NOT_FOUND)).transform(this::getResponse);
// }
//
// Mono<ServerResponse> throwableError(final Throwable error) {
// logger.error(ERROR_RAISED, error);
// return Mono.just(error).transform(this::getResponse);
// }
//
// <T extends Throwable> Mono<ServerResponse> getResponse(final Mono<T> monoError) {
// return monoError.transform(ThrowableTranslator::translate)
// .flatMap(translation -> ServerResponse
// .status(translation.getHttpStatus())
// .body(Mono.just(new ErrorResponse(translation.getMessage())), ErrorResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/routers/MainRouter.java
// public class MainRouter {
//
// public static RouterFunction<?> doRoute(final ApiHandler handler, final ErrorHandler errorHandler) {
// return ApiRouter
// .doRoute(handler, errorHandler)
// .andOther(StaticRouter.doRoute());
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/application/ApplicationConfig.java
import org.learning.by.example.reactive.microservices.handlers.ApiHandler;
import org.learning.by.example.reactive.microservices.handlers.ErrorHandler;
import org.learning.by.example.reactive.microservices.routers.MainRouter;
import org.learning.by.example.reactive.microservices.services.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.config.EnableWebFlux;
import org.springframework.web.reactive.function.server.RouterFunction;
package org.learning.by.example.reactive.microservices.application;
@Configuration
@EnableWebFlux
class ApplicationConfig {
@Bean | ApiHandler apiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService, |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/application/ApplicationConfig.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
// public class ApiHandler {
//
// private static final String ADDRESS = "address";
// private static final String EMPTY_STRING = "";
//
// private final ErrorHandler errorHandler;
//
// private final GeoLocationService geoLocationService;
// private final SunriseSunsetService sunriseSunsetService;
//
// public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
// final ErrorHandler errorHandler) {
// this.errorHandler = errorHandler;
// this.geoLocationService = geoLocationService;
// this.sunriseSunsetService = sunriseSunsetService;
// }
//
// public Mono<ServerResponse> postLocation(final ServerRequest request) {
// return request.bodyToMono(LocationRequest.class)
// .map(LocationRequest::getAddress)
// .onErrorResume(throwable -> Mono.just(EMPTY_STRING))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// public Mono<ServerResponse> getLocation(final ServerRequest request) {
// return Mono.just(request.pathVariable(ADDRESS))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// Mono<ServerResponse> buildResponse(final Mono<String> address) {
// return address
// .transform(geoLocationService::fromAddress)
// .zipWhen(this::sunriseSunset, LocationResponse::new)
// .transform(this::serverResponse);
// }
//
// private Mono<SunriseSunset> sunriseSunset(GeographicCoordinates geographicCoordinates) {
// return Mono.just(geographicCoordinates).transform(sunriseSunsetService::fromGeographicCoordinates);
// }
//
// Mono<ServerResponse> serverResponse(Mono<LocationResponse> locationResponseMono) {
// return locationResponseMono.flatMap(locationResponse ->
// ServerResponse.ok().body(Mono.just(locationResponse), LocationResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java
// public class ErrorHandler {
//
// private static final String NOT_FOUND = "not found";
// private static final String ERROR_RAISED = "error raised";
// private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
//
// public Mono<ServerResponse> notFound(final ServerRequest request) {
// return Mono.just(new PathNotFoundException(NOT_FOUND)).transform(this::getResponse);
// }
//
// Mono<ServerResponse> throwableError(final Throwable error) {
// logger.error(ERROR_RAISED, error);
// return Mono.just(error).transform(this::getResponse);
// }
//
// <T extends Throwable> Mono<ServerResponse> getResponse(final Mono<T> monoError) {
// return monoError.transform(ThrowableTranslator::translate)
// .flatMap(translation -> ServerResponse
// .status(translation.getHttpStatus())
// .body(Mono.just(new ErrorResponse(translation.getMessage())), ErrorResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/routers/MainRouter.java
// public class MainRouter {
//
// public static RouterFunction<?> doRoute(final ApiHandler handler, final ErrorHandler errorHandler) {
// return ApiRouter
// .doRoute(handler, errorHandler)
// .andOther(StaticRouter.doRoute());
// }
// }
| import org.learning.by.example.reactive.microservices.handlers.ApiHandler;
import org.learning.by.example.reactive.microservices.handlers.ErrorHandler;
import org.learning.by.example.reactive.microservices.routers.MainRouter;
import org.learning.by.example.reactive.microservices.services.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.config.EnableWebFlux;
import org.springframework.web.reactive.function.server.RouterFunction; | package org.learning.by.example.reactive.microservices.application;
@Configuration
@EnableWebFlux
class ApplicationConfig {
@Bean
ApiHandler apiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService, | // Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
// public class ApiHandler {
//
// private static final String ADDRESS = "address";
// private static final String EMPTY_STRING = "";
//
// private final ErrorHandler errorHandler;
//
// private final GeoLocationService geoLocationService;
// private final SunriseSunsetService sunriseSunsetService;
//
// public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
// final ErrorHandler errorHandler) {
// this.errorHandler = errorHandler;
// this.geoLocationService = geoLocationService;
// this.sunriseSunsetService = sunriseSunsetService;
// }
//
// public Mono<ServerResponse> postLocation(final ServerRequest request) {
// return request.bodyToMono(LocationRequest.class)
// .map(LocationRequest::getAddress)
// .onErrorResume(throwable -> Mono.just(EMPTY_STRING))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// public Mono<ServerResponse> getLocation(final ServerRequest request) {
// return Mono.just(request.pathVariable(ADDRESS))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// Mono<ServerResponse> buildResponse(final Mono<String> address) {
// return address
// .transform(geoLocationService::fromAddress)
// .zipWhen(this::sunriseSunset, LocationResponse::new)
// .transform(this::serverResponse);
// }
//
// private Mono<SunriseSunset> sunriseSunset(GeographicCoordinates geographicCoordinates) {
// return Mono.just(geographicCoordinates).transform(sunriseSunsetService::fromGeographicCoordinates);
// }
//
// Mono<ServerResponse> serverResponse(Mono<LocationResponse> locationResponseMono) {
// return locationResponseMono.flatMap(locationResponse ->
// ServerResponse.ok().body(Mono.just(locationResponse), LocationResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java
// public class ErrorHandler {
//
// private static final String NOT_FOUND = "not found";
// private static final String ERROR_RAISED = "error raised";
// private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
//
// public Mono<ServerResponse> notFound(final ServerRequest request) {
// return Mono.just(new PathNotFoundException(NOT_FOUND)).transform(this::getResponse);
// }
//
// Mono<ServerResponse> throwableError(final Throwable error) {
// logger.error(ERROR_RAISED, error);
// return Mono.just(error).transform(this::getResponse);
// }
//
// <T extends Throwable> Mono<ServerResponse> getResponse(final Mono<T> monoError) {
// return monoError.transform(ThrowableTranslator::translate)
// .flatMap(translation -> ServerResponse
// .status(translation.getHttpStatus())
// .body(Mono.just(new ErrorResponse(translation.getMessage())), ErrorResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/routers/MainRouter.java
// public class MainRouter {
//
// public static RouterFunction<?> doRoute(final ApiHandler handler, final ErrorHandler errorHandler) {
// return ApiRouter
// .doRoute(handler, errorHandler)
// .andOther(StaticRouter.doRoute());
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/application/ApplicationConfig.java
import org.learning.by.example.reactive.microservices.handlers.ApiHandler;
import org.learning.by.example.reactive.microservices.handlers.ErrorHandler;
import org.learning.by.example.reactive.microservices.routers.MainRouter;
import org.learning.by.example.reactive.microservices.services.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.config.EnableWebFlux;
import org.springframework.web.reactive.function.server.RouterFunction;
package org.learning.by.example.reactive.microservices.application;
@Configuration
@EnableWebFlux
class ApplicationConfig {
@Bean
ApiHandler apiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService, | final ErrorHandler errorHandler) { |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/application/ApplicationConfig.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
// public class ApiHandler {
//
// private static final String ADDRESS = "address";
// private static final String EMPTY_STRING = "";
//
// private final ErrorHandler errorHandler;
//
// private final GeoLocationService geoLocationService;
// private final SunriseSunsetService sunriseSunsetService;
//
// public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
// final ErrorHandler errorHandler) {
// this.errorHandler = errorHandler;
// this.geoLocationService = geoLocationService;
// this.sunriseSunsetService = sunriseSunsetService;
// }
//
// public Mono<ServerResponse> postLocation(final ServerRequest request) {
// return request.bodyToMono(LocationRequest.class)
// .map(LocationRequest::getAddress)
// .onErrorResume(throwable -> Mono.just(EMPTY_STRING))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// public Mono<ServerResponse> getLocation(final ServerRequest request) {
// return Mono.just(request.pathVariable(ADDRESS))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// Mono<ServerResponse> buildResponse(final Mono<String> address) {
// return address
// .transform(geoLocationService::fromAddress)
// .zipWhen(this::sunriseSunset, LocationResponse::new)
// .transform(this::serverResponse);
// }
//
// private Mono<SunriseSunset> sunriseSunset(GeographicCoordinates geographicCoordinates) {
// return Mono.just(geographicCoordinates).transform(sunriseSunsetService::fromGeographicCoordinates);
// }
//
// Mono<ServerResponse> serverResponse(Mono<LocationResponse> locationResponseMono) {
// return locationResponseMono.flatMap(locationResponse ->
// ServerResponse.ok().body(Mono.just(locationResponse), LocationResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java
// public class ErrorHandler {
//
// private static final String NOT_FOUND = "not found";
// private static final String ERROR_RAISED = "error raised";
// private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
//
// public Mono<ServerResponse> notFound(final ServerRequest request) {
// return Mono.just(new PathNotFoundException(NOT_FOUND)).transform(this::getResponse);
// }
//
// Mono<ServerResponse> throwableError(final Throwable error) {
// logger.error(ERROR_RAISED, error);
// return Mono.just(error).transform(this::getResponse);
// }
//
// <T extends Throwable> Mono<ServerResponse> getResponse(final Mono<T> monoError) {
// return monoError.transform(ThrowableTranslator::translate)
// .flatMap(translation -> ServerResponse
// .status(translation.getHttpStatus())
// .body(Mono.just(new ErrorResponse(translation.getMessage())), ErrorResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/routers/MainRouter.java
// public class MainRouter {
//
// public static RouterFunction<?> doRoute(final ApiHandler handler, final ErrorHandler errorHandler) {
// return ApiRouter
// .doRoute(handler, errorHandler)
// .andOther(StaticRouter.doRoute());
// }
// }
| import org.learning.by.example.reactive.microservices.handlers.ApiHandler;
import org.learning.by.example.reactive.microservices.handlers.ErrorHandler;
import org.learning.by.example.reactive.microservices.routers.MainRouter;
import org.learning.by.example.reactive.microservices.services.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.config.EnableWebFlux;
import org.springframework.web.reactive.function.server.RouterFunction; | package org.learning.by.example.reactive.microservices.application;
@Configuration
@EnableWebFlux
class ApplicationConfig {
@Bean
ApiHandler apiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
final ErrorHandler errorHandler) {
return new ApiHandler(geoLocationService, sunriseSunsetService, errorHandler);
}
@Bean
GeoLocationService locationService(@Value("${GeoLocationServiceImpl.endPoint}") final String endPoint) {
return new GeoLocationServiceImpl(endPoint);
}
@Bean
SunriseSunsetService sunriseSunsetService(@Value("${SunriseSunsetServiceImpl.endPoint}") final String endPoint) {
return new SunriseSunsetServiceImpl(endPoint);
}
@Bean
ErrorHandler errorHandler() {
return new ErrorHandler();
}
@Bean
RouterFunction<?> mainRouterFunction(final ApiHandler apiHandler, final ErrorHandler errorHandler) { | // Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
// public class ApiHandler {
//
// private static final String ADDRESS = "address";
// private static final String EMPTY_STRING = "";
//
// private final ErrorHandler errorHandler;
//
// private final GeoLocationService geoLocationService;
// private final SunriseSunsetService sunriseSunsetService;
//
// public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
// final ErrorHandler errorHandler) {
// this.errorHandler = errorHandler;
// this.geoLocationService = geoLocationService;
// this.sunriseSunsetService = sunriseSunsetService;
// }
//
// public Mono<ServerResponse> postLocation(final ServerRequest request) {
// return request.bodyToMono(LocationRequest.class)
// .map(LocationRequest::getAddress)
// .onErrorResume(throwable -> Mono.just(EMPTY_STRING))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// public Mono<ServerResponse> getLocation(final ServerRequest request) {
// return Mono.just(request.pathVariable(ADDRESS))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// Mono<ServerResponse> buildResponse(final Mono<String> address) {
// return address
// .transform(geoLocationService::fromAddress)
// .zipWhen(this::sunriseSunset, LocationResponse::new)
// .transform(this::serverResponse);
// }
//
// private Mono<SunriseSunset> sunriseSunset(GeographicCoordinates geographicCoordinates) {
// return Mono.just(geographicCoordinates).transform(sunriseSunsetService::fromGeographicCoordinates);
// }
//
// Mono<ServerResponse> serverResponse(Mono<LocationResponse> locationResponseMono) {
// return locationResponseMono.flatMap(locationResponse ->
// ServerResponse.ok().body(Mono.just(locationResponse), LocationResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java
// public class ErrorHandler {
//
// private static final String NOT_FOUND = "not found";
// private static final String ERROR_RAISED = "error raised";
// private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
//
// public Mono<ServerResponse> notFound(final ServerRequest request) {
// return Mono.just(new PathNotFoundException(NOT_FOUND)).transform(this::getResponse);
// }
//
// Mono<ServerResponse> throwableError(final Throwable error) {
// logger.error(ERROR_RAISED, error);
// return Mono.just(error).transform(this::getResponse);
// }
//
// <T extends Throwable> Mono<ServerResponse> getResponse(final Mono<T> monoError) {
// return monoError.transform(ThrowableTranslator::translate)
// .flatMap(translation -> ServerResponse
// .status(translation.getHttpStatus())
// .body(Mono.just(new ErrorResponse(translation.getMessage())), ErrorResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/routers/MainRouter.java
// public class MainRouter {
//
// public static RouterFunction<?> doRoute(final ApiHandler handler, final ErrorHandler errorHandler) {
// return ApiRouter
// .doRoute(handler, errorHandler)
// .andOther(StaticRouter.doRoute());
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/application/ApplicationConfig.java
import org.learning.by.example.reactive.microservices.handlers.ApiHandler;
import org.learning.by.example.reactive.microservices.handlers.ErrorHandler;
import org.learning.by.example.reactive.microservices.routers.MainRouter;
import org.learning.by.example.reactive.microservices.services.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.config.EnableWebFlux;
import org.springframework.web.reactive.function.server.RouterFunction;
package org.learning.by.example.reactive.microservices.application;
@Configuration
@EnableWebFlux
class ApplicationConfig {
@Bean
ApiHandler apiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
final ErrorHandler errorHandler) {
return new ApiHandler(geoLocationService, sunriseSunsetService, errorHandler);
}
@Bean
GeoLocationService locationService(@Value("${GeoLocationServiceImpl.endPoint}") final String endPoint) {
return new GeoLocationServiceImpl(endPoint);
}
@Bean
SunriseSunsetService sunriseSunsetService(@Value("${SunriseSunsetServiceImpl.endPoint}") final String endPoint) {
return new SunriseSunsetServiceImpl(endPoint);
}
@Bean
ErrorHandler errorHandler() {
return new ErrorHandler();
}
@Bean
RouterFunction<?> mainRouterFunction(final ApiHandler apiHandler, final ErrorHandler errorHandler) { | return MainRouter.doRoute(apiHandler, errorHandler); |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/routers/ApiRouter.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java
// public class ErrorHandler {
//
// private static final String NOT_FOUND = "not found";
// private static final String ERROR_RAISED = "error raised";
// private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
//
// public Mono<ServerResponse> notFound(final ServerRequest request) {
// return Mono.just(new PathNotFoundException(NOT_FOUND)).transform(this::getResponse);
// }
//
// Mono<ServerResponse> throwableError(final Throwable error) {
// logger.error(ERROR_RAISED, error);
// return Mono.just(error).transform(this::getResponse);
// }
//
// <T extends Throwable> Mono<ServerResponse> getResponse(final Mono<T> monoError) {
// return monoError.transform(ThrowableTranslator::translate)
// .flatMap(translation -> ServerResponse
// .status(translation.getHttpStatus())
// .body(Mono.just(new ErrorResponse(translation.getMessage())), ErrorResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
// public class ApiHandler {
//
// private static final String ADDRESS = "address";
// private static final String EMPTY_STRING = "";
//
// private final ErrorHandler errorHandler;
//
// private final GeoLocationService geoLocationService;
// private final SunriseSunsetService sunriseSunsetService;
//
// public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
// final ErrorHandler errorHandler) {
// this.errorHandler = errorHandler;
// this.geoLocationService = geoLocationService;
// this.sunriseSunsetService = sunriseSunsetService;
// }
//
// public Mono<ServerResponse> postLocation(final ServerRequest request) {
// return request.bodyToMono(LocationRequest.class)
// .map(LocationRequest::getAddress)
// .onErrorResume(throwable -> Mono.just(EMPTY_STRING))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// public Mono<ServerResponse> getLocation(final ServerRequest request) {
// return Mono.just(request.pathVariable(ADDRESS))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// Mono<ServerResponse> buildResponse(final Mono<String> address) {
// return address
// .transform(geoLocationService::fromAddress)
// .zipWhen(this::sunriseSunset, LocationResponse::new)
// .transform(this::serverResponse);
// }
//
// private Mono<SunriseSunset> sunriseSunset(GeographicCoordinates geographicCoordinates) {
// return Mono.just(geographicCoordinates).transform(sunriseSunsetService::fromGeographicCoordinates);
// }
//
// Mono<ServerResponse> serverResponse(Mono<LocationResponse> locationResponseMono) {
// return locationResponseMono.flatMap(locationResponse ->
// ServerResponse.ok().body(Mono.just(locationResponse), LocationResponse.class));
// }
// }
| import org.learning.by.example.reactive.microservices.handlers.ErrorHandler;
import org.learning.by.example.reactive.microservices.handlers.ApiHandler;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.web.reactive.function.server.RequestPredicates.*;
import static org.springframework.web.reactive.function.server.RouterFunctions.nest;
import static org.springframework.web.reactive.function.server.RouterFunctions.route; | package org.learning.by.example.reactive.microservices.routers;
class ApiRouter {
private static final String API_PATH = "/api";
private static final String LOCATION_PATH = "/location";
private static final String ADDRESS_ARG = "/{address}";
private static final String LOCATION_WITH_ADDRESS_PATH = LOCATION_PATH + ADDRESS_ARG;
| // Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java
// public class ErrorHandler {
//
// private static final String NOT_FOUND = "not found";
// private static final String ERROR_RAISED = "error raised";
// private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
//
// public Mono<ServerResponse> notFound(final ServerRequest request) {
// return Mono.just(new PathNotFoundException(NOT_FOUND)).transform(this::getResponse);
// }
//
// Mono<ServerResponse> throwableError(final Throwable error) {
// logger.error(ERROR_RAISED, error);
// return Mono.just(error).transform(this::getResponse);
// }
//
// <T extends Throwable> Mono<ServerResponse> getResponse(final Mono<T> monoError) {
// return monoError.transform(ThrowableTranslator::translate)
// .flatMap(translation -> ServerResponse
// .status(translation.getHttpStatus())
// .body(Mono.just(new ErrorResponse(translation.getMessage())), ErrorResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
// public class ApiHandler {
//
// private static final String ADDRESS = "address";
// private static final String EMPTY_STRING = "";
//
// private final ErrorHandler errorHandler;
//
// private final GeoLocationService geoLocationService;
// private final SunriseSunsetService sunriseSunsetService;
//
// public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
// final ErrorHandler errorHandler) {
// this.errorHandler = errorHandler;
// this.geoLocationService = geoLocationService;
// this.sunriseSunsetService = sunriseSunsetService;
// }
//
// public Mono<ServerResponse> postLocation(final ServerRequest request) {
// return request.bodyToMono(LocationRequest.class)
// .map(LocationRequest::getAddress)
// .onErrorResume(throwable -> Mono.just(EMPTY_STRING))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// public Mono<ServerResponse> getLocation(final ServerRequest request) {
// return Mono.just(request.pathVariable(ADDRESS))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// Mono<ServerResponse> buildResponse(final Mono<String> address) {
// return address
// .transform(geoLocationService::fromAddress)
// .zipWhen(this::sunriseSunset, LocationResponse::new)
// .transform(this::serverResponse);
// }
//
// private Mono<SunriseSunset> sunriseSunset(GeographicCoordinates geographicCoordinates) {
// return Mono.just(geographicCoordinates).transform(sunriseSunsetService::fromGeographicCoordinates);
// }
//
// Mono<ServerResponse> serverResponse(Mono<LocationResponse> locationResponseMono) {
// return locationResponseMono.flatMap(locationResponse ->
// ServerResponse.ok().body(Mono.just(locationResponse), LocationResponse.class));
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/routers/ApiRouter.java
import org.learning.by.example.reactive.microservices.handlers.ErrorHandler;
import org.learning.by.example.reactive.microservices.handlers.ApiHandler;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.web.reactive.function.server.RequestPredicates.*;
import static org.springframework.web.reactive.function.server.RouterFunctions.nest;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
package org.learning.by.example.reactive.microservices.routers;
class ApiRouter {
private static final String API_PATH = "/api";
private static final String LOCATION_PATH = "/location";
private static final String ADDRESS_ARG = "/{address}";
private static final String LOCATION_WITH_ADDRESS_PATH = LOCATION_PATH + ADDRESS_ARG;
| static RouterFunction<?> doRoute(final ApiHandler apiHandler, final ErrorHandler errorHandler) { |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/routers/ApiRouter.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java
// public class ErrorHandler {
//
// private static final String NOT_FOUND = "not found";
// private static final String ERROR_RAISED = "error raised";
// private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
//
// public Mono<ServerResponse> notFound(final ServerRequest request) {
// return Mono.just(new PathNotFoundException(NOT_FOUND)).transform(this::getResponse);
// }
//
// Mono<ServerResponse> throwableError(final Throwable error) {
// logger.error(ERROR_RAISED, error);
// return Mono.just(error).transform(this::getResponse);
// }
//
// <T extends Throwable> Mono<ServerResponse> getResponse(final Mono<T> monoError) {
// return monoError.transform(ThrowableTranslator::translate)
// .flatMap(translation -> ServerResponse
// .status(translation.getHttpStatus())
// .body(Mono.just(new ErrorResponse(translation.getMessage())), ErrorResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
// public class ApiHandler {
//
// private static final String ADDRESS = "address";
// private static final String EMPTY_STRING = "";
//
// private final ErrorHandler errorHandler;
//
// private final GeoLocationService geoLocationService;
// private final SunriseSunsetService sunriseSunsetService;
//
// public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
// final ErrorHandler errorHandler) {
// this.errorHandler = errorHandler;
// this.geoLocationService = geoLocationService;
// this.sunriseSunsetService = sunriseSunsetService;
// }
//
// public Mono<ServerResponse> postLocation(final ServerRequest request) {
// return request.bodyToMono(LocationRequest.class)
// .map(LocationRequest::getAddress)
// .onErrorResume(throwable -> Mono.just(EMPTY_STRING))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// public Mono<ServerResponse> getLocation(final ServerRequest request) {
// return Mono.just(request.pathVariable(ADDRESS))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// Mono<ServerResponse> buildResponse(final Mono<String> address) {
// return address
// .transform(geoLocationService::fromAddress)
// .zipWhen(this::sunriseSunset, LocationResponse::new)
// .transform(this::serverResponse);
// }
//
// private Mono<SunriseSunset> sunriseSunset(GeographicCoordinates geographicCoordinates) {
// return Mono.just(geographicCoordinates).transform(sunriseSunsetService::fromGeographicCoordinates);
// }
//
// Mono<ServerResponse> serverResponse(Mono<LocationResponse> locationResponseMono) {
// return locationResponseMono.flatMap(locationResponse ->
// ServerResponse.ok().body(Mono.just(locationResponse), LocationResponse.class));
// }
// }
| import org.learning.by.example.reactive.microservices.handlers.ErrorHandler;
import org.learning.by.example.reactive.microservices.handlers.ApiHandler;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.web.reactive.function.server.RequestPredicates.*;
import static org.springframework.web.reactive.function.server.RouterFunctions.nest;
import static org.springframework.web.reactive.function.server.RouterFunctions.route; | package org.learning.by.example.reactive.microservices.routers;
class ApiRouter {
private static final String API_PATH = "/api";
private static final String LOCATION_PATH = "/location";
private static final String ADDRESS_ARG = "/{address}";
private static final String LOCATION_WITH_ADDRESS_PATH = LOCATION_PATH + ADDRESS_ARG;
| // Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java
// public class ErrorHandler {
//
// private static final String NOT_FOUND = "not found";
// private static final String ERROR_RAISED = "error raised";
// private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
//
// public Mono<ServerResponse> notFound(final ServerRequest request) {
// return Mono.just(new PathNotFoundException(NOT_FOUND)).transform(this::getResponse);
// }
//
// Mono<ServerResponse> throwableError(final Throwable error) {
// logger.error(ERROR_RAISED, error);
// return Mono.just(error).transform(this::getResponse);
// }
//
// <T extends Throwable> Mono<ServerResponse> getResponse(final Mono<T> monoError) {
// return monoError.transform(ThrowableTranslator::translate)
// .flatMap(translation -> ServerResponse
// .status(translation.getHttpStatus())
// .body(Mono.just(new ErrorResponse(translation.getMessage())), ErrorResponse.class));
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
// public class ApiHandler {
//
// private static final String ADDRESS = "address";
// private static final String EMPTY_STRING = "";
//
// private final ErrorHandler errorHandler;
//
// private final GeoLocationService geoLocationService;
// private final SunriseSunsetService sunriseSunsetService;
//
// public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
// final ErrorHandler errorHandler) {
// this.errorHandler = errorHandler;
// this.geoLocationService = geoLocationService;
// this.sunriseSunsetService = sunriseSunsetService;
// }
//
// public Mono<ServerResponse> postLocation(final ServerRequest request) {
// return request.bodyToMono(LocationRequest.class)
// .map(LocationRequest::getAddress)
// .onErrorResume(throwable -> Mono.just(EMPTY_STRING))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// public Mono<ServerResponse> getLocation(final ServerRequest request) {
// return Mono.just(request.pathVariable(ADDRESS))
// .transform(this::buildResponse)
// .onErrorResume(errorHandler::throwableError);
// }
//
// Mono<ServerResponse> buildResponse(final Mono<String> address) {
// return address
// .transform(geoLocationService::fromAddress)
// .zipWhen(this::sunriseSunset, LocationResponse::new)
// .transform(this::serverResponse);
// }
//
// private Mono<SunriseSunset> sunriseSunset(GeographicCoordinates geographicCoordinates) {
// return Mono.just(geographicCoordinates).transform(sunriseSunsetService::fromGeographicCoordinates);
// }
//
// Mono<ServerResponse> serverResponse(Mono<LocationResponse> locationResponseMono) {
// return locationResponseMono.flatMap(locationResponse ->
// ServerResponse.ok().body(Mono.just(locationResponse), LocationResponse.class));
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/routers/ApiRouter.java
import org.learning.by.example.reactive.microservices.handlers.ErrorHandler;
import org.learning.by.example.reactive.microservices.handlers.ApiHandler;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.web.reactive.function.server.RequestPredicates.*;
import static org.springframework.web.reactive.function.server.RouterFunctions.nest;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
package org.learning.by.example.reactive.microservices.routers;
class ApiRouter {
private static final String API_PATH = "/api";
private static final String LOCATION_PATH = "/location";
private static final String ADDRESS_ARG = "/{address}";
private static final String LOCATION_WITH_ADDRESS_PATH = LOCATION_PATH + ADDRESS_ARG;
| static RouterFunction<?> doRoute(final ApiHandler apiHandler, final ErrorHandler errorHandler) { |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/test/tags/UnitTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/application/ReactiveMsApplication.java
// @SpringBootApplication
// public class ReactiveMsApplication {
// public static void main(String[] args) {
// SpringApplication.run(ReactiveMsApplication.class, args);
// }
// }
| import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.extension.ExtendWith;
import org.learning.by.example.reactive.microservices.application.ReactiveMsApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package org.learning.by.example.reactive.microservices.test.tags;
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Tag("UnitTest") | // Path: src/main/java/org/learning/by/example/reactive/microservices/application/ReactiveMsApplication.java
// @SpringBootApplication
// public class ReactiveMsApplication {
// public static void main(String[] args) {
// SpringApplication.run(ReactiveMsApplication.class, args);
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/tags/UnitTest.java
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.extension.ExtendWith;
import org.learning.by.example.reactive.microservices.application.ReactiveMsApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package org.learning.by.example.reactive.microservices.test.tags;
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Tag("UnitTest") | @SpringBootTest(classes = ReactiveMsApplication.class) |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/test/tags/SystemTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/application/ReactiveMsApplication.java
// @SpringBootApplication
// public class ReactiveMsApplication {
// public static void main(String[] args) {
// SpringApplication.run(ReactiveMsApplication.class, args);
// }
// }
| import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.extension.ExtendWith;
import org.learning.by.example.reactive.microservices.application.ReactiveMsApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package org.learning.by.example.reactive.microservices.test.tags;
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Tag("SystemTest") | // Path: src/main/java/org/learning/by/example/reactive/microservices/application/ReactiveMsApplication.java
// @SpringBootApplication
// public class ReactiveMsApplication {
// public static void main(String[] args) {
// SpringApplication.run(ReactiveMsApplication.class, args);
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/tags/SystemTest.java
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.extension.ExtendWith;
import org.learning.by.example.reactive.microservices.application.ReactiveMsApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package org.learning.by.example.reactive.microservices.test.tags;
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Tag("SystemTest") | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = ReactiveMsApplication.class) |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/handlers/ApiHandlerTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
| import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.*;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; | package org.learning.by.example.reactive.microservices.handlers;
@UnitTest
@DisplayName("ApiHandler Unit Tests")
class ApiHandlerTest {
private static final String ADDRESS_VARIABLE = "address";
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String NOT_FOUND = "not found";
private static final String CANT_GET_LOCATION = "cant get location";
private static final String CANT_GET_SUNRISE_SUNSET = "can't get sunrise sunset";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME)); | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/handlers/ApiHandlerTest.java
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.*;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
package org.learning.by.example.reactive.microservices.handlers;
@UnitTest
@DisplayName("ApiHandler Unit Tests")
class ApiHandlerTest {
private static final String ADDRESS_VARIABLE = "address";
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String NOT_FOUND = "not found";
private static final String CANT_GET_LOCATION = "cant get location";
private static final String CANT_GET_SUNRISE_SUNSET = "can't get sunrise sunset";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME)); | private static final Mono<GeographicCoordinates> LOCATION_NOT_FOUND = Mono.error(new GeoLocationNotFoundException(NOT_FOUND)); |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/handlers/ApiHandlerTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
| import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.*;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; | package org.learning.by.example.reactive.microservices.handlers;
@UnitTest
@DisplayName("ApiHandler Unit Tests")
class ApiHandlerTest {
private static final String ADDRESS_VARIABLE = "address";
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String NOT_FOUND = "not found";
private static final String CANT_GET_LOCATION = "cant get location";
private static final String CANT_GET_SUNRISE_SUNSET = "can't get sunrise sunset";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME));
private static final Mono<GeographicCoordinates> LOCATION_NOT_FOUND = Mono.error(new GeoLocationNotFoundException(NOT_FOUND)); | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/handlers/ApiHandlerTest.java
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.*;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
package org.learning.by.example.reactive.microservices.handlers;
@UnitTest
@DisplayName("ApiHandler Unit Tests")
class ApiHandlerTest {
private static final String ADDRESS_VARIABLE = "address";
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String NOT_FOUND = "not found";
private static final String CANT_GET_LOCATION = "cant get location";
private static final String CANT_GET_SUNRISE_SUNSET = "can't get sunrise sunset";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME));
private static final Mono<GeographicCoordinates> LOCATION_NOT_FOUND = Mono.error(new GeoLocationNotFoundException(NOT_FOUND)); | private static final Mono<GeographicCoordinates> LOCATION_EXCEPTION = Mono.error(new GetGeoLocationException(CANT_GET_LOCATION)); |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/handlers/ApiHandlerTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
| import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.*;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; | package org.learning.by.example.reactive.microservices.handlers;
@UnitTest
@DisplayName("ApiHandler Unit Tests")
class ApiHandlerTest {
private static final String ADDRESS_VARIABLE = "address";
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String NOT_FOUND = "not found";
private static final String CANT_GET_LOCATION = "cant get location";
private static final String CANT_GET_SUNRISE_SUNSET = "can't get sunrise sunset";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME));
private static final Mono<GeographicCoordinates> LOCATION_NOT_FOUND = Mono.error(new GeoLocationNotFoundException(NOT_FOUND));
private static final Mono<GeographicCoordinates> LOCATION_EXCEPTION = Mono.error(new GetGeoLocationException(CANT_GET_LOCATION)); | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/handlers/ApiHandlerTest.java
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.*;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
package org.learning.by.example.reactive.microservices.handlers;
@UnitTest
@DisplayName("ApiHandler Unit Tests")
class ApiHandlerTest {
private static final String ADDRESS_VARIABLE = "address";
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String NOT_FOUND = "not found";
private static final String CANT_GET_LOCATION = "cant get location";
private static final String CANT_GET_SUNRISE_SUNSET = "can't get sunrise sunset";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME));
private static final Mono<GeographicCoordinates> LOCATION_NOT_FOUND = Mono.error(new GeoLocationNotFoundException(NOT_FOUND));
private static final Mono<GeographicCoordinates> LOCATION_EXCEPTION = Mono.error(new GetGeoLocationException(CANT_GET_LOCATION)); | private static final Mono<GeographicCoordinates> SUNRISE_SUNSET_ERROR = Mono.error(new GetSunriseSunsetException(CANT_GET_SUNRISE_SUNSET)); |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/handlers/ApiHandlerTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
| import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.*;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; | package org.learning.by.example.reactive.microservices.handlers;
@UnitTest
@DisplayName("ApiHandler Unit Tests")
class ApiHandlerTest {
private static final String ADDRESS_VARIABLE = "address";
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String NOT_FOUND = "not found";
private static final String CANT_GET_LOCATION = "cant get location";
private static final String CANT_GET_SUNRISE_SUNSET = "can't get sunrise sunset";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME));
private static final Mono<GeographicCoordinates> LOCATION_NOT_FOUND = Mono.error(new GeoLocationNotFoundException(NOT_FOUND));
private static final Mono<GeographicCoordinates> LOCATION_EXCEPTION = Mono.error(new GetGeoLocationException(CANT_GET_LOCATION));
private static final Mono<GeographicCoordinates> SUNRISE_SUNSET_ERROR = Mono.error(new GetSunriseSunsetException(CANT_GET_SUNRISE_SUNSET));
@Autowired
private ApiHandler apiHandler;
@SpyBean | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/handlers/ApiHandlerTest.java
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.*;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
package org.learning.by.example.reactive.microservices.handlers;
@UnitTest
@DisplayName("ApiHandler Unit Tests")
class ApiHandlerTest {
private static final String ADDRESS_VARIABLE = "address";
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String NOT_FOUND = "not found";
private static final String CANT_GET_LOCATION = "cant get location";
private static final String CANT_GET_SUNRISE_SUNSET = "can't get sunrise sunset";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME));
private static final Mono<GeographicCoordinates> LOCATION_NOT_FOUND = Mono.error(new GeoLocationNotFoundException(NOT_FOUND));
private static final Mono<GeographicCoordinates> LOCATION_EXCEPTION = Mono.error(new GetGeoLocationException(CANT_GET_LOCATION));
private static final Mono<GeographicCoordinates> SUNRISE_SUNSET_ERROR = Mono.error(new GetSunriseSunsetException(CANT_GET_SUNRISE_SUNSET));
@Autowired
private ApiHandler apiHandler;
@SpyBean | private GeoLocationService geoLocationService; |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/handlers/ApiHandlerTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
| import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.*;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; | package org.learning.by.example.reactive.microservices.handlers;
@UnitTest
@DisplayName("ApiHandler Unit Tests")
class ApiHandlerTest {
private static final String ADDRESS_VARIABLE = "address";
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String NOT_FOUND = "not found";
private static final String CANT_GET_LOCATION = "cant get location";
private static final String CANT_GET_SUNRISE_SUNSET = "can't get sunrise sunset";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME));
private static final Mono<GeographicCoordinates> LOCATION_NOT_FOUND = Mono.error(new GeoLocationNotFoundException(NOT_FOUND));
private static final Mono<GeographicCoordinates> LOCATION_EXCEPTION = Mono.error(new GetGeoLocationException(CANT_GET_LOCATION));
private static final Mono<GeographicCoordinates> SUNRISE_SUNSET_ERROR = Mono.error(new GetSunriseSunsetException(CANT_GET_SUNRISE_SUNSET));
@Autowired
private ApiHandler apiHandler;
@SpyBean
private GeoLocationService geoLocationService;
@SpyBean | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/handlers/ApiHandlerTest.java
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.*;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
package org.learning.by.example.reactive.microservices.handlers;
@UnitTest
@DisplayName("ApiHandler Unit Tests")
class ApiHandlerTest {
private static final String ADDRESS_VARIABLE = "address";
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String NOT_FOUND = "not found";
private static final String CANT_GET_LOCATION = "cant get location";
private static final String CANT_GET_SUNRISE_SUNSET = "can't get sunrise sunset";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME));
private static final Mono<GeographicCoordinates> LOCATION_NOT_FOUND = Mono.error(new GeoLocationNotFoundException(NOT_FOUND));
private static final Mono<GeographicCoordinates> LOCATION_EXCEPTION = Mono.error(new GetGeoLocationException(CANT_GET_LOCATION));
private static final Mono<GeographicCoordinates> SUNRISE_SUNSET_ERROR = Mono.error(new GetSunriseSunsetException(CANT_GET_SUNRISE_SUNSET));
@Autowired
private ApiHandler apiHandler;
@SpyBean
private GeoLocationService geoLocationService;
@SpyBean | private SunriseSunsetService sunriseSunsetService; |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/handlers/ApiHandlerTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
| import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.*;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; |
private Mono<SunriseSunset> getData(final GeographicCoordinates ignore) {
return SUNRISE_SUNSET;
}
@Test
void combineTest() {
GOOGLE_LOCATION.zipWhen(this::getData, LocationResponse::new)
.subscribe(this::verifyLocationResponse);
}
private void verifyLocationResponse(final LocationResponse locationResponse) {
assertThat(locationResponse.getGeographicCoordinates().getLatitude(), is(GOOGLE_LAT));
assertThat(locationResponse.getGeographicCoordinates().getLongitude(), is(GOOGLE_LNG));
assertThat(locationResponse.getSunriseSunset().getSunrise(), is(SUNRISE_TIME));
assertThat(locationResponse.getSunriseSunset().getSunset(), is(SUNSET_TIME));
}
@Test
void serverResponseTest() {
GOOGLE_LOCATION.zipWhen(this::getData, LocationResponse::new)
.transform(apiHandler::serverResponse).subscribe(this::verifyServerResponse);
}
private void verifyServerResponse(final ServerResponse serverResponse) {
assertThat(serverResponse.statusCode(), is(HttpStatus.OK));
| // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/HandlersHelper.java
// public class HandlersHelper {
// @SuppressWarnings("unchecked")
// public static <T> T extractEntity(final ServerResponse response, final Class<T> type) {
//
// EntityResponse<Mono<T>> entityResponse = (EntityResponse<Mono<T>>) response;
//
// return type.cast(entityResponse.entity().block());
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/handlers/ApiHandlerTest.java
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.*;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.HandlersHelper;
import org.learning.by.example.reactive.microservices.test.tags.UnitTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
private Mono<SunriseSunset> getData(final GeographicCoordinates ignore) {
return SUNRISE_SUNSET;
}
@Test
void combineTest() {
GOOGLE_LOCATION.zipWhen(this::getData, LocationResponse::new)
.subscribe(this::verifyLocationResponse);
}
private void verifyLocationResponse(final LocationResponse locationResponse) {
assertThat(locationResponse.getGeographicCoordinates().getLatitude(), is(GOOGLE_LAT));
assertThat(locationResponse.getGeographicCoordinates().getLongitude(), is(GOOGLE_LNG));
assertThat(locationResponse.getSunriseSunset().getSunrise(), is(SUNRISE_TIME));
assertThat(locationResponse.getSunriseSunset().getSunset(), is(SUNSET_TIME));
}
@Test
void serverResponseTest() {
GOOGLE_LOCATION.zipWhen(this::getData, LocationResponse::new)
.transform(apiHandler::serverResponse).subscribe(this::verifyServerResponse);
}
private void verifyServerResponse(final ServerResponse serverResponse) {
assertThat(serverResponse.statusCode(), is(HttpStatus.OK));
| final LocationResponse locationResponse = HandlersHelper.extractEntity(serverResponse, LocationResponse.class); |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetServiceImpl.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeoTimesResponse.java
// public final class GeoTimesResponse {
//
// private final Results results;
// private final String status;
//
// @JsonCreator
// public GeoTimesResponse(@JsonProperty("results") Results results, @JsonProperty("status") String status) {
// this.results = results;
// this.status = status;
// }
//
// public Results getResults() {
// return results;
// }
//
// public String getStatus() {
// return status;
// }
//
// public static final class Results {
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// final String sunrise;
// final String sunset;
// final String solar_noon;
// final long day_length;
// final String civil_twilight_begin;
// final String civil_twilight_end;
// final String nautical_twilight_begin;
// final String nautical_twilight_end;
// final String astronomical_twilight_begin;
// final String astronomical_twilight_end;
//
// @JsonCreator
// public Results(@JsonProperty("sunrise") String sunrise, @JsonProperty("sunset") String sunset, @JsonProperty("solar_noon") String solar_noon, @JsonProperty("day_length") long day_length, @JsonProperty("civil_twilight_begin") String civil_twilight_begin, @JsonProperty("civil_twilight_end") String civil_twilight_end, @JsonProperty("nautical_twilight_begin") String nautical_twilight_begin, @JsonProperty("nautical_twilight_end") String nautical_twilight_end, @JsonProperty("astronomical_twilight_begin") String astronomical_twilight_begin, @JsonProperty("astronomical_twilight_end") String astronomical_twilight_end) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// this.solar_noon = solar_noon;
// this.day_length = day_length;
// this.civil_twilight_begin = civil_twilight_begin;
// this.civil_twilight_end = civil_twilight_end;
// this.nautical_twilight_begin = nautical_twilight_begin;
// this.nautical_twilight_end = nautical_twilight_end;
// this.astronomical_twilight_begin = astronomical_twilight_begin;
// this.astronomical_twilight_end = astronomical_twilight_end;
// }
// }
// }
| import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.model.GeoTimesResponse;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono; | package org.learning.by.example.reactive.microservices.services;
public class SunriseSunsetServiceImpl implements SunriseSunsetService {
private static final String BEGIN_PARAMETERS = "?";
private static final String NEXT_PARAMETER = "&";
private static final String EQUALS = "=";
private static final String LATITUDE_PARAMETER = "lat" + EQUALS;
private static final String LONGITUDE_PARAMETER = "lng" + EQUALS;
private static final String DATE_PARAMETER = "date" + EQUALS;
private static final String TODAY_DATE = "today";
private static final String FORMATTED_PARAMETER = "formatted" + EQUALS;
private static final String NOT_FORMATTED = "0";
private static final String ERROR_GETTING_DATA = "error getting sunrise and sunset";
private static final String SUNRISE_RESULT_NOT_OK = "sunrise and sunrise result was not OK";
private static final String STATUS_OK = "OK";
WebClient webClient;
private final String endPoint;
public SunriseSunsetServiceImpl(final String endPoint) {
this.endPoint = endPoint;
this.webClient = WebClient.create();
}
@Override | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeoTimesResponse.java
// public final class GeoTimesResponse {
//
// private final Results results;
// private final String status;
//
// @JsonCreator
// public GeoTimesResponse(@JsonProperty("results") Results results, @JsonProperty("status") String status) {
// this.results = results;
// this.status = status;
// }
//
// public Results getResults() {
// return results;
// }
//
// public String getStatus() {
// return status;
// }
//
// public static final class Results {
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// final String sunrise;
// final String sunset;
// final String solar_noon;
// final long day_length;
// final String civil_twilight_begin;
// final String civil_twilight_end;
// final String nautical_twilight_begin;
// final String nautical_twilight_end;
// final String astronomical_twilight_begin;
// final String astronomical_twilight_end;
//
// @JsonCreator
// public Results(@JsonProperty("sunrise") String sunrise, @JsonProperty("sunset") String sunset, @JsonProperty("solar_noon") String solar_noon, @JsonProperty("day_length") long day_length, @JsonProperty("civil_twilight_begin") String civil_twilight_begin, @JsonProperty("civil_twilight_end") String civil_twilight_end, @JsonProperty("nautical_twilight_begin") String nautical_twilight_begin, @JsonProperty("nautical_twilight_end") String nautical_twilight_end, @JsonProperty("astronomical_twilight_begin") String astronomical_twilight_begin, @JsonProperty("astronomical_twilight_end") String astronomical_twilight_end) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// this.solar_noon = solar_noon;
// this.day_length = day_length;
// this.civil_twilight_begin = civil_twilight_begin;
// this.civil_twilight_end = civil_twilight_end;
// this.nautical_twilight_begin = nautical_twilight_begin;
// this.nautical_twilight_end = nautical_twilight_end;
// this.astronomical_twilight_begin = astronomical_twilight_begin;
// this.astronomical_twilight_end = astronomical_twilight_end;
// }
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetServiceImpl.java
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.model.GeoTimesResponse;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
package org.learning.by.example.reactive.microservices.services;
public class SunriseSunsetServiceImpl implements SunriseSunsetService {
private static final String BEGIN_PARAMETERS = "?";
private static final String NEXT_PARAMETER = "&";
private static final String EQUALS = "=";
private static final String LATITUDE_PARAMETER = "lat" + EQUALS;
private static final String LONGITUDE_PARAMETER = "lng" + EQUALS;
private static final String DATE_PARAMETER = "date" + EQUALS;
private static final String TODAY_DATE = "today";
private static final String FORMATTED_PARAMETER = "formatted" + EQUALS;
private static final String NOT_FORMATTED = "0";
private static final String ERROR_GETTING_DATA = "error getting sunrise and sunset";
private static final String SUNRISE_RESULT_NOT_OK = "sunrise and sunrise result was not OK";
private static final String STATUS_OK = "OK";
WebClient webClient;
private final String endPoint;
public SunriseSunsetServiceImpl(final String endPoint) {
this.endPoint = endPoint;
this.webClient = WebClient.create();
}
@Override | public Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> location) { |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetServiceImpl.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeoTimesResponse.java
// public final class GeoTimesResponse {
//
// private final Results results;
// private final String status;
//
// @JsonCreator
// public GeoTimesResponse(@JsonProperty("results") Results results, @JsonProperty("status") String status) {
// this.results = results;
// this.status = status;
// }
//
// public Results getResults() {
// return results;
// }
//
// public String getStatus() {
// return status;
// }
//
// public static final class Results {
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// final String sunrise;
// final String sunset;
// final String solar_noon;
// final long day_length;
// final String civil_twilight_begin;
// final String civil_twilight_end;
// final String nautical_twilight_begin;
// final String nautical_twilight_end;
// final String astronomical_twilight_begin;
// final String astronomical_twilight_end;
//
// @JsonCreator
// public Results(@JsonProperty("sunrise") String sunrise, @JsonProperty("sunset") String sunset, @JsonProperty("solar_noon") String solar_noon, @JsonProperty("day_length") long day_length, @JsonProperty("civil_twilight_begin") String civil_twilight_begin, @JsonProperty("civil_twilight_end") String civil_twilight_end, @JsonProperty("nautical_twilight_begin") String nautical_twilight_begin, @JsonProperty("nautical_twilight_end") String nautical_twilight_end, @JsonProperty("astronomical_twilight_begin") String astronomical_twilight_begin, @JsonProperty("astronomical_twilight_end") String astronomical_twilight_end) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// this.solar_noon = solar_noon;
// this.day_length = day_length;
// this.civil_twilight_begin = civil_twilight_begin;
// this.civil_twilight_end = civil_twilight_end;
// this.nautical_twilight_begin = nautical_twilight_begin;
// this.nautical_twilight_end = nautical_twilight_end;
// this.astronomical_twilight_begin = astronomical_twilight_begin;
// this.astronomical_twilight_end = astronomical_twilight_end;
// }
// }
// }
| import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.model.GeoTimesResponse;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono; | package org.learning.by.example.reactive.microservices.services;
public class SunriseSunsetServiceImpl implements SunriseSunsetService {
private static final String BEGIN_PARAMETERS = "?";
private static final String NEXT_PARAMETER = "&";
private static final String EQUALS = "=";
private static final String LATITUDE_PARAMETER = "lat" + EQUALS;
private static final String LONGITUDE_PARAMETER = "lng" + EQUALS;
private static final String DATE_PARAMETER = "date" + EQUALS;
private static final String TODAY_DATE = "today";
private static final String FORMATTED_PARAMETER = "formatted" + EQUALS;
private static final String NOT_FORMATTED = "0";
private static final String ERROR_GETTING_DATA = "error getting sunrise and sunset";
private static final String SUNRISE_RESULT_NOT_OK = "sunrise and sunrise result was not OK";
private static final String STATUS_OK = "OK";
WebClient webClient;
private final String endPoint;
public SunriseSunsetServiceImpl(final String endPoint) {
this.endPoint = endPoint;
this.webClient = WebClient.create();
}
@Override | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeoTimesResponse.java
// public final class GeoTimesResponse {
//
// private final Results results;
// private final String status;
//
// @JsonCreator
// public GeoTimesResponse(@JsonProperty("results") Results results, @JsonProperty("status") String status) {
// this.results = results;
// this.status = status;
// }
//
// public Results getResults() {
// return results;
// }
//
// public String getStatus() {
// return status;
// }
//
// public static final class Results {
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// final String sunrise;
// final String sunset;
// final String solar_noon;
// final long day_length;
// final String civil_twilight_begin;
// final String civil_twilight_end;
// final String nautical_twilight_begin;
// final String nautical_twilight_end;
// final String astronomical_twilight_begin;
// final String astronomical_twilight_end;
//
// @JsonCreator
// public Results(@JsonProperty("sunrise") String sunrise, @JsonProperty("sunset") String sunset, @JsonProperty("solar_noon") String solar_noon, @JsonProperty("day_length") long day_length, @JsonProperty("civil_twilight_begin") String civil_twilight_begin, @JsonProperty("civil_twilight_end") String civil_twilight_end, @JsonProperty("nautical_twilight_begin") String nautical_twilight_begin, @JsonProperty("nautical_twilight_end") String nautical_twilight_end, @JsonProperty("astronomical_twilight_begin") String astronomical_twilight_begin, @JsonProperty("astronomical_twilight_end") String astronomical_twilight_end) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// this.solar_noon = solar_noon;
// this.day_length = day_length;
// this.civil_twilight_begin = civil_twilight_begin;
// this.civil_twilight_end = civil_twilight_end;
// this.nautical_twilight_begin = nautical_twilight_begin;
// this.nautical_twilight_end = nautical_twilight_end;
// this.astronomical_twilight_begin = astronomical_twilight_begin;
// this.astronomical_twilight_end = astronomical_twilight_end;
// }
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetServiceImpl.java
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.model.GeoTimesResponse;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
package org.learning.by.example.reactive.microservices.services;
public class SunriseSunsetServiceImpl implements SunriseSunsetService {
private static final String BEGIN_PARAMETERS = "?";
private static final String NEXT_PARAMETER = "&";
private static final String EQUALS = "=";
private static final String LATITUDE_PARAMETER = "lat" + EQUALS;
private static final String LONGITUDE_PARAMETER = "lng" + EQUALS;
private static final String DATE_PARAMETER = "date" + EQUALS;
private static final String TODAY_DATE = "today";
private static final String FORMATTED_PARAMETER = "formatted" + EQUALS;
private static final String NOT_FORMATTED = "0";
private static final String ERROR_GETTING_DATA = "error getting sunrise and sunset";
private static final String SUNRISE_RESULT_NOT_OK = "sunrise and sunrise result was not OK";
private static final String STATUS_OK = "OK";
WebClient webClient;
private final String endPoint;
public SunriseSunsetServiceImpl(final String endPoint) {
this.endPoint = endPoint;
this.webClient = WebClient.create();
}
@Override | public Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> location) { |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetServiceImpl.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeoTimesResponse.java
// public final class GeoTimesResponse {
//
// private final Results results;
// private final String status;
//
// @JsonCreator
// public GeoTimesResponse(@JsonProperty("results") Results results, @JsonProperty("status") String status) {
// this.results = results;
// this.status = status;
// }
//
// public Results getResults() {
// return results;
// }
//
// public String getStatus() {
// return status;
// }
//
// public static final class Results {
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// final String sunrise;
// final String sunset;
// final String solar_noon;
// final long day_length;
// final String civil_twilight_begin;
// final String civil_twilight_end;
// final String nautical_twilight_begin;
// final String nautical_twilight_end;
// final String astronomical_twilight_begin;
// final String astronomical_twilight_end;
//
// @JsonCreator
// public Results(@JsonProperty("sunrise") String sunrise, @JsonProperty("sunset") String sunset, @JsonProperty("solar_noon") String solar_noon, @JsonProperty("day_length") long day_length, @JsonProperty("civil_twilight_begin") String civil_twilight_begin, @JsonProperty("civil_twilight_end") String civil_twilight_end, @JsonProperty("nautical_twilight_begin") String nautical_twilight_begin, @JsonProperty("nautical_twilight_end") String nautical_twilight_end, @JsonProperty("astronomical_twilight_begin") String astronomical_twilight_begin, @JsonProperty("astronomical_twilight_end") String astronomical_twilight_end) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// this.solar_noon = solar_noon;
// this.day_length = day_length;
// this.civil_twilight_begin = civil_twilight_begin;
// this.civil_twilight_end = civil_twilight_end;
// this.nautical_twilight_begin = nautical_twilight_begin;
// this.nautical_twilight_end = nautical_twilight_end;
// this.astronomical_twilight_begin = astronomical_twilight_begin;
// this.astronomical_twilight_end = astronomical_twilight_end;
// }
// }
// }
| import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.model.GeoTimesResponse;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono; | package org.learning.by.example.reactive.microservices.services;
public class SunriseSunsetServiceImpl implements SunriseSunsetService {
private static final String BEGIN_PARAMETERS = "?";
private static final String NEXT_PARAMETER = "&";
private static final String EQUALS = "=";
private static final String LATITUDE_PARAMETER = "lat" + EQUALS;
private static final String LONGITUDE_PARAMETER = "lng" + EQUALS;
private static final String DATE_PARAMETER = "date" + EQUALS;
private static final String TODAY_DATE = "today";
private static final String FORMATTED_PARAMETER = "formatted" + EQUALS;
private static final String NOT_FORMATTED = "0";
private static final String ERROR_GETTING_DATA = "error getting sunrise and sunset";
private static final String SUNRISE_RESULT_NOT_OK = "sunrise and sunrise result was not OK";
private static final String STATUS_OK = "OK";
WebClient webClient;
private final String endPoint;
public SunriseSunsetServiceImpl(final String endPoint) {
this.endPoint = endPoint;
this.webClient = WebClient.create();
}
@Override
public Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> location) {
return location
.transform(this::buildUrl)
.transform(this::get) | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeoTimesResponse.java
// public final class GeoTimesResponse {
//
// private final Results results;
// private final String status;
//
// @JsonCreator
// public GeoTimesResponse(@JsonProperty("results") Results results, @JsonProperty("status") String status) {
// this.results = results;
// this.status = status;
// }
//
// public Results getResults() {
// return results;
// }
//
// public String getStatus() {
// return status;
// }
//
// public static final class Results {
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// final String sunrise;
// final String sunset;
// final String solar_noon;
// final long day_length;
// final String civil_twilight_begin;
// final String civil_twilight_end;
// final String nautical_twilight_begin;
// final String nautical_twilight_end;
// final String astronomical_twilight_begin;
// final String astronomical_twilight_end;
//
// @JsonCreator
// public Results(@JsonProperty("sunrise") String sunrise, @JsonProperty("sunset") String sunset, @JsonProperty("solar_noon") String solar_noon, @JsonProperty("day_length") long day_length, @JsonProperty("civil_twilight_begin") String civil_twilight_begin, @JsonProperty("civil_twilight_end") String civil_twilight_end, @JsonProperty("nautical_twilight_begin") String nautical_twilight_begin, @JsonProperty("nautical_twilight_end") String nautical_twilight_end, @JsonProperty("astronomical_twilight_begin") String astronomical_twilight_begin, @JsonProperty("astronomical_twilight_end") String astronomical_twilight_end) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// this.solar_noon = solar_noon;
// this.day_length = day_length;
// this.civil_twilight_begin = civil_twilight_begin;
// this.civil_twilight_end = civil_twilight_end;
// this.nautical_twilight_begin = nautical_twilight_begin;
// this.nautical_twilight_end = nautical_twilight_end;
// this.astronomical_twilight_begin = astronomical_twilight_begin;
// this.astronomical_twilight_end = astronomical_twilight_end;
// }
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetServiceImpl.java
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.model.GeoTimesResponse;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
package org.learning.by.example.reactive.microservices.services;
public class SunriseSunsetServiceImpl implements SunriseSunsetService {
private static final String BEGIN_PARAMETERS = "?";
private static final String NEXT_PARAMETER = "&";
private static final String EQUALS = "=";
private static final String LATITUDE_PARAMETER = "lat" + EQUALS;
private static final String LONGITUDE_PARAMETER = "lng" + EQUALS;
private static final String DATE_PARAMETER = "date" + EQUALS;
private static final String TODAY_DATE = "today";
private static final String FORMATTED_PARAMETER = "formatted" + EQUALS;
private static final String NOT_FORMATTED = "0";
private static final String ERROR_GETTING_DATA = "error getting sunrise and sunset";
private static final String SUNRISE_RESULT_NOT_OK = "sunrise and sunrise result was not OK";
private static final String STATUS_OK = "OK";
WebClient webClient;
private final String endPoint;
public SunriseSunsetServiceImpl(final String endPoint) {
this.endPoint = endPoint;
this.webClient = WebClient.create();
}
@Override
public Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> location) {
return location
.transform(this::buildUrl)
.transform(this::get) | .onErrorResume(throwable -> Mono.error(new GetSunriseSunsetException(ERROR_GETTING_DATA, throwable))) |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetServiceImpl.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeoTimesResponse.java
// public final class GeoTimesResponse {
//
// private final Results results;
// private final String status;
//
// @JsonCreator
// public GeoTimesResponse(@JsonProperty("results") Results results, @JsonProperty("status") String status) {
// this.results = results;
// this.status = status;
// }
//
// public Results getResults() {
// return results;
// }
//
// public String getStatus() {
// return status;
// }
//
// public static final class Results {
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// final String sunrise;
// final String sunset;
// final String solar_noon;
// final long day_length;
// final String civil_twilight_begin;
// final String civil_twilight_end;
// final String nautical_twilight_begin;
// final String nautical_twilight_end;
// final String astronomical_twilight_begin;
// final String astronomical_twilight_end;
//
// @JsonCreator
// public Results(@JsonProperty("sunrise") String sunrise, @JsonProperty("sunset") String sunset, @JsonProperty("solar_noon") String solar_noon, @JsonProperty("day_length") long day_length, @JsonProperty("civil_twilight_begin") String civil_twilight_begin, @JsonProperty("civil_twilight_end") String civil_twilight_end, @JsonProperty("nautical_twilight_begin") String nautical_twilight_begin, @JsonProperty("nautical_twilight_end") String nautical_twilight_end, @JsonProperty("astronomical_twilight_begin") String astronomical_twilight_begin, @JsonProperty("astronomical_twilight_end") String astronomical_twilight_end) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// this.solar_noon = solar_noon;
// this.day_length = day_length;
// this.civil_twilight_begin = civil_twilight_begin;
// this.civil_twilight_end = civil_twilight_end;
// this.nautical_twilight_begin = nautical_twilight_begin;
// this.nautical_twilight_end = nautical_twilight_end;
// this.astronomical_twilight_begin = astronomical_twilight_begin;
// this.astronomical_twilight_end = astronomical_twilight_end;
// }
// }
// }
| import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.model.GeoTimesResponse;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono; | WebClient webClient;
private final String endPoint;
public SunriseSunsetServiceImpl(final String endPoint) {
this.endPoint = endPoint;
this.webClient = WebClient.create();
}
@Override
public Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> location) {
return location
.transform(this::buildUrl)
.transform(this::get)
.onErrorResume(throwable -> Mono.error(new GetSunriseSunsetException(ERROR_GETTING_DATA, throwable)))
.transform(this::createResult);
}
Mono<String> buildUrl(final Mono<GeographicCoordinates> geographicCoordinatesMono) {
return geographicCoordinatesMono.flatMap(geographicCoordinates -> Mono.just(endPoint
.concat(BEGIN_PARAMETERS)
.concat(LATITUDE_PARAMETER).concat(Double.toString(geographicCoordinates.getLatitude()))
.concat(NEXT_PARAMETER)
.concat(LONGITUDE_PARAMETER).concat(Double.toString(geographicCoordinates.getLongitude()))
.concat(NEXT_PARAMETER)
.concat(DATE_PARAMETER).concat(TODAY_DATE)
.concat(NEXT_PARAMETER)
.concat(FORMATTED_PARAMETER).concat(NOT_FORMATTED)
));
}
| // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetSunriseSunsetException.java
// public class GetSunriseSunsetException extends Exception {
//
// public GetSunriseSunsetException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetSunriseSunsetException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeoTimesResponse.java
// public final class GeoTimesResponse {
//
// private final Results results;
// private final String status;
//
// @JsonCreator
// public GeoTimesResponse(@JsonProperty("results") Results results, @JsonProperty("status") String status) {
// this.results = results;
// this.status = status;
// }
//
// public Results getResults() {
// return results;
// }
//
// public String getStatus() {
// return status;
// }
//
// public static final class Results {
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// final String sunrise;
// final String sunset;
// final String solar_noon;
// final long day_length;
// final String civil_twilight_begin;
// final String civil_twilight_end;
// final String nautical_twilight_begin;
// final String nautical_twilight_end;
// final String astronomical_twilight_begin;
// final String astronomical_twilight_end;
//
// @JsonCreator
// public Results(@JsonProperty("sunrise") String sunrise, @JsonProperty("sunset") String sunset, @JsonProperty("solar_noon") String solar_noon, @JsonProperty("day_length") long day_length, @JsonProperty("civil_twilight_begin") String civil_twilight_begin, @JsonProperty("civil_twilight_end") String civil_twilight_end, @JsonProperty("nautical_twilight_begin") String nautical_twilight_begin, @JsonProperty("nautical_twilight_end") String nautical_twilight_end, @JsonProperty("astronomical_twilight_begin") String astronomical_twilight_begin, @JsonProperty("astronomical_twilight_end") String astronomical_twilight_end) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// this.solar_noon = solar_noon;
// this.day_length = day_length;
// this.civil_twilight_begin = civil_twilight_begin;
// this.civil_twilight_end = civil_twilight_end;
// this.nautical_twilight_begin = nautical_twilight_begin;
// this.nautical_twilight_end = nautical_twilight_end;
// this.astronomical_twilight_begin = astronomical_twilight_begin;
// this.astronomical_twilight_end = astronomical_twilight_end;
// }
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetServiceImpl.java
import org.learning.by.example.reactive.microservices.exceptions.GetSunriseSunsetException;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.model.GeoTimesResponse;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
WebClient webClient;
private final String endPoint;
public SunriseSunsetServiceImpl(final String endPoint) {
this.endPoint = endPoint;
this.webClient = WebClient.create();
}
@Override
public Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> location) {
return location
.transform(this::buildUrl)
.transform(this::get)
.onErrorResume(throwable -> Mono.error(new GetSunriseSunsetException(ERROR_GETTING_DATA, throwable)))
.transform(this::createResult);
}
Mono<String> buildUrl(final Mono<GeographicCoordinates> geographicCoordinatesMono) {
return geographicCoordinatesMono.flatMap(geographicCoordinates -> Mono.just(endPoint
.concat(BEGIN_PARAMETERS)
.concat(LATITUDE_PARAMETER).concat(Double.toString(geographicCoordinates.getLatitude()))
.concat(NEXT_PARAMETER)
.concat(LONGITUDE_PARAMETER).concat(Double.toString(geographicCoordinates.getLongitude()))
.concat(NEXT_PARAMETER)
.concat(DATE_PARAMETER).concat(TODAY_DATE)
.concat(NEXT_PARAMETER)
.concat(FORMATTED_PARAMETER).concat(NOT_FORMATTED)
));
}
| Mono<GeoTimesResponse> get(final Mono<String> monoUrl) { |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
| import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono; | package org.learning.by.example.reactive.microservices.handlers;
public class ApiHandler {
private static final String ADDRESS = "address";
private static final String EMPTY_STRING = "";
private final ErrorHandler errorHandler;
| // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
package org.learning.by.example.reactive.microservices.handlers;
public class ApiHandler {
private static final String ADDRESS = "address";
private static final String EMPTY_STRING = "";
private final ErrorHandler errorHandler;
| private final GeoLocationService geoLocationService; |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
| import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono; | package org.learning.by.example.reactive.microservices.handlers;
public class ApiHandler {
private static final String ADDRESS = "address";
private static final String EMPTY_STRING = "";
private final ErrorHandler errorHandler;
private final GeoLocationService geoLocationService; | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
package org.learning.by.example.reactive.microservices.handlers;
public class ApiHandler {
private static final String ADDRESS = "address";
private static final String EMPTY_STRING = "";
private final ErrorHandler errorHandler;
private final GeoLocationService geoLocationService; | private final SunriseSunsetService sunriseSunsetService; |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
| import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono; | package org.learning.by.example.reactive.microservices.handlers;
public class ApiHandler {
private static final String ADDRESS = "address";
private static final String EMPTY_STRING = "";
private final ErrorHandler errorHandler;
private final GeoLocationService geoLocationService;
private final SunriseSunsetService sunriseSunsetService;
public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
final ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
this.geoLocationService = geoLocationService;
this.sunriseSunsetService = sunriseSunsetService;
}
public Mono<ServerResponse> postLocation(final ServerRequest request) { | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
package org.learning.by.example.reactive.microservices.handlers;
public class ApiHandler {
private static final String ADDRESS = "address";
private static final String EMPTY_STRING = "";
private final ErrorHandler errorHandler;
private final GeoLocationService geoLocationService;
private final SunriseSunsetService sunriseSunsetService;
public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
final ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
this.geoLocationService = geoLocationService;
this.sunriseSunsetService = sunriseSunsetService;
}
public Mono<ServerResponse> postLocation(final ServerRequest request) { | return request.bodyToMono(LocationRequest.class) |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
| import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono; | package org.learning.by.example.reactive.microservices.handlers;
public class ApiHandler {
private static final String ADDRESS = "address";
private static final String EMPTY_STRING = "";
private final ErrorHandler errorHandler;
private final GeoLocationService geoLocationService;
private final SunriseSunsetService sunriseSunsetService;
public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
final ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
this.geoLocationService = geoLocationService;
this.sunriseSunsetService = sunriseSunsetService;
}
public Mono<ServerResponse> postLocation(final ServerRequest request) {
return request.bodyToMono(LocationRequest.class)
.map(LocationRequest::getAddress)
.onErrorResume(throwable -> Mono.just(EMPTY_STRING))
.transform(this::buildResponse)
.onErrorResume(errorHandler::throwableError);
}
public Mono<ServerResponse> getLocation(final ServerRequest request) {
return Mono.just(request.pathVariable(ADDRESS))
.transform(this::buildResponse)
.onErrorResume(errorHandler::throwableError);
}
Mono<ServerResponse> buildResponse(final Mono<String> address) {
return address
.transform(geoLocationService::fromAddress) | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
package org.learning.by.example.reactive.microservices.handlers;
public class ApiHandler {
private static final String ADDRESS = "address";
private static final String EMPTY_STRING = "";
private final ErrorHandler errorHandler;
private final GeoLocationService geoLocationService;
private final SunriseSunsetService sunriseSunsetService;
public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
final ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
this.geoLocationService = geoLocationService;
this.sunriseSunsetService = sunriseSunsetService;
}
public Mono<ServerResponse> postLocation(final ServerRequest request) {
return request.bodyToMono(LocationRequest.class)
.map(LocationRequest::getAddress)
.onErrorResume(throwable -> Mono.just(EMPTY_STRING))
.transform(this::buildResponse)
.onErrorResume(errorHandler::throwableError);
}
public Mono<ServerResponse> getLocation(final ServerRequest request) {
return Mono.just(request.pathVariable(ADDRESS))
.transform(this::buildResponse)
.onErrorResume(errorHandler::throwableError);
}
Mono<ServerResponse> buildResponse(final Mono<String> address) {
return address
.transform(geoLocationService::fromAddress) | .zipWhen(this::sunriseSunset, LocationResponse::new) |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
| import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono; | private final SunriseSunsetService sunriseSunsetService;
public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
final ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
this.geoLocationService = geoLocationService;
this.sunriseSunsetService = sunriseSunsetService;
}
public Mono<ServerResponse> postLocation(final ServerRequest request) {
return request.bodyToMono(LocationRequest.class)
.map(LocationRequest::getAddress)
.onErrorResume(throwable -> Mono.just(EMPTY_STRING))
.transform(this::buildResponse)
.onErrorResume(errorHandler::throwableError);
}
public Mono<ServerResponse> getLocation(final ServerRequest request) {
return Mono.just(request.pathVariable(ADDRESS))
.transform(this::buildResponse)
.onErrorResume(errorHandler::throwableError);
}
Mono<ServerResponse> buildResponse(final Mono<String> address) {
return address
.transform(geoLocationService::fromAddress)
.zipWhen(this::sunriseSunset, LocationResponse::new)
.transform(this::serverResponse);
}
| // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
private final SunriseSunsetService sunriseSunsetService;
public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
final ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
this.geoLocationService = geoLocationService;
this.sunriseSunsetService = sunriseSunsetService;
}
public Mono<ServerResponse> postLocation(final ServerRequest request) {
return request.bodyToMono(LocationRequest.class)
.map(LocationRequest::getAddress)
.onErrorResume(throwable -> Mono.just(EMPTY_STRING))
.transform(this::buildResponse)
.onErrorResume(errorHandler::throwableError);
}
public Mono<ServerResponse> getLocation(final ServerRequest request) {
return Mono.just(request.pathVariable(ADDRESS))
.transform(this::buildResponse)
.onErrorResume(errorHandler::throwableError);
}
Mono<ServerResponse> buildResponse(final Mono<String> address) {
return address
.transform(geoLocationService::fromAddress)
.zipWhen(this::sunriseSunset, LocationResponse::new)
.transform(this::serverResponse);
}
| private Mono<SunriseSunset> sunriseSunset(GeographicCoordinates geographicCoordinates) { |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
| import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono; | private final SunriseSunsetService sunriseSunsetService;
public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
final ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
this.geoLocationService = geoLocationService;
this.sunriseSunsetService = sunriseSunsetService;
}
public Mono<ServerResponse> postLocation(final ServerRequest request) {
return request.bodyToMono(LocationRequest.class)
.map(LocationRequest::getAddress)
.onErrorResume(throwable -> Mono.just(EMPTY_STRING))
.transform(this::buildResponse)
.onErrorResume(errorHandler::throwableError);
}
public Mono<ServerResponse> getLocation(final ServerRequest request) {
return Mono.just(request.pathVariable(ADDRESS))
.transform(this::buildResponse)
.onErrorResume(errorHandler::throwableError);
}
Mono<ServerResponse> buildResponse(final Mono<String> address) {
return address
.transform(geoLocationService::fromAddress)
.zipWhen(this::sunriseSunset, LocationResponse::new)
.transform(this::serverResponse);
}
| // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
private final SunriseSunsetService sunriseSunsetService;
public ApiHandler(final GeoLocationService geoLocationService, final SunriseSunsetService sunriseSunsetService,
final ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
this.geoLocationService = geoLocationService;
this.sunriseSunsetService = sunriseSunsetService;
}
public Mono<ServerResponse> postLocation(final ServerRequest request) {
return request.bodyToMono(LocationRequest.class)
.map(LocationRequest::getAddress)
.onErrorResume(throwable -> Mono.just(EMPTY_STRING))
.transform(this::buildResponse)
.onErrorResume(errorHandler::throwableError);
}
public Mono<ServerResponse> getLocation(final ServerRequest request) {
return Mono.just(request.pathVariable(ADDRESS))
.transform(this::buildResponse)
.onErrorResume(errorHandler::throwableError);
}
Mono<ServerResponse> buildResponse(final Mono<String> address) {
return address
.transform(geoLocationService::fromAddress)
.zipWhen(this::sunriseSunset, LocationResponse::new)
.transform(this::serverResponse);
}
| private Mono<SunriseSunset> sunriseSunset(GeographicCoordinates geographicCoordinates) { |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/application/ReactiveMsApplicationTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
| import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.SystemTest;
import org.springframework.boot.web.server.LocalServerPort;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; | package org.learning.by.example.reactive.microservices.application;
@SystemTest
@DisplayName("ReactiveMsApplication System Tests") | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/application/ReactiveMsApplicationTest.java
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.SystemTest;
import org.springframework.boot.web.server.LocalServerPort;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
package org.learning.by.example.reactive.microservices.application;
@SystemTest
@DisplayName("ReactiveMsApplication System Tests") | class ReactiveMsApplicationTest extends BasicIntegrationTest { |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/application/ReactiveMsApplicationTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
| import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.SystemTest;
import org.springframework.boot.web.server.LocalServerPort;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; | package org.learning.by.example.reactive.microservices.application;
@SystemTest
@DisplayName("ReactiveMsApplication System Tests")
class ReactiveMsApplicationTest extends BasicIntegrationTest {
private static final String LOCATION_PATH = "/api/location";
private static final String ADDRESS_ARG = "{address}";
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
@LocalServerPort
private int port;
@BeforeEach
void setup() {
bindToServerPort(port);
}
@Test
@DisplayName("get location from URL")
void getLocationTest() { | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/application/ReactiveMsApplicationTest.java
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.SystemTest;
import org.springframework.boot.web.server.LocalServerPort;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
package org.learning.by.example.reactive.microservices.application;
@SystemTest
@DisplayName("ReactiveMsApplication System Tests")
class ReactiveMsApplicationTest extends BasicIntegrationTest {
private static final String LOCATION_PATH = "/api/location";
private static final String ADDRESS_ARG = "{address}";
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
@LocalServerPort
private int port;
@BeforeEach
void setup() {
bindToServerPort(port);
}
@Test
@DisplayName("get location from URL")
void getLocationTest() { | final LocationResponse response = get( |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/application/ReactiveMsApplicationTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
| import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.SystemTest;
import org.springframework.boot.web.server.LocalServerPort;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; |
@LocalServerPort
private int port;
@BeforeEach
void setup() {
bindToServerPort(port);
}
@Test
@DisplayName("get location from URL")
void getLocationTest() {
final LocationResponse response = get(
builder -> builder.path(LOCATION_PATH).path("/").path(ADDRESS_ARG).build(GOOGLE_ADDRESS),
LocationResponse.class);
assertThat(response.getGeographicCoordinates(), not(nullValue()));
assertThat(response.getGeographicCoordinates().getLatitude(), not(nullValue()));
assertThat(response.getGeographicCoordinates().getLongitude(), not(nullValue()));
assertThat(response.getSunriseSunset(), not(nullValue()));
assertThat(response.getSunriseSunset().getSunrise(), not(isEmptyOrNullString()));
assertThat(response.getSunriseSunset().getSunset(), not(isEmptyOrNullString()));
}
@Test
@DisplayName("post location")
void postLocationTest() {
final LocationResponse response = post(
builder -> builder.path(LOCATION_PATH).build(), | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationRequest.java
// public class LocationRequest {
//
// private final String address;
//
// @JsonCreator
// public LocationRequest(@JsonProperty("address") final String address) {
// this.address = address;
// }
//
// public String getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/LocationResponse.java
// public class LocationResponse {
//
// private final GeographicCoordinates geographicCoordinates;
// private final SunriseSunset sunriseSunset;
//
// @JsonCreator
// public LocationResponse(@JsonProperty("geographicCoordinates") final GeographicCoordinates geographicCoordinates,
// @JsonProperty("sunriseSunset") final SunriseSunset sunriseSunset) {
// this.geographicCoordinates = geographicCoordinates;
// this.sunriseSunset = sunriseSunset;
// }
//
// public GeographicCoordinates getGeographicCoordinates() {
// return geographicCoordinates;
// }
//
// public SunriseSunset getSunriseSunset() {
// return sunriseSunset;
// }
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/application/ReactiveMsApplicationTest.java
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.LocationRequest;
import org.learning.by.example.reactive.microservices.model.LocationResponse;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.SystemTest;
import org.springframework.boot.web.server.LocalServerPort;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
@LocalServerPort
private int port;
@BeforeEach
void setup() {
bindToServerPort(port);
}
@Test
@DisplayName("get location from URL")
void getLocationTest() {
final LocationResponse response = get(
builder -> builder.path(LOCATION_PATH).path("/").path(ADDRESS_ARG).build(GOOGLE_ADDRESS),
LocationResponse.class);
assertThat(response.getGeographicCoordinates(), not(nullValue()));
assertThat(response.getGeographicCoordinates().getLatitude(), not(nullValue()));
assertThat(response.getGeographicCoordinates().getLongitude(), not(nullValue()));
assertThat(response.getSunriseSunset(), not(nullValue()));
assertThat(response.getSunriseSunset().getSunrise(), not(isEmptyOrNullString()));
assertThat(response.getSunriseSunset().getSunset(), not(isEmptyOrNullString()));
}
@Test
@DisplayName("post location")
void postLocationTest() {
final LocationResponse response = post(
builder -> builder.path(LOCATION_PATH).build(), | new LocationRequest(GOOGLE_ADDRESS), |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/handlers/ThrowableTranslator.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/InvalidParametersException.java
// public class InvalidParametersException extends Exception {
//
// public InvalidParametersException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
| import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.InvalidParametersException;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.springframework.http.HttpStatus;
import reactor.core.publisher.Mono; | package org.learning.by.example.reactive.microservices.handlers;
class ThrowableTranslator {
private final HttpStatus httpStatus;
private final String message;
private ThrowableTranslator(final Throwable throwable) {
this.httpStatus = getStatus(throwable);
this.message = throwable.getMessage();
}
private HttpStatus getStatus(final Throwable error) { | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/InvalidParametersException.java
// public class InvalidParametersException extends Exception {
//
// public InvalidParametersException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ThrowableTranslator.java
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.InvalidParametersException;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.springframework.http.HttpStatus;
import reactor.core.publisher.Mono;
package org.learning.by.example.reactive.microservices.handlers;
class ThrowableTranslator {
private final HttpStatus httpStatus;
private final String message;
private ThrowableTranslator(final Throwable throwable) {
this.httpStatus = getStatus(throwable);
this.message = throwable.getMessage();
}
private HttpStatus getStatus(final Throwable error) { | if (error instanceof InvalidParametersException) { |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/handlers/ThrowableTranslator.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/InvalidParametersException.java
// public class InvalidParametersException extends Exception {
//
// public InvalidParametersException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
| import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.InvalidParametersException;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.springframework.http.HttpStatus;
import reactor.core.publisher.Mono; | package org.learning.by.example.reactive.microservices.handlers;
class ThrowableTranslator {
private final HttpStatus httpStatus;
private final String message;
private ThrowableTranslator(final Throwable throwable) {
this.httpStatus = getStatus(throwable);
this.message = throwable.getMessage();
}
private HttpStatus getStatus(final Throwable error) {
if (error instanceof InvalidParametersException) {
return HttpStatus.BAD_REQUEST; | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/InvalidParametersException.java
// public class InvalidParametersException extends Exception {
//
// public InvalidParametersException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ThrowableTranslator.java
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.InvalidParametersException;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.springframework.http.HttpStatus;
import reactor.core.publisher.Mono;
package org.learning.by.example.reactive.microservices.handlers;
class ThrowableTranslator {
private final HttpStatus httpStatus;
private final String message;
private ThrowableTranslator(final Throwable throwable) {
this.httpStatus = getStatus(throwable);
this.message = throwable.getMessage();
}
private HttpStatus getStatus(final Throwable error) {
if (error instanceof InvalidParametersException) {
return HttpStatus.BAD_REQUEST; | } else if (error instanceof PathNotFoundException) { |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/handlers/ThrowableTranslator.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/InvalidParametersException.java
// public class InvalidParametersException extends Exception {
//
// public InvalidParametersException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
| import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.InvalidParametersException;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.springframework.http.HttpStatus;
import reactor.core.publisher.Mono; | package org.learning.by.example.reactive.microservices.handlers;
class ThrowableTranslator {
private final HttpStatus httpStatus;
private final String message;
private ThrowableTranslator(final Throwable throwable) {
this.httpStatus = getStatus(throwable);
this.message = throwable.getMessage();
}
private HttpStatus getStatus(final Throwable error) {
if (error instanceof InvalidParametersException) {
return HttpStatus.BAD_REQUEST;
} else if (error instanceof PathNotFoundException) {
return HttpStatus.NOT_FOUND; | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/InvalidParametersException.java
// public class InvalidParametersException extends Exception {
//
// public InvalidParametersException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ThrowableTranslator.java
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.InvalidParametersException;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.springframework.http.HttpStatus;
import reactor.core.publisher.Mono;
package org.learning.by.example.reactive.microservices.handlers;
class ThrowableTranslator {
private final HttpStatus httpStatus;
private final String message;
private ThrowableTranslator(final Throwable throwable) {
this.httpStatus = getStatus(throwable);
this.message = throwable.getMessage();
}
private HttpStatus getStatus(final Throwable error) {
if (error instanceof InvalidParametersException) {
return HttpStatus.BAD_REQUEST;
} else if (error instanceof PathNotFoundException) {
return HttpStatus.NOT_FOUND; | } else if (error instanceof GeoLocationNotFoundException) { |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/handlers/ThrowableTranslator.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/InvalidParametersException.java
// public class InvalidParametersException extends Exception {
//
// public InvalidParametersException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
| import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.InvalidParametersException;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.springframework.http.HttpStatus;
import reactor.core.publisher.Mono; | package org.learning.by.example.reactive.microservices.handlers;
class ThrowableTranslator {
private final HttpStatus httpStatus;
private final String message;
private ThrowableTranslator(final Throwable throwable) {
this.httpStatus = getStatus(throwable);
this.message = throwable.getMessage();
}
private HttpStatus getStatus(final Throwable error) {
if (error instanceof InvalidParametersException) {
return HttpStatus.BAD_REQUEST;
} else if (error instanceof PathNotFoundException) {
return HttpStatus.NOT_FOUND;
} else if (error instanceof GeoLocationNotFoundException) {
return HttpStatus.NOT_FOUND; | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GetGeoLocationException.java
// public class GetGeoLocationException extends Exception {
// public GetGeoLocationException(final String message, final Throwable throwable) {
// super(message, throwable);
// }
//
// public GetGeoLocationException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/InvalidParametersException.java
// public class InvalidParametersException extends Exception {
//
// public InvalidParametersException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/GeoLocationNotFoundException.java
// public class GeoLocationNotFoundException extends Exception{
//
// public GeoLocationNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ThrowableTranslator.java
import org.learning.by.example.reactive.microservices.exceptions.GetGeoLocationException;
import org.learning.by.example.reactive.microservices.exceptions.InvalidParametersException;
import org.learning.by.example.reactive.microservices.exceptions.GeoLocationNotFoundException;
import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.springframework.http.HttpStatus;
import reactor.core.publisher.Mono;
package org.learning.by.example.reactive.microservices.handlers;
class ThrowableTranslator {
private final HttpStatus httpStatus;
private final String message;
private ThrowableTranslator(final Throwable throwable) {
this.httpStatus = getStatus(throwable);
this.message = throwable.getMessage();
}
private HttpStatus getStatus(final Throwable error) {
if (error instanceof InvalidParametersException) {
return HttpStatus.BAD_REQUEST;
} else if (error instanceof PathNotFoundException) {
return HttpStatus.NOT_FOUND;
} else if (error instanceof GeoLocationNotFoundException) {
return HttpStatus.NOT_FOUND; | } else if (error instanceof GetGeoLocationException) { |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/test/tags/IntegrationTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/application/ReactiveMsApplication.java
// @SpringBootApplication
// public class ReactiveMsApplication {
// public static void main(String[] args) {
// SpringApplication.run(ReactiveMsApplication.class, args);
// }
// }
| import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.extension.ExtendWith;
import org.learning.by.example.reactive.microservices.application.ReactiveMsApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package org.learning.by.example.reactive.microservices.test.tags;
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Tag("IntegrationTest") | // Path: src/main/java/org/learning/by/example/reactive/microservices/application/ReactiveMsApplication.java
// @SpringBootApplication
// public class ReactiveMsApplication {
// public static void main(String[] args) {
// SpringApplication.run(ReactiveMsApplication.class, args);
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/tags/IntegrationTest.java
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.extension.ExtendWith;
import org.learning.by.example.reactive.microservices.application.ReactiveMsApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package org.learning.by.example.reactive.microservices.test.tags;
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Tag("IntegrationTest") | @SpringBootTest(classes = ReactiveMsApplication.class) |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/ErrorResponse.java
// public class ErrorResponse {
//
// private final String error;
//
// @JsonCreator
// public ErrorResponse(@JsonProperty("error") final String error) {
// this.error = error;
// }
//
// public String getError() {
// return error;
// }
// }
| import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.learning.by.example.reactive.microservices.model.ErrorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono; | package org.learning.by.example.reactive.microservices.handlers;
public class ErrorHandler {
private static final String NOT_FOUND = "not found";
private static final String ERROR_RAISED = "error raised";
private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
public Mono<ServerResponse> notFound(final ServerRequest request) { | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/ErrorResponse.java
// public class ErrorResponse {
//
// private final String error;
//
// @JsonCreator
// public ErrorResponse(@JsonProperty("error") final String error) {
// this.error = error;
// }
//
// public String getError() {
// return error;
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java
import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.learning.by.example.reactive.microservices.model.ErrorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
package org.learning.by.example.reactive.microservices.handlers;
public class ErrorHandler {
private static final String NOT_FOUND = "not found";
private static final String ERROR_RAISED = "error raised";
private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
public Mono<ServerResponse> notFound(final ServerRequest request) { | return Mono.just(new PathNotFoundException(NOT_FOUND)).transform(this::getResponse); |
LearningByExample/reactive-ms-example | src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/ErrorResponse.java
// public class ErrorResponse {
//
// private final String error;
//
// @JsonCreator
// public ErrorResponse(@JsonProperty("error") final String error) {
// this.error = error;
// }
//
// public String getError() {
// return error;
// }
// }
| import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.learning.by.example.reactive.microservices.model.ErrorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono; | package org.learning.by.example.reactive.microservices.handlers;
public class ErrorHandler {
private static final String NOT_FOUND = "not found";
private static final String ERROR_RAISED = "error raised";
private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
public Mono<ServerResponse> notFound(final ServerRequest request) {
return Mono.just(new PathNotFoundException(NOT_FOUND)).transform(this::getResponse);
}
Mono<ServerResponse> throwableError(final Throwable error) {
logger.error(ERROR_RAISED, error);
return Mono.just(error).transform(this::getResponse);
}
<T extends Throwable> Mono<ServerResponse> getResponse(final Mono<T> monoError) {
return monoError.transform(ThrowableTranslator::translate)
.flatMap(translation -> ServerResponse
.status(translation.getHttpStatus()) | // Path: src/main/java/org/learning/by/example/reactive/microservices/exceptions/PathNotFoundException.java
// public class PathNotFoundException extends Exception {
//
// public PathNotFoundException(final String message) {
// super(message);
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/ErrorResponse.java
// public class ErrorResponse {
//
// private final String error;
//
// @JsonCreator
// public ErrorResponse(@JsonProperty("error") final String error) {
// this.error = error;
// }
//
// public String getError() {
// return error;
// }
// }
// Path: src/main/java/org/learning/by/example/reactive/microservices/handlers/ErrorHandler.java
import org.learning.by.example.reactive.microservices.exceptions.PathNotFoundException;
import org.learning.by.example.reactive.microservices.model.ErrorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
package org.learning.by.example.reactive.microservices.handlers;
public class ErrorHandler {
private static final String NOT_FOUND = "not found";
private static final String ERROR_RAISED = "error raised";
private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
public Mono<ServerResponse> notFound(final ServerRequest request) {
return Mono.just(new PathNotFoundException(NOT_FOUND)).transform(this::getResponse);
}
Mono<ServerResponse> throwableError(final Throwable error) {
logger.error(ERROR_RAISED, error);
return Mono.just(error).transform(this::getResponse);
}
<T extends Throwable> Mono<ServerResponse> getResponse(final Mono<T> monoError) {
return monoError.transform(ThrowableTranslator::translate)
.flatMap(translation -> ServerResponse
.status(translation.getHttpStatus()) | .body(Mono.just(new ErrorResponse(translation.getMessage())), ErrorResponse.class)); |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/routers/MainRouterTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
| import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.IntegrationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.web.reactive.function.server.RouterFunction;
import reactor.core.publisher.Mono;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset; | package org.learning.by.example.reactive.microservices.routers;
@IntegrationTest
@DisplayName("MainRouter Integration Tests") | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/routers/MainRouterTest.java
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.IntegrationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.web.reactive.function.server.RouterFunction;
import reactor.core.publisher.Mono;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset;
package org.learning.by.example.reactive.microservices.routers;
@IntegrationTest
@DisplayName("MainRouter Integration Tests") | class MainRouterTest extends BasicIntegrationTest { |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/routers/MainRouterTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
| import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.IntegrationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.web.reactive.function.server.RouterFunction;
import reactor.core.publisher.Mono;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset; | package org.learning.by.example.reactive.microservices.routers;
@IntegrationTest
@DisplayName("MainRouter Integration Tests")
class MainRouterTest extends BasicIntegrationTest {
private static final String STATIC_ROUTE = "/index.html";
private static final String LOCATION_PATH = "/api/location";
private static final String ADDRESS_ARG = "{address}";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
| // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/routers/MainRouterTest.java
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.IntegrationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.web.reactive.function.server.RouterFunction;
import reactor.core.publisher.Mono;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset;
package org.learning.by.example.reactive.microservices.routers;
@IntegrationTest
@DisplayName("MainRouter Integration Tests")
class MainRouterTest extends BasicIntegrationTest {
private static final String STATIC_ROUTE = "/index.html";
private static final String LOCATION_PATH = "/api/location";
private static final String ADDRESS_ARG = "{address}";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
| private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG)); |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/routers/MainRouterTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
| import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.IntegrationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.web.reactive.function.server.RouterFunction;
import reactor.core.publisher.Mono;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset; | package org.learning.by.example.reactive.microservices.routers;
@IntegrationTest
@DisplayName("MainRouter Integration Tests")
class MainRouterTest extends BasicIntegrationTest {
private static final String STATIC_ROUTE = "/index.html";
private static final String LOCATION_PATH = "/api/location";
private static final String ADDRESS_ARG = "{address}";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG)); | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/routers/MainRouterTest.java
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.IntegrationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.web.reactive.function.server.RouterFunction;
import reactor.core.publisher.Mono;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset;
package org.learning.by.example.reactive.microservices.routers;
@IntegrationTest
@DisplayName("MainRouter Integration Tests")
class MainRouterTest extends BasicIntegrationTest {
private static final String STATIC_ROUTE = "/index.html";
private static final String LOCATION_PATH = "/api/location";
private static final String ADDRESS_ARG = "{address}";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG)); | private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME)); |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/routers/MainRouterTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
| import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.IntegrationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.web.reactive.function.server.RouterFunction;
import reactor.core.publisher.Mono;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset; | package org.learning.by.example.reactive.microservices.routers;
@IntegrationTest
@DisplayName("MainRouter Integration Tests")
class MainRouterTest extends BasicIntegrationTest {
private static final String STATIC_ROUTE = "/index.html";
private static final String LOCATION_PATH = "/api/location";
private static final String ADDRESS_ARG = "{address}";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME));
@SpyBean | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/routers/MainRouterTest.java
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.IntegrationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.web.reactive.function.server.RouterFunction;
import reactor.core.publisher.Mono;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset;
package org.learning.by.example.reactive.microservices.routers;
@IntegrationTest
@DisplayName("MainRouter Integration Tests")
class MainRouterTest extends BasicIntegrationTest {
private static final String STATIC_ROUTE = "/index.html";
private static final String LOCATION_PATH = "/api/location";
private static final String ADDRESS_ARG = "{address}";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME));
@SpyBean | private GeoLocationService geoLocationService; |
LearningByExample/reactive-ms-example | src/test/java/org/learning/by/example/reactive/microservices/routers/MainRouterTest.java | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
| import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.IntegrationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.web.reactive.function.server.RouterFunction;
import reactor.core.publisher.Mono;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset; | package org.learning.by.example.reactive.microservices.routers;
@IntegrationTest
@DisplayName("MainRouter Integration Tests")
class MainRouterTest extends BasicIntegrationTest {
private static final String STATIC_ROUTE = "/index.html";
private static final String LOCATION_PATH = "/api/location";
private static final String ADDRESS_ARG = "{address}";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME));
@SpyBean
private GeoLocationService geoLocationService;
@SpyBean | // Path: src/main/java/org/learning/by/example/reactive/microservices/model/GeographicCoordinates.java
// public final class GeographicCoordinates {
//
// public double getLatitude() {
// return latitude;
// }
//
// public double getLongitude() {
// return longitude;
// }
//
// private final double latitude;
// private final double longitude;
//
// @JsonCreator
// public GeographicCoordinates(@JsonProperty("latitude") double latitude, @JsonProperty("longitude") double longitude) {
// this.latitude = latitude;
// this.longitude = longitude;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/model/SunriseSunset.java
// public class SunriseSunset {
//
// public String getSunrise() {
// return sunrise;
// }
//
// public String getSunset() {
// return sunset;
// }
//
// private final String sunrise;
// private final String sunset;
//
// @JsonCreator
// public SunriseSunset(@JsonProperty("sunrise") final String sunrise, @JsonProperty("sunset") final String sunset) {
// this.sunrise = sunrise;
// this.sunset = sunset;
// }
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/GeoLocationService.java
// public interface GeoLocationService {
//
// Mono<GeographicCoordinates> fromAddress(Mono<String> addressMono);
// }
//
// Path: src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetService.java
// public interface SunriseSunsetService {
//
// Mono<SunriseSunset> fromGeographicCoordinates(Mono<GeographicCoordinates> geographicCoordinatesMono);
// }
//
// Path: src/test/java/org/learning/by/example/reactive/microservices/test/BasicIntegrationTest.java
// public abstract class BasicIntegrationTest {
// private WebTestClient client;
//
// protected void bindToRouterFunction(final RouterFunction<?> routerFunction) {
// client = WebTestClient.bindToRouterFunction(routerFunction).build();
// }
//
// protected void bindToServerPort(final int port) {
// client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
// }
//
// protected String get(final Function<UriBuilder, URI> builder) {
// return get(builder, HttpStatus.OK);
// }
//
// private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) {
// return new String(client.get()
// .uri(builder)
// .accept(TEXT_HTML).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(TEXT_HTML)
// .expectBody().returnResult().getResponseBody());
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) {
// return client.get()
// .uri(builder)
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) {
// return get(builder, HttpStatus.OK, type);
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) {
// return client.post()
// .uri(builder)
// .body(BodyInserters.fromObject(object))
// .accept(APPLICATION_JSON_UTF8).exchange()
// .expectStatus().isEqualTo(status)
// .expectHeader().contentType(APPLICATION_JSON_UTF8)
// .expectBody(type)
// .returnResult().getResponseBody();
// }
//
// protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) {
// return post(builder, HttpStatus.OK, object, type);
// }
// }
// Path: src/test/java/org/learning/by/example/reactive/microservices/routers/MainRouterTest.java
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.learning.by.example.reactive.microservices.model.GeographicCoordinates;
import org.learning.by.example.reactive.microservices.model.SunriseSunset;
import org.learning.by.example.reactive.microservices.services.GeoLocationService;
import org.learning.by.example.reactive.microservices.services.SunriseSunsetService;
import org.learning.by.example.reactive.microservices.test.BasicIntegrationTest;
import org.learning.by.example.reactive.microservices.test.tags.IntegrationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.web.reactive.function.server.RouterFunction;
import reactor.core.publisher.Mono;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset;
package org.learning.by.example.reactive.microservices.routers;
@IntegrationTest
@DisplayName("MainRouter Integration Tests")
class MainRouterTest extends BasicIntegrationTest {
private static final String STATIC_ROUTE = "/index.html";
private static final String LOCATION_PATH = "/api/location";
private static final String ADDRESS_ARG = "{address}";
private static final double GOOGLE_LAT = 37.4224082;
private static final double GOOGLE_LNG = -122.0856086;
private static final String GOOGLE_ADDRESS = "1600 Amphitheatre Parkway, Mountain View, CA";
private static final String SUNRISE_TIME = "12:55:17 PM";
private static final String SUNSET_TIME = "3:14:28 AM";
private static final Mono<GeographicCoordinates> GOOGLE_LOCATION = Mono.just(new GeographicCoordinates(GOOGLE_LAT, GOOGLE_LNG));
private static final Mono<SunriseSunset> SUNRISE_SUNSET = Mono.just(new SunriseSunset(SUNRISE_TIME, SUNSET_TIME));
@SpyBean
private GeoLocationService geoLocationService;
@SpyBean | private SunriseSunsetService sunriseSunsetService; |
badvision/jace | src/main/java/jace/core/SoundMixer.java | // Path: src/main/java/jace/config/DynamicSelection.java
// public abstract class DynamicSelection<T> implements ISelection<T> {
// public DynamicSelection(T defaultValue) {
// setValue(defaultValue);
// }
// abstract public boolean allowNull();
// T currentValue;
// @Override
// public T getValue() {
// if (currentValue != null || allowNull()) {
// return currentValue;
// } else {
// Iterator<? extends T> i = getSelections().keySet().iterator();
// if (i.hasNext()) {
// return i.next();
// } else {
// return null;
// }
// }
// }
//
// @Override
// public void setValue(T value) {currentValue = value;}
//
// @Override
// public void setValueByMatch(String search) {
// setValue(findValueByMatch(search));
// }
//
// public T findValueByMatch(String search) {
// Map<? extends T, String> selections = getSelections();
// String match = Utility.findBestMatch(search, selections.values());
// if (match != null) {
// for (T key : selections.keySet()) {
// if (selections.get(key).equals(match)) {
// return key;
// }
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/jace/config/Reconfigurable.java
// public interface Reconfigurable {
// public String getName();
// public String getShortName();
// public void reconfigure();
// }
| import jace.config.ConfigurableField;
import jace.config.DynamicSelection;
import jace.config.Reconfigurable;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Mixer.Info;
import javax.sound.sampled.SourceDataLine; | /*
* Copyright (C) 2012 Brendan Robert (BLuRry) brendan.robert@gmail.com.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package jace.core;
/**
* Manages sound resources used by various audio devices (such as speaker and
* mockingboard cards.) The plumbing is managed in this class so that the
* consumers do not have to do a lot of work to manage mixer lines or deal with
* how to reuse active lines if needed. It is possible that this class might be
* used to manage volume in the future, but that remains to be seen.
*
* @author Brendan Robert (BLuRry) brendan.robert@gmail.com
*/
public class SoundMixer extends Device {
private final Set<SourceDataLine> availableLines = Collections.synchronizedSet(new HashSet<>());
private final Map<Object, SourceDataLine> activeLines = Collections.synchronizedMap(new HashMap<>());
/**
* Bits per sample
*/
@ConfigurableField(name = "Bits per sample", shortName = "bits")
public static int BITS = 16;
/**
* Sample playback rate
*/
@ConfigurableField(name = "Playback Rate", shortName = "freq")
public static int RATE = 48000;
@ConfigurableField(name = "Mute", shortName = "mute")
public static boolean MUTE = false;
/**
* Sound format used for playback
*/
private AudioFormat af;
/**
* Is sound line available for playback at all?
*/
public boolean lineAvailable;
@ConfigurableField(name = "Audio device", description = "Audio output device") | // Path: src/main/java/jace/config/DynamicSelection.java
// public abstract class DynamicSelection<T> implements ISelection<T> {
// public DynamicSelection(T defaultValue) {
// setValue(defaultValue);
// }
// abstract public boolean allowNull();
// T currentValue;
// @Override
// public T getValue() {
// if (currentValue != null || allowNull()) {
// return currentValue;
// } else {
// Iterator<? extends T> i = getSelections().keySet().iterator();
// if (i.hasNext()) {
// return i.next();
// } else {
// return null;
// }
// }
// }
//
// @Override
// public void setValue(T value) {currentValue = value;}
//
// @Override
// public void setValueByMatch(String search) {
// setValue(findValueByMatch(search));
// }
//
// public T findValueByMatch(String search) {
// Map<? extends T, String> selections = getSelections();
// String match = Utility.findBestMatch(search, selections.values());
// if (match != null) {
// for (T key : selections.keySet()) {
// if (selections.get(key).equals(match)) {
// return key;
// }
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/jace/config/Reconfigurable.java
// public interface Reconfigurable {
// public String getName();
// public String getShortName();
// public void reconfigure();
// }
// Path: src/main/java/jace/core/SoundMixer.java
import jace.config.ConfigurableField;
import jace.config.DynamicSelection;
import jace.config.Reconfigurable;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Mixer.Info;
import javax.sound.sampled.SourceDataLine;
/*
* Copyright (C) 2012 Brendan Robert (BLuRry) brendan.robert@gmail.com.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package jace.core;
/**
* Manages sound resources used by various audio devices (such as speaker and
* mockingboard cards.) The plumbing is managed in this class so that the
* consumers do not have to do a lot of work to manage mixer lines or deal with
* how to reuse active lines if needed. It is possible that this class might be
* used to manage volume in the future, but that remains to be seen.
*
* @author Brendan Robert (BLuRry) brendan.robert@gmail.com
*/
public class SoundMixer extends Device {
private final Set<SourceDataLine> availableLines = Collections.synchronizedSet(new HashSet<>());
private final Map<Object, SourceDataLine> activeLines = Collections.synchronizedMap(new HashMap<>());
/**
* Bits per sample
*/
@ConfigurableField(name = "Bits per sample", shortName = "bits")
public static int BITS = 16;
/**
* Sample playback rate
*/
@ConfigurableField(name = "Playback Rate", shortName = "freq")
public static int RATE = 48000;
@ConfigurableField(name = "Mute", shortName = "mute")
public static boolean MUTE = false;
/**
* Sound format used for playback
*/
private AudioFormat af;
/**
* Is sound line available for playback at all?
*/
public boolean lineAvailable;
@ConfigurableField(name = "Audio device", description = "Audio output device") | public static DynamicSelection<String> preferredMixer = new DynamicSelection<String>(null) { |
badvision/jace | src/main/java/jace/core/SoundMixer.java | // Path: src/main/java/jace/config/DynamicSelection.java
// public abstract class DynamicSelection<T> implements ISelection<T> {
// public DynamicSelection(T defaultValue) {
// setValue(defaultValue);
// }
// abstract public boolean allowNull();
// T currentValue;
// @Override
// public T getValue() {
// if (currentValue != null || allowNull()) {
// return currentValue;
// } else {
// Iterator<? extends T> i = getSelections().keySet().iterator();
// if (i.hasNext()) {
// return i.next();
// } else {
// return null;
// }
// }
// }
//
// @Override
// public void setValue(T value) {currentValue = value;}
//
// @Override
// public void setValueByMatch(String search) {
// setValue(findValueByMatch(search));
// }
//
// public T findValueByMatch(String search) {
// Map<? extends T, String> selections = getSelections();
// String match = Utility.findBestMatch(search, selections.values());
// if (match != null) {
// for (T key : selections.keySet()) {
// if (selections.get(key).equals(match)) {
// return key;
// }
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/jace/config/Reconfigurable.java
// public interface Reconfigurable {
// public String getName();
// public String getShortName();
// public void reconfigure();
// }
| import jace.config.ConfigurableField;
import jace.config.DynamicSelection;
import jace.config.Reconfigurable;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Mixer.Info;
import javax.sound.sampled.SourceDataLine; | sdl.open();
return sdl;
}
public byte randomByte() {
return (byte) (Math.random() * 256);
}
@Override
public void tick() {
}
@Override
public void attach() {
// if (Motherboard.enableSpeaker)
// Motherboard.speaker.attach();
}
@Override
public void detach() {
availableLines.stream().forEach((line) -> {
line.close();
});
Set requesters = new HashSet(activeLines.keySet());
requesters.stream().map((o) -> {
if (o instanceof Device) {
((Device) o).detach();
}
return o;
}).filter((o) -> (o instanceof Card)).forEach((o) -> { | // Path: src/main/java/jace/config/DynamicSelection.java
// public abstract class DynamicSelection<T> implements ISelection<T> {
// public DynamicSelection(T defaultValue) {
// setValue(defaultValue);
// }
// abstract public boolean allowNull();
// T currentValue;
// @Override
// public T getValue() {
// if (currentValue != null || allowNull()) {
// return currentValue;
// } else {
// Iterator<? extends T> i = getSelections().keySet().iterator();
// if (i.hasNext()) {
// return i.next();
// } else {
// return null;
// }
// }
// }
//
// @Override
// public void setValue(T value) {currentValue = value;}
//
// @Override
// public void setValueByMatch(String search) {
// setValue(findValueByMatch(search));
// }
//
// public T findValueByMatch(String search) {
// Map<? extends T, String> selections = getSelections();
// String match = Utility.findBestMatch(search, selections.values());
// if (match != null) {
// for (T key : selections.keySet()) {
// if (selections.get(key).equals(match)) {
// return key;
// }
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/jace/config/Reconfigurable.java
// public interface Reconfigurable {
// public String getName();
// public String getShortName();
// public void reconfigure();
// }
// Path: src/main/java/jace/core/SoundMixer.java
import jace.config.ConfigurableField;
import jace.config.DynamicSelection;
import jace.config.Reconfigurable;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Mixer.Info;
import javax.sound.sampled.SourceDataLine;
sdl.open();
return sdl;
}
public byte randomByte() {
return (byte) (Math.random() * 256);
}
@Override
public void tick() {
}
@Override
public void attach() {
// if (Motherboard.enableSpeaker)
// Motherboard.speaker.attach();
}
@Override
public void detach() {
availableLines.stream().forEach((line) -> {
line.close();
});
Set requesters = new HashSet(activeLines.keySet());
requesters.stream().map((o) -> {
if (o instanceof Device) {
((Device) o).detach();
}
return o;
}).filter((o) -> (o instanceof Card)).forEach((o) -> { | ((Reconfigurable) o).reconfigure(); |
badvision/jace | src/main/java/jace/config/ConfigurationUIController.java | // Path: src/main/java/jace/config/Configuration.java
// public static class ConfigNode extends TreeItem implements Serializable {
//
// public transient ConfigNode root;
// public transient ConfigNode parent;
// private transient ObservableList<ConfigNode> children;
// public transient Reconfigurable subject;
// private transient boolean changed = true;
//
// public Map<String, Serializable> settings = new TreeMap<>();
// public Map<String, String[]> hotkeys = new TreeMap<>();
// public String name;
// private String id;
//
// private void writeObject(java.io.ObjectOutputStream out)
// throws IOException {
// out.writeObject(id);
// out.writeObject(name);
// out.writeObject(settings);
// out.writeObject(hotkeys);
// out.writeObject(children.toArray());
// }
//
// private void readObject(java.io.ObjectInputStream in)
// throws IOException, ClassNotFoundException {
// children = super.getChildren();
// id = (String) in.readObject();
// name = (String) in.readObject();
// settings = (Map) in.readObject();
// hotkeys = (Map) in.readObject();
// Object[] nodeArray = (Object[]) in.readObject();
// for (Object child : nodeArray) {
// children.add((ConfigNode) child);
// }
// }
//
// private void readObjectNoData()
// throws ObjectStreamException {
// name = "Bad read";
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// public ConfigNode(Reconfigurable subject) {
// this(null, subject);
// this.root = null;
// this.setExpanded(true);
// }
//
// public ConfigNode(ConfigNode parent, Reconfigurable subject) {
// this(parent, subject, subject.getName());
// }
//
// public ConfigNode(ConfigNode parent, Reconfigurable subject, String id) {
// super();
// this.id = id;
// this.name = subject.getName();
// this.subject = subject;
// this.children = getChildren();
// this.parent = parent;
// if (this.parent != null) {
// this.root = this.parent.root != null ? this.parent.root : this.parent;
// }
// setValue(toString());
// }
//
// public void setFieldValue(String field, Serializable value) {
// if (value != null) {
// if (value.equals(getFieldValue(field))) {
// return;
// }
// } else {
// if (getFieldValue(field) == null) {
// setChanged(false);
// return;
// }
// }
// setChanged(true);
// setRawFieldValue(field, value);
// }
//
// public void setRawFieldValue(String field, Serializable value) {
// settings.put(field, value);
// }
//
// public Serializable getFieldValue(String field) {
// return settings.get(field);
// }
//
// public Set<String> getAllSettingNames() {
// return settings.keySet();
// }
//
// @Override
// public ObservableList<ConfigNode> getChildren() {
// return super.getChildren();
// }
//
// private boolean removeChild(String childName) {
// ConfigNode child = findChild(childName);
// return children.remove(child);
// }
//
// private ConfigNode findChild(String id) {
// for (ConfigNode node : children) {
// if (id.equalsIgnoreCase(node.id)) {
// return node;
// }
// }
// return null;
// }
//
// private void putChild(String id, ConfigNode newChild) {
// removeChild(id);
// int index = 0;
// for (ConfigNode node : children) {
// int compare = node.toString().compareToIgnoreCase(id);
// if (compare >= 0) {
// break;
// } else {
// index++;
// }
// }
// children.add(index, newChild);
// }
//
// private void setChanged(boolean b) {
// changed = b;
// if (!changed) {
// setGraphic(null);
// } else {
// getChangedIcon().ifPresent(this::setGraphic);
// }
// }
//
// public Stream<ConfigNode> getTreeAsStream() {
// return Stream.concat(
// Stream.of(this),
// children.stream().flatMap(ConfigNode::getTreeAsStream));
// }
// }
| import jace.config.Configuration.ConfigNode;
import java.io.File;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javafx.beans.Observable;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.SplitPane;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.util.StringConverter; | package jace.config;
public class ConfigurationUIController {
public static final String DELIMITER = "~!~";
@FXML
private ResourceBundle resources;
@FXML
private URL location;
@FXML
private VBox settingsVbox;
@FXML
private SplitPane splitPane;
@FXML
private ScrollPane settingsScroll;
@FXML | // Path: src/main/java/jace/config/Configuration.java
// public static class ConfigNode extends TreeItem implements Serializable {
//
// public transient ConfigNode root;
// public transient ConfigNode parent;
// private transient ObservableList<ConfigNode> children;
// public transient Reconfigurable subject;
// private transient boolean changed = true;
//
// public Map<String, Serializable> settings = new TreeMap<>();
// public Map<String, String[]> hotkeys = new TreeMap<>();
// public String name;
// private String id;
//
// private void writeObject(java.io.ObjectOutputStream out)
// throws IOException {
// out.writeObject(id);
// out.writeObject(name);
// out.writeObject(settings);
// out.writeObject(hotkeys);
// out.writeObject(children.toArray());
// }
//
// private void readObject(java.io.ObjectInputStream in)
// throws IOException, ClassNotFoundException {
// children = super.getChildren();
// id = (String) in.readObject();
// name = (String) in.readObject();
// settings = (Map) in.readObject();
// hotkeys = (Map) in.readObject();
// Object[] nodeArray = (Object[]) in.readObject();
// for (Object child : nodeArray) {
// children.add((ConfigNode) child);
// }
// }
//
// private void readObjectNoData()
// throws ObjectStreamException {
// name = "Bad read";
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// public ConfigNode(Reconfigurable subject) {
// this(null, subject);
// this.root = null;
// this.setExpanded(true);
// }
//
// public ConfigNode(ConfigNode parent, Reconfigurable subject) {
// this(parent, subject, subject.getName());
// }
//
// public ConfigNode(ConfigNode parent, Reconfigurable subject, String id) {
// super();
// this.id = id;
// this.name = subject.getName();
// this.subject = subject;
// this.children = getChildren();
// this.parent = parent;
// if (this.parent != null) {
// this.root = this.parent.root != null ? this.parent.root : this.parent;
// }
// setValue(toString());
// }
//
// public void setFieldValue(String field, Serializable value) {
// if (value != null) {
// if (value.equals(getFieldValue(field))) {
// return;
// }
// } else {
// if (getFieldValue(field) == null) {
// setChanged(false);
// return;
// }
// }
// setChanged(true);
// setRawFieldValue(field, value);
// }
//
// public void setRawFieldValue(String field, Serializable value) {
// settings.put(field, value);
// }
//
// public Serializable getFieldValue(String field) {
// return settings.get(field);
// }
//
// public Set<String> getAllSettingNames() {
// return settings.keySet();
// }
//
// @Override
// public ObservableList<ConfigNode> getChildren() {
// return super.getChildren();
// }
//
// private boolean removeChild(String childName) {
// ConfigNode child = findChild(childName);
// return children.remove(child);
// }
//
// private ConfigNode findChild(String id) {
// for (ConfigNode node : children) {
// if (id.equalsIgnoreCase(node.id)) {
// return node;
// }
// }
// return null;
// }
//
// private void putChild(String id, ConfigNode newChild) {
// removeChild(id);
// int index = 0;
// for (ConfigNode node : children) {
// int compare = node.toString().compareToIgnoreCase(id);
// if (compare >= 0) {
// break;
// } else {
// index++;
// }
// }
// children.add(index, newChild);
// }
//
// private void setChanged(boolean b) {
// changed = b;
// if (!changed) {
// setGraphic(null);
// } else {
// getChangedIcon().ifPresent(this::setGraphic);
// }
// }
//
// public Stream<ConfigNode> getTreeAsStream() {
// return Stream.concat(
// Stream.of(this),
// children.stream().flatMap(ConfigNode::getTreeAsStream));
// }
// }
// Path: src/main/java/jace/config/ConfigurationUIController.java
import jace.config.Configuration.ConfigNode;
import java.io.File;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javafx.beans.Observable;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.SplitPane;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.util.StringConverter;
package jace.config;
public class ConfigurationUIController {
public static final String DELIMITER = "~!~";
@FXML
private ResourceBundle resources;
@FXML
private URL location;
@FXML
private VBox settingsVbox;
@FXML
private SplitPane splitPane;
@FXML
private ScrollPane settingsScroll;
@FXML | private TreeView<ConfigNode> deviceTree; |
badvision/jace | src/main/java/jace/hardware/massStorage/MassStorageDrive.java | // Path: src/main/java/jace/library/MediaConsumer.java
// public interface MediaConsumer {
// public Optional<Label> getIcon();
// public void setIcon(Optional<Label> i);
// public void insertMedia(MediaEntry e, MediaFile f) throws IOException;
// public MediaEntry getMediaEntry();
// public MediaFile getMediaFile();
// public boolean isAccepted(MediaEntry e, MediaFile f);
// public void eject();
// }
//
// Path: src/main/java/jace/library/MediaEntry.java
// public class MediaEntry implements Serializable {
//
// @Override
// public String toString() {
// return (name == null || name.length() == 0) ? "No name" : name;
// }
//
// public long id;
// public boolean isLocal;
// public String source;
// public String name;
// public String[] keywords = new String[0];
// public String category;
// public String description;
// public String year;
// public String author;
// public String publisher;
// public String screenshotURL;
// public String boxFrontURL;
// public String boxBackURL;
// public boolean favorite;
// public DiskType type;
// public String auxtype;
// public boolean writeProtected;
// public List<MediaFile> files;
//
// public static class MediaFile implements Serializable {
// public long checksum;
// public File path;
// public boolean activeVersion;
// public String label;
// public long lastRead;
// public long lastWritten;
// volatile public boolean temporary = false;
// }
// }
//
// Path: src/main/java/jace/library/MediaEntry.java
// public static class MediaFile implements Serializable {
// public long checksum;
// public File path;
// public boolean activeVersion;
// public String label;
// public long lastRead;
// public long lastWritten;
// volatile public boolean temporary = false;
// }
| import jace.library.MediaConsumer;
import jace.library.MediaEntry;
import jace.library.MediaEntry.MediaFile;
import java.io.File;
import java.io.IOException;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.scene.control.Label; | /*
* Copyright (C) 2013 brobert.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package jace.hardware.massStorage;
/**
*
* @author brobert
*/
public class MassStorageDrive implements MediaConsumer {
IDisk disk = null;
Optional<Label> icon = null;
@Override
public Optional<Label> getIcon() {
return icon;
}
/**
*
* @param i
*/
@Override
public void setIcon(Optional<Label> i) {
icon = i;
}
| // Path: src/main/java/jace/library/MediaConsumer.java
// public interface MediaConsumer {
// public Optional<Label> getIcon();
// public void setIcon(Optional<Label> i);
// public void insertMedia(MediaEntry e, MediaFile f) throws IOException;
// public MediaEntry getMediaEntry();
// public MediaFile getMediaFile();
// public boolean isAccepted(MediaEntry e, MediaFile f);
// public void eject();
// }
//
// Path: src/main/java/jace/library/MediaEntry.java
// public class MediaEntry implements Serializable {
//
// @Override
// public String toString() {
// return (name == null || name.length() == 0) ? "No name" : name;
// }
//
// public long id;
// public boolean isLocal;
// public String source;
// public String name;
// public String[] keywords = new String[0];
// public String category;
// public String description;
// public String year;
// public String author;
// public String publisher;
// public String screenshotURL;
// public String boxFrontURL;
// public String boxBackURL;
// public boolean favorite;
// public DiskType type;
// public String auxtype;
// public boolean writeProtected;
// public List<MediaFile> files;
//
// public static class MediaFile implements Serializable {
// public long checksum;
// public File path;
// public boolean activeVersion;
// public String label;
// public long lastRead;
// public long lastWritten;
// volatile public boolean temporary = false;
// }
// }
//
// Path: src/main/java/jace/library/MediaEntry.java
// public static class MediaFile implements Serializable {
// public long checksum;
// public File path;
// public boolean activeVersion;
// public String label;
// public long lastRead;
// public long lastWritten;
// volatile public boolean temporary = false;
// }
// Path: src/main/java/jace/hardware/massStorage/MassStorageDrive.java
import jace.library.MediaConsumer;
import jace.library.MediaEntry;
import jace.library.MediaEntry.MediaFile;
import java.io.File;
import java.io.IOException;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.scene.control.Label;
/*
* Copyright (C) 2013 brobert.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package jace.hardware.massStorage;
/**
*
* @author brobert
*/
public class MassStorageDrive implements MediaConsumer {
IDisk disk = null;
Optional<Label> icon = null;
@Override
public Optional<Label> getIcon() {
return icon;
}
/**
*
* @param i
*/
@Override
public void setIcon(Optional<Label> i) {
icon = i;
}
| MediaEntry currentEntry; |
badvision/jace | src/main/java/jace/hardware/massStorage/MassStorageDrive.java | // Path: src/main/java/jace/library/MediaConsumer.java
// public interface MediaConsumer {
// public Optional<Label> getIcon();
// public void setIcon(Optional<Label> i);
// public void insertMedia(MediaEntry e, MediaFile f) throws IOException;
// public MediaEntry getMediaEntry();
// public MediaFile getMediaFile();
// public boolean isAccepted(MediaEntry e, MediaFile f);
// public void eject();
// }
//
// Path: src/main/java/jace/library/MediaEntry.java
// public class MediaEntry implements Serializable {
//
// @Override
// public String toString() {
// return (name == null || name.length() == 0) ? "No name" : name;
// }
//
// public long id;
// public boolean isLocal;
// public String source;
// public String name;
// public String[] keywords = new String[0];
// public String category;
// public String description;
// public String year;
// public String author;
// public String publisher;
// public String screenshotURL;
// public String boxFrontURL;
// public String boxBackURL;
// public boolean favorite;
// public DiskType type;
// public String auxtype;
// public boolean writeProtected;
// public List<MediaFile> files;
//
// public static class MediaFile implements Serializable {
// public long checksum;
// public File path;
// public boolean activeVersion;
// public String label;
// public long lastRead;
// public long lastWritten;
// volatile public boolean temporary = false;
// }
// }
//
// Path: src/main/java/jace/library/MediaEntry.java
// public static class MediaFile implements Serializable {
// public long checksum;
// public File path;
// public boolean activeVersion;
// public String label;
// public long lastRead;
// public long lastWritten;
// volatile public boolean temporary = false;
// }
| import jace.library.MediaConsumer;
import jace.library.MediaEntry;
import jace.library.MediaEntry.MediaFile;
import java.io.File;
import java.io.IOException;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.scene.control.Label; | /*
* Copyright (C) 2013 brobert.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package jace.hardware.massStorage;
/**
*
* @author brobert
*/
public class MassStorageDrive implements MediaConsumer {
IDisk disk = null;
Optional<Label> icon = null;
@Override
public Optional<Label> getIcon() {
return icon;
}
/**
*
* @param i
*/
@Override
public void setIcon(Optional<Label> i) {
icon = i;
}
MediaEntry currentEntry; | // Path: src/main/java/jace/library/MediaConsumer.java
// public interface MediaConsumer {
// public Optional<Label> getIcon();
// public void setIcon(Optional<Label> i);
// public void insertMedia(MediaEntry e, MediaFile f) throws IOException;
// public MediaEntry getMediaEntry();
// public MediaFile getMediaFile();
// public boolean isAccepted(MediaEntry e, MediaFile f);
// public void eject();
// }
//
// Path: src/main/java/jace/library/MediaEntry.java
// public class MediaEntry implements Serializable {
//
// @Override
// public String toString() {
// return (name == null || name.length() == 0) ? "No name" : name;
// }
//
// public long id;
// public boolean isLocal;
// public String source;
// public String name;
// public String[] keywords = new String[0];
// public String category;
// public String description;
// public String year;
// public String author;
// public String publisher;
// public String screenshotURL;
// public String boxFrontURL;
// public String boxBackURL;
// public boolean favorite;
// public DiskType type;
// public String auxtype;
// public boolean writeProtected;
// public List<MediaFile> files;
//
// public static class MediaFile implements Serializable {
// public long checksum;
// public File path;
// public boolean activeVersion;
// public String label;
// public long lastRead;
// public long lastWritten;
// volatile public boolean temporary = false;
// }
// }
//
// Path: src/main/java/jace/library/MediaEntry.java
// public static class MediaFile implements Serializable {
// public long checksum;
// public File path;
// public boolean activeVersion;
// public String label;
// public long lastRead;
// public long lastWritten;
// volatile public boolean temporary = false;
// }
// Path: src/main/java/jace/hardware/massStorage/MassStorageDrive.java
import jace.library.MediaConsumer;
import jace.library.MediaEntry;
import jace.library.MediaEntry.MediaFile;
import java.io.File;
import java.io.IOException;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.scene.control.Label;
/*
* Copyright (C) 2013 brobert.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package jace.hardware.massStorage;
/**
*
* @author brobert
*/
public class MassStorageDrive implements MediaConsumer {
IDisk disk = null;
Optional<Label> icon = null;
@Override
public Optional<Label> getIcon() {
return icon;
}
/**
*
* @param i
*/
@Override
public void setIcon(Optional<Label> i) {
icon = i;
}
MediaEntry currentEntry; | MediaFile currentFile; |
badvision/jace | src/main/java/jace/ide/Program.java | // Path: src/main/java/jace/applesoft/ApplesoftHandler.java
// public class ApplesoftHandler implements LanguageHandler<ApplesoftProgram> {
//
// @Override
// public String getNewDocumentContent() {
// return ApplesoftProgram.fromMemory(Emulator.computer.getMemory()).toString();
// }
//
// @Override
// public CompileResult<ApplesoftProgram> compile(Program program) {
// final ApplesoftProgram result = ApplesoftProgram.fromString(program.getValue());
// final Map<Integer, String> warnings = new LinkedHashMap<>();
// // int lineNumber = 1;
// // for (Line l : result.lines) {
// // warnings.put(lineNumber++, l.toString());
// // }
// return new CompileResult<ApplesoftProgram>() {
// @Override
// public boolean isSuccessful() {
// return result != null;
// }
//
// @Override
// public ApplesoftProgram getCompiledAsset() {
// return result;
// }
//
// @Override
// public Map<Integer, String> getErrors() {
// return Collections.EMPTY_MAP;
// }
//
// @Override
// public Map<Integer, String> getWarnings() {
// return warnings;
// }
//
// @Override
// public List<String> getOtherMessages() {
// return Collections.EMPTY_LIST;
// }
//
// @Override
// public List<String> getRawOutput() {
// return Collections.EMPTY_LIST;
// }
// };
// }
//
// @Override
// public void execute(CompileResult<ApplesoftProgram> lastResult) {
// lastResult.getCompiledAsset().run();
// }
//
// @Override
// public void clean(CompileResult<ApplesoftProgram> lastResult) {
// }
// }
//
// Path: src/main/java/jace/assembly/AssemblyHandler.java
// public class AssemblyHandler implements LanguageHandler<File> {
// @Override
// public String getNewDocumentContent() {
// return "\t\t*= $300;\n\t\t!cpu 65c02;\n;--- Insert your code here ---\n";
// }
//
// @Override
// public CompileResult<File> compile(Program proxy) {
// AcmeCompiler compiler = new AcmeCompiler();
// compiler.compile(proxy);
// return compiler;
// }
//
// @Override
// public void execute(CompileResult<File> lastResult) {
// if (lastResult.isSuccessful()) {
// try {
// boolean resume = false;
// if (Emulator.computer.isRunning()) {
// resume = true;
// Emulator.computer.pause();
// }
// RAM memory = Emulator.computer.getMemory();
// FileInputStream input = new FileInputStream(lastResult.getCompiledAsset());
// int startLSB = input.read();
// int startMSB = input.read();
// int pos = startLSB + startMSB << 8;
// Emulator.computer.getCpu().JSR(pos);
// int next;
// while ((next=input.read()) != -1) {
// memory.write(pos++, (byte) next, false, true);
// }
// if (resume) {
// Emulator.computer.resume();
// }
// } catch (IOException ex) {
// Logger.getLogger(AssemblyHandler.class.getName()).log(Level.SEVERE, null, ex);
// }
// }
// clean(lastResult);
// }
//
// @Override
// public void clean(CompileResult<File> lastResult) {
// if (lastResult.getCompiledAsset() != null) {
// lastResult.getCompiledAsset().delete();
// }
// }
// }
| import jace.applesoft.ApplesoftHandler;
import jace.assembly.AssemblyHandler;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.concurrent.Worker;
import javafx.scene.control.TextInputDialog;
import javafx.scene.web.PromptData;
import javafx.scene.web.WebView;
import netscape.javascript.JSObject; | package jace.ide;
/**
*
* @author blurry
*/
public class Program {
public static String CODEMIRROR_EDITOR = "/codemirror/editor.html";
public static enum DocumentType {
| // Path: src/main/java/jace/applesoft/ApplesoftHandler.java
// public class ApplesoftHandler implements LanguageHandler<ApplesoftProgram> {
//
// @Override
// public String getNewDocumentContent() {
// return ApplesoftProgram.fromMemory(Emulator.computer.getMemory()).toString();
// }
//
// @Override
// public CompileResult<ApplesoftProgram> compile(Program program) {
// final ApplesoftProgram result = ApplesoftProgram.fromString(program.getValue());
// final Map<Integer, String> warnings = new LinkedHashMap<>();
// // int lineNumber = 1;
// // for (Line l : result.lines) {
// // warnings.put(lineNumber++, l.toString());
// // }
// return new CompileResult<ApplesoftProgram>() {
// @Override
// public boolean isSuccessful() {
// return result != null;
// }
//
// @Override
// public ApplesoftProgram getCompiledAsset() {
// return result;
// }
//
// @Override
// public Map<Integer, String> getErrors() {
// return Collections.EMPTY_MAP;
// }
//
// @Override
// public Map<Integer, String> getWarnings() {
// return warnings;
// }
//
// @Override
// public List<String> getOtherMessages() {
// return Collections.EMPTY_LIST;
// }
//
// @Override
// public List<String> getRawOutput() {
// return Collections.EMPTY_LIST;
// }
// };
// }
//
// @Override
// public void execute(CompileResult<ApplesoftProgram> lastResult) {
// lastResult.getCompiledAsset().run();
// }
//
// @Override
// public void clean(CompileResult<ApplesoftProgram> lastResult) {
// }
// }
//
// Path: src/main/java/jace/assembly/AssemblyHandler.java
// public class AssemblyHandler implements LanguageHandler<File> {
// @Override
// public String getNewDocumentContent() {
// return "\t\t*= $300;\n\t\t!cpu 65c02;\n;--- Insert your code here ---\n";
// }
//
// @Override
// public CompileResult<File> compile(Program proxy) {
// AcmeCompiler compiler = new AcmeCompiler();
// compiler.compile(proxy);
// return compiler;
// }
//
// @Override
// public void execute(CompileResult<File> lastResult) {
// if (lastResult.isSuccessful()) {
// try {
// boolean resume = false;
// if (Emulator.computer.isRunning()) {
// resume = true;
// Emulator.computer.pause();
// }
// RAM memory = Emulator.computer.getMemory();
// FileInputStream input = new FileInputStream(lastResult.getCompiledAsset());
// int startLSB = input.read();
// int startMSB = input.read();
// int pos = startLSB + startMSB << 8;
// Emulator.computer.getCpu().JSR(pos);
// int next;
// while ((next=input.read()) != -1) {
// memory.write(pos++, (byte) next, false, true);
// }
// if (resume) {
// Emulator.computer.resume();
// }
// } catch (IOException ex) {
// Logger.getLogger(AssemblyHandler.class.getName()).log(Level.SEVERE, null, ex);
// }
// }
// clean(lastResult);
// }
//
// @Override
// public void clean(CompileResult<File> lastResult) {
// if (lastResult.getCompiledAsset() != null) {
// lastResult.getCompiledAsset().delete();
// }
// }
// }
// Path: src/main/java/jace/ide/Program.java
import jace.applesoft.ApplesoftHandler;
import jace.assembly.AssemblyHandler;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.concurrent.Worker;
import javafx.scene.control.TextInputDialog;
import javafx.scene.web.PromptData;
import javafx.scene.web.WebView;
import netscape.javascript.JSObject;
package jace.ide;
/**
*
* @author blurry
*/
public class Program {
public static String CODEMIRROR_EDITOR = "/codemirror/editor.html";
public static enum DocumentType {
| applesoft(new ApplesoftHandler(), "textfile", "*.bas"), assembly(new AssemblyHandler(), "textfile", "*.a", "*.s", "*.asm"), plain(new TextHandler(), "textfile", "*.txt"), hex(new TextHandler(), "textfile", "*.bin", "*.raw"); |
badvision/jace | src/main/java/jace/ide/Program.java | // Path: src/main/java/jace/applesoft/ApplesoftHandler.java
// public class ApplesoftHandler implements LanguageHandler<ApplesoftProgram> {
//
// @Override
// public String getNewDocumentContent() {
// return ApplesoftProgram.fromMemory(Emulator.computer.getMemory()).toString();
// }
//
// @Override
// public CompileResult<ApplesoftProgram> compile(Program program) {
// final ApplesoftProgram result = ApplesoftProgram.fromString(program.getValue());
// final Map<Integer, String> warnings = new LinkedHashMap<>();
// // int lineNumber = 1;
// // for (Line l : result.lines) {
// // warnings.put(lineNumber++, l.toString());
// // }
// return new CompileResult<ApplesoftProgram>() {
// @Override
// public boolean isSuccessful() {
// return result != null;
// }
//
// @Override
// public ApplesoftProgram getCompiledAsset() {
// return result;
// }
//
// @Override
// public Map<Integer, String> getErrors() {
// return Collections.EMPTY_MAP;
// }
//
// @Override
// public Map<Integer, String> getWarnings() {
// return warnings;
// }
//
// @Override
// public List<String> getOtherMessages() {
// return Collections.EMPTY_LIST;
// }
//
// @Override
// public List<String> getRawOutput() {
// return Collections.EMPTY_LIST;
// }
// };
// }
//
// @Override
// public void execute(CompileResult<ApplesoftProgram> lastResult) {
// lastResult.getCompiledAsset().run();
// }
//
// @Override
// public void clean(CompileResult<ApplesoftProgram> lastResult) {
// }
// }
//
// Path: src/main/java/jace/assembly/AssemblyHandler.java
// public class AssemblyHandler implements LanguageHandler<File> {
// @Override
// public String getNewDocumentContent() {
// return "\t\t*= $300;\n\t\t!cpu 65c02;\n;--- Insert your code here ---\n";
// }
//
// @Override
// public CompileResult<File> compile(Program proxy) {
// AcmeCompiler compiler = new AcmeCompiler();
// compiler.compile(proxy);
// return compiler;
// }
//
// @Override
// public void execute(CompileResult<File> lastResult) {
// if (lastResult.isSuccessful()) {
// try {
// boolean resume = false;
// if (Emulator.computer.isRunning()) {
// resume = true;
// Emulator.computer.pause();
// }
// RAM memory = Emulator.computer.getMemory();
// FileInputStream input = new FileInputStream(lastResult.getCompiledAsset());
// int startLSB = input.read();
// int startMSB = input.read();
// int pos = startLSB + startMSB << 8;
// Emulator.computer.getCpu().JSR(pos);
// int next;
// while ((next=input.read()) != -1) {
// memory.write(pos++, (byte) next, false, true);
// }
// if (resume) {
// Emulator.computer.resume();
// }
// } catch (IOException ex) {
// Logger.getLogger(AssemblyHandler.class.getName()).log(Level.SEVERE, null, ex);
// }
// }
// clean(lastResult);
// }
//
// @Override
// public void clean(CompileResult<File> lastResult) {
// if (lastResult.getCompiledAsset() != null) {
// lastResult.getCompiledAsset().delete();
// }
// }
// }
| import jace.applesoft.ApplesoftHandler;
import jace.assembly.AssemblyHandler;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.concurrent.Worker;
import javafx.scene.control.TextInputDialog;
import javafx.scene.web.PromptData;
import javafx.scene.web.WebView;
import netscape.javascript.JSObject; | package jace.ide;
/**
*
* @author blurry
*/
public class Program {
public static String CODEMIRROR_EDITOR = "/codemirror/editor.html";
public static enum DocumentType {
| // Path: src/main/java/jace/applesoft/ApplesoftHandler.java
// public class ApplesoftHandler implements LanguageHandler<ApplesoftProgram> {
//
// @Override
// public String getNewDocumentContent() {
// return ApplesoftProgram.fromMemory(Emulator.computer.getMemory()).toString();
// }
//
// @Override
// public CompileResult<ApplesoftProgram> compile(Program program) {
// final ApplesoftProgram result = ApplesoftProgram.fromString(program.getValue());
// final Map<Integer, String> warnings = new LinkedHashMap<>();
// // int lineNumber = 1;
// // for (Line l : result.lines) {
// // warnings.put(lineNumber++, l.toString());
// // }
// return new CompileResult<ApplesoftProgram>() {
// @Override
// public boolean isSuccessful() {
// return result != null;
// }
//
// @Override
// public ApplesoftProgram getCompiledAsset() {
// return result;
// }
//
// @Override
// public Map<Integer, String> getErrors() {
// return Collections.EMPTY_MAP;
// }
//
// @Override
// public Map<Integer, String> getWarnings() {
// return warnings;
// }
//
// @Override
// public List<String> getOtherMessages() {
// return Collections.EMPTY_LIST;
// }
//
// @Override
// public List<String> getRawOutput() {
// return Collections.EMPTY_LIST;
// }
// };
// }
//
// @Override
// public void execute(CompileResult<ApplesoftProgram> lastResult) {
// lastResult.getCompiledAsset().run();
// }
//
// @Override
// public void clean(CompileResult<ApplesoftProgram> lastResult) {
// }
// }
//
// Path: src/main/java/jace/assembly/AssemblyHandler.java
// public class AssemblyHandler implements LanguageHandler<File> {
// @Override
// public String getNewDocumentContent() {
// return "\t\t*= $300;\n\t\t!cpu 65c02;\n;--- Insert your code here ---\n";
// }
//
// @Override
// public CompileResult<File> compile(Program proxy) {
// AcmeCompiler compiler = new AcmeCompiler();
// compiler.compile(proxy);
// return compiler;
// }
//
// @Override
// public void execute(CompileResult<File> lastResult) {
// if (lastResult.isSuccessful()) {
// try {
// boolean resume = false;
// if (Emulator.computer.isRunning()) {
// resume = true;
// Emulator.computer.pause();
// }
// RAM memory = Emulator.computer.getMemory();
// FileInputStream input = new FileInputStream(lastResult.getCompiledAsset());
// int startLSB = input.read();
// int startMSB = input.read();
// int pos = startLSB + startMSB << 8;
// Emulator.computer.getCpu().JSR(pos);
// int next;
// while ((next=input.read()) != -1) {
// memory.write(pos++, (byte) next, false, true);
// }
// if (resume) {
// Emulator.computer.resume();
// }
// } catch (IOException ex) {
// Logger.getLogger(AssemblyHandler.class.getName()).log(Level.SEVERE, null, ex);
// }
// }
// clean(lastResult);
// }
//
// @Override
// public void clean(CompileResult<File> lastResult) {
// if (lastResult.getCompiledAsset() != null) {
// lastResult.getCompiledAsset().delete();
// }
// }
// }
// Path: src/main/java/jace/ide/Program.java
import jace.applesoft.ApplesoftHandler;
import jace.assembly.AssemblyHandler;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.concurrent.Worker;
import javafx.scene.control.TextInputDialog;
import javafx.scene.web.PromptData;
import javafx.scene.web.WebView;
import netscape.javascript.JSObject;
package jace.ide;
/**
*
* @author blurry
*/
public class Program {
public static String CODEMIRROR_EDITOR = "/codemirror/editor.html";
public static enum DocumentType {
| applesoft(new ApplesoftHandler(), "textfile", "*.bas"), assembly(new AssemblyHandler(), "textfile", "*.a", "*.s", "*.asm"), plain(new TextHandler(), "textfile", "*.txt"), hex(new TextHandler(), "textfile", "*.bin", "*.raw"); |
badvision/jace | src/main/java/jace/library/MediaConsumer.java | // Path: src/main/java/jace/library/MediaEntry.java
// public static class MediaFile implements Serializable {
// public long checksum;
// public File path;
// public boolean activeVersion;
// public String label;
// public long lastRead;
// public long lastWritten;
// volatile public boolean temporary = false;
// }
| import jace.library.MediaEntry.MediaFile;
import java.io.IOException;
import java.util.Optional;
import javafx.scene.control.Label; | /*
* Copyright (C) 2013 brobert.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package jace.library;
/**
*
* @author brobert
*/
public interface MediaConsumer {
public Optional<Label> getIcon();
public void setIcon(Optional<Label> i); | // Path: src/main/java/jace/library/MediaEntry.java
// public static class MediaFile implements Serializable {
// public long checksum;
// public File path;
// public boolean activeVersion;
// public String label;
// public long lastRead;
// public long lastWritten;
// volatile public boolean temporary = false;
// }
// Path: src/main/java/jace/library/MediaConsumer.java
import jace.library.MediaEntry.MediaFile;
import java.io.IOException;
import java.util.Optional;
import javafx.scene.control.Label;
/*
* Copyright (C) 2013 brobert.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package jace.library;
/**
*
* @author brobert
*/
public interface MediaConsumer {
public Optional<Label> getIcon();
public void setIcon(Optional<Label> i); | public void insertMedia(MediaEntry e, MediaFile f) throws IOException; |
badvision/jace | src/main/java/jace/core/Video.java | // Path: src/main/java/jace/Emulator.java
// public class Emulator {
//
// public static Emulator instance;
// public static EmulatorUILogic logic = new EmulatorUILogic();
// public static Thread mainThread;
//
// // public static void main(String... args) {
// // mainThread = Thread.currentThread();
// // instance = new Emulator(args);
// // }
//
// public static Apple2e computer;
//
// /**
// * Creates a new instance of Emulator
// * @param args
// */
// public Emulator(List<String> args) {
// instance = this;
// computer = new Apple2e();
// Configuration.buildTree();
// Configuration.loadSettings();
// mainThread = Thread.currentThread();
// applyConfiguration(args);
// }
//
// public void applyConfiguration(List<String> args) {
// Map<String, String> settings = new LinkedHashMap<>();
// if (args != null) {
// for (int i = 0; i < args.size(); i++) {
// if (args.get(i).startsWith("-")) {
// String key = args.get(i).substring(1);
// if ((i + 1) < args.size()) {
// String val = args.get(i + 1);
// if (!val.startsWith("-")) {
// settings.put(key, val);
// i++;
// } else {
// settings.put(key, "true");
// }
// } else {
// settings.put(key, "true");
// }
// } else {
// System.err.println("Did not understand parameter " + args.get(i) + ", skipping.");
// }
// }
// }
// Configuration.applySettings(settings);
// // EmulatorUILogic.registerDebugger();
// // computer.coldStart();
// }
//
// public static void resizeVideo() {
// // AbstractEmulatorFrame window = getFrame();
// // if (window != null) {
// // window.resizeVideo();
// // }
// }
// }
| import jace.Emulator;
import jace.state.Stateful;
import jace.config.ConfigurableField;
import jace.config.InvokableAction;
import javafx.scene.image.Image;
import javafx.scene.image.WritableImage;
| //floor((x-1024)/128) + floor(((x-1024)%128)/40)*8
// Caller must check result is <= 23, if so then they are in a screenhole!
return (y >> 7) + (((y & 0x7f) / 40) << 3);
}
static public int identifyHiresRow(int y) {
int blockOffset = identifyTextRow(y & 0x03ff);
// Caller must check results is > 0, if not then they are in a screenhole!
if (blockOffset > 23) {
return -1;
}
return ((y >> 10) & 7) + (blockOffset << 3);
}
public abstract void doPostDraw();
public byte getFloatingBus() {
return floatingBus;
}
private void setFloatingBus(byte floatingBus) {
this.floatingBus = floatingBus;
}
@InvokableAction(name = "Refresh screen",
category = "display",
description = "Marks screen contents as changed, forcing full screen redraw",
alternatives = "redraw",
defaultKeyMapping = {"ctrl+shift+r"})
public static final void forceRefresh() {
| // Path: src/main/java/jace/Emulator.java
// public class Emulator {
//
// public static Emulator instance;
// public static EmulatorUILogic logic = new EmulatorUILogic();
// public static Thread mainThread;
//
// // public static void main(String... args) {
// // mainThread = Thread.currentThread();
// // instance = new Emulator(args);
// // }
//
// public static Apple2e computer;
//
// /**
// * Creates a new instance of Emulator
// * @param args
// */
// public Emulator(List<String> args) {
// instance = this;
// computer = new Apple2e();
// Configuration.buildTree();
// Configuration.loadSettings();
// mainThread = Thread.currentThread();
// applyConfiguration(args);
// }
//
// public void applyConfiguration(List<String> args) {
// Map<String, String> settings = new LinkedHashMap<>();
// if (args != null) {
// for (int i = 0; i < args.size(); i++) {
// if (args.get(i).startsWith("-")) {
// String key = args.get(i).substring(1);
// if ((i + 1) < args.size()) {
// String val = args.get(i + 1);
// if (!val.startsWith("-")) {
// settings.put(key, val);
// i++;
// } else {
// settings.put(key, "true");
// }
// } else {
// settings.put(key, "true");
// }
// } else {
// System.err.println("Did not understand parameter " + args.get(i) + ", skipping.");
// }
// }
// }
// Configuration.applySettings(settings);
// // EmulatorUILogic.registerDebugger();
// // computer.coldStart();
// }
//
// public static void resizeVideo() {
// // AbstractEmulatorFrame window = getFrame();
// // if (window != null) {
// // window.resizeVideo();
// // }
// }
// }
// Path: src/main/java/jace/core/Video.java
import jace.Emulator;
import jace.state.Stateful;
import jace.config.ConfigurableField;
import jace.config.InvokableAction;
import javafx.scene.image.Image;
import javafx.scene.image.WritableImage;
//floor((x-1024)/128) + floor(((x-1024)%128)/40)*8
// Caller must check result is <= 23, if so then they are in a screenhole!
return (y >> 7) + (((y & 0x7f) / 40) << 3);
}
static public int identifyHiresRow(int y) {
int blockOffset = identifyTextRow(y & 0x03ff);
// Caller must check results is > 0, if not then they are in a screenhole!
if (blockOffset > 23) {
return -1;
}
return ((y >> 10) & 7) + (blockOffset << 3);
}
public abstract void doPostDraw();
public byte getFloatingBus() {
return floatingBus;
}
private void setFloatingBus(byte floatingBus) {
this.floatingBus = floatingBus;
}
@InvokableAction(name = "Refresh screen",
category = "display",
description = "Marks screen contents as changed, forcing full screen redraw",
alternatives = "redraw",
defaultKeyMapping = {"ctrl+shift+r"})
public static final void forceRefresh() {
| if (Emulator.computer != null && Emulator.computer.video != null) {
|
jonnyzzz/IDEA.Dependencies | src/main/java/com/eugenePetrenko/idea/dependencies/AnalyzeStrategies.java | // Path: src/main/java/com/eugenePetrenko/idea/dependencies/data/ModulesDependencies.java
// public class ModulesDependencies {
// private final Map<Module, LibOrModuleSet> myModuleToRemove = new HashMap<>();
//
// public void addAll(@NotNull final Module fromModule,
// @NotNull final LibOrModuleSet dependencies) {
// if (dependencies.isEmpty()) return;
//
// final LibOrModuleSet d = myModuleToRemove.get(fromModule);
// if (d == null) {
// myModuleToRemove.put(fromModule, dependencies);
// } else {
// d.addDependencies(dependencies);
// }
// }
//
// @NotNull
// public Collection<Module> modules() {
// return myModuleToRemove.keySet();
// }
//
// @Nullable
// public LibOrModuleSet forModule(@NotNull final Module module) {
// final LibOrModuleSet set = myModuleToRemove.get(module);
// assert set == null || !set.isEmpty();
// return set;
// }
//
// public boolean isEmpty() {
// if (myModuleToRemove.isEmpty()) return true;
// for (LibOrModuleSet val : myModuleToRemove.values()) {
// if (!val.isEmpty()) return false;
// }
// return true;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append("RemoveModulesModel{\n");
// for (Map.Entry<Module, LibOrModuleSet> e : myModuleToRemove.entrySet()) {
// if (e.getValue().isEmpty()) continue;
//
// sb.append(" ").append(e.getKey()).append(" =>\n");
// for (String line : e.getValue().toString().split("[\n\r]+")) {
// if (StringUtil.isEmptyOrSpaces(line)) continue;
// sb.append(" ").append(line).append("\n");
// }
// }
// sb.append('}');
// return sb.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final ModulesDependencies that = (ModulesDependencies) o;
//
// final Set<Module> allKeys = new HashSet<>();
// allKeys.addAll(this.myModuleToRemove.keySet());
// allKeys.addAll(that.myModuleToRemove.keySet());
//
// for (Module key : allKeys) {
// final LibOrModuleSet thisSet = this.myModuleToRemove.get(key);
// final LibOrModuleSet thatSet = that.myModuleToRemove.get(key);
//
// if ((thisSet == null || thisSet.isEmpty()) && (thatSet == null || thatSet.isEmpty())) continue;
// if (thisSet == null || thatSet == null) return false;
// if (!thisSet.equals(thatSet)) return false;
// }
// return true;
// }
//
// @Override
// public int hashCode() {
// return myModuleToRemove.hashCode();
// }
// }
| import com.eugenePetrenko.idea.dependencies.data.ModulesDependencies;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.OrderEntry;
import org.jetbrains.annotations.NotNull; | /*
* Copyright 2013-2013 Eugene Petrenko
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eugenePetrenko.idea.dependencies;
/**
* Created by Eugene Petrenko (eugene.petrenko@gmail.com)
* Date: 17.04.13 12:19
*/
public enum AnalyzeStrategies implements AnalyzeStrategy {
WITH_EXPORT_DEPENDENCIES {
@NotNull
public Module[] collectAllModules(@NotNull Project project, @NotNull Module[] initial) {
return ModuleDependenciesHelper.includeExportDependencies(project, initial);
}
| // Path: src/main/java/com/eugenePetrenko/idea/dependencies/data/ModulesDependencies.java
// public class ModulesDependencies {
// private final Map<Module, LibOrModuleSet> myModuleToRemove = new HashMap<>();
//
// public void addAll(@NotNull final Module fromModule,
// @NotNull final LibOrModuleSet dependencies) {
// if (dependencies.isEmpty()) return;
//
// final LibOrModuleSet d = myModuleToRemove.get(fromModule);
// if (d == null) {
// myModuleToRemove.put(fromModule, dependencies);
// } else {
// d.addDependencies(dependencies);
// }
// }
//
// @NotNull
// public Collection<Module> modules() {
// return myModuleToRemove.keySet();
// }
//
// @Nullable
// public LibOrModuleSet forModule(@NotNull final Module module) {
// final LibOrModuleSet set = myModuleToRemove.get(module);
// assert set == null || !set.isEmpty();
// return set;
// }
//
// public boolean isEmpty() {
// if (myModuleToRemove.isEmpty()) return true;
// for (LibOrModuleSet val : myModuleToRemove.values()) {
// if (!val.isEmpty()) return false;
// }
// return true;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append("RemoveModulesModel{\n");
// for (Map.Entry<Module, LibOrModuleSet> e : myModuleToRemove.entrySet()) {
// if (e.getValue().isEmpty()) continue;
//
// sb.append(" ").append(e.getKey()).append(" =>\n");
// for (String line : e.getValue().toString().split("[\n\r]+")) {
// if (StringUtil.isEmptyOrSpaces(line)) continue;
// sb.append(" ").append(line).append("\n");
// }
// }
// sb.append('}');
// return sb.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final ModulesDependencies that = (ModulesDependencies) o;
//
// final Set<Module> allKeys = new HashSet<>();
// allKeys.addAll(this.myModuleToRemove.keySet());
// allKeys.addAll(that.myModuleToRemove.keySet());
//
// for (Module key : allKeys) {
// final LibOrModuleSet thisSet = this.myModuleToRemove.get(key);
// final LibOrModuleSet thatSet = that.myModuleToRemove.get(key);
//
// if ((thisSet == null || thisSet.isEmpty()) && (thatSet == null || thatSet.isEmpty())) continue;
// if (thisSet == null || thatSet == null) return false;
// if (!thisSet.equals(thatSet)) return false;
// }
// return true;
// }
//
// @Override
// public int hashCode() {
// return myModuleToRemove.hashCode();
// }
// }
// Path: src/main/java/com/eugenePetrenko/idea/dependencies/AnalyzeStrategies.java
import com.eugenePetrenko.idea.dependencies.data.ModulesDependencies;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.OrderEntry;
import org.jetbrains.annotations.NotNull;
/*
* Copyright 2013-2013 Eugene Petrenko
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eugenePetrenko.idea.dependencies;
/**
* Created by Eugene Petrenko (eugene.petrenko@gmail.com)
* Date: 17.04.13 12:19
*/
public enum AnalyzeStrategies implements AnalyzeStrategy {
WITH_EXPORT_DEPENDENCIES {
@NotNull
public Module[] collectAllModules(@NotNull Project project, @NotNull Module[] initial) {
return ModuleDependenciesHelper.includeExportDependencies(project, initial);
}
| public void updateDetectedDependencies(@NotNull Project project, @NotNull Module[] modules, @NotNull ModulesDependencies deps) { |
jonnyzzz/IDEA.Dependencies | src/main/java/com/eugenePetrenko/idea/dependencies/AnalyzeStrategy.java | // Path: src/main/java/com/eugenePetrenko/idea/dependencies/data/ModulesDependencies.java
// public class ModulesDependencies {
// private final Map<Module, LibOrModuleSet> myModuleToRemove = new HashMap<>();
//
// public void addAll(@NotNull final Module fromModule,
// @NotNull final LibOrModuleSet dependencies) {
// if (dependencies.isEmpty()) return;
//
// final LibOrModuleSet d = myModuleToRemove.get(fromModule);
// if (d == null) {
// myModuleToRemove.put(fromModule, dependencies);
// } else {
// d.addDependencies(dependencies);
// }
// }
//
// @NotNull
// public Collection<Module> modules() {
// return myModuleToRemove.keySet();
// }
//
// @Nullable
// public LibOrModuleSet forModule(@NotNull final Module module) {
// final LibOrModuleSet set = myModuleToRemove.get(module);
// assert set == null || !set.isEmpty();
// return set;
// }
//
// public boolean isEmpty() {
// if (myModuleToRemove.isEmpty()) return true;
// for (LibOrModuleSet val : myModuleToRemove.values()) {
// if (!val.isEmpty()) return false;
// }
// return true;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append("RemoveModulesModel{\n");
// for (Map.Entry<Module, LibOrModuleSet> e : myModuleToRemove.entrySet()) {
// if (e.getValue().isEmpty()) continue;
//
// sb.append(" ").append(e.getKey()).append(" =>\n");
// for (String line : e.getValue().toString().split("[\n\r]+")) {
// if (StringUtil.isEmptyOrSpaces(line)) continue;
// sb.append(" ").append(line).append("\n");
// }
// }
// sb.append('}');
// return sb.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final ModulesDependencies that = (ModulesDependencies) o;
//
// final Set<Module> allKeys = new HashSet<>();
// allKeys.addAll(this.myModuleToRemove.keySet());
// allKeys.addAll(that.myModuleToRemove.keySet());
//
// for (Module key : allKeys) {
// final LibOrModuleSet thisSet = this.myModuleToRemove.get(key);
// final LibOrModuleSet thatSet = that.myModuleToRemove.get(key);
//
// if ((thisSet == null || thisSet.isEmpty()) && (thatSet == null || thatSet.isEmpty())) continue;
// if (thisSet == null || thatSet == null) return false;
// if (!thisSet.equals(thatSet)) return false;
// }
// return true;
// }
//
// @Override
// public int hashCode() {
// return myModuleToRemove.hashCode();
// }
// }
| import com.eugenePetrenko.idea.dependencies.data.ModulesDependencies;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.OrderEntry;
import org.jetbrains.annotations.NotNull; | /*
* Copyright 2013-2013 Eugene Petrenko
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eugenePetrenko.idea.dependencies;
/**
* Dependency processing interface,
* implementation may assume it is called under Read (or even Write) lock
*/
public interface AnalyzeStrategy {
/**
* called at the very beginning to expand modules that are searched
* @param project project
* @param initial user-selected modules set
* @return expanded modules set
*/
@NotNull
Module[] collectAllModules(@NotNull Project project, @NotNull Module[] initial);
/**
* called to post-process collected actual dependencies.
* For example to update exported module dependencies in results
* @param project project
* @param modules expanded set of modules
* @param deps actual collected dependencies
*/ | // Path: src/main/java/com/eugenePetrenko/idea/dependencies/data/ModulesDependencies.java
// public class ModulesDependencies {
// private final Map<Module, LibOrModuleSet> myModuleToRemove = new HashMap<>();
//
// public void addAll(@NotNull final Module fromModule,
// @NotNull final LibOrModuleSet dependencies) {
// if (dependencies.isEmpty()) return;
//
// final LibOrModuleSet d = myModuleToRemove.get(fromModule);
// if (d == null) {
// myModuleToRemove.put(fromModule, dependencies);
// } else {
// d.addDependencies(dependencies);
// }
// }
//
// @NotNull
// public Collection<Module> modules() {
// return myModuleToRemove.keySet();
// }
//
// @Nullable
// public LibOrModuleSet forModule(@NotNull final Module module) {
// final LibOrModuleSet set = myModuleToRemove.get(module);
// assert set == null || !set.isEmpty();
// return set;
// }
//
// public boolean isEmpty() {
// if (myModuleToRemove.isEmpty()) return true;
// for (LibOrModuleSet val : myModuleToRemove.values()) {
// if (!val.isEmpty()) return false;
// }
// return true;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append("RemoveModulesModel{\n");
// for (Map.Entry<Module, LibOrModuleSet> e : myModuleToRemove.entrySet()) {
// if (e.getValue().isEmpty()) continue;
//
// sb.append(" ").append(e.getKey()).append(" =>\n");
// for (String line : e.getValue().toString().split("[\n\r]+")) {
// if (StringUtil.isEmptyOrSpaces(line)) continue;
// sb.append(" ").append(line).append("\n");
// }
// }
// sb.append('}');
// return sb.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final ModulesDependencies that = (ModulesDependencies) o;
//
// final Set<Module> allKeys = new HashSet<>();
// allKeys.addAll(this.myModuleToRemove.keySet());
// allKeys.addAll(that.myModuleToRemove.keySet());
//
// for (Module key : allKeys) {
// final LibOrModuleSet thisSet = this.myModuleToRemove.get(key);
// final LibOrModuleSet thatSet = that.myModuleToRemove.get(key);
//
// if ((thisSet == null || thisSet.isEmpty()) && (thatSet == null || thatSet.isEmpty())) continue;
// if (thisSet == null || thatSet == null) return false;
// if (!thisSet.equals(thatSet)) return false;
// }
// return true;
// }
//
// @Override
// public int hashCode() {
// return myModuleToRemove.hashCode();
// }
// }
// Path: src/main/java/com/eugenePetrenko/idea/dependencies/AnalyzeStrategy.java
import com.eugenePetrenko.idea.dependencies.data.ModulesDependencies;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.OrderEntry;
import org.jetbrains.annotations.NotNull;
/*
* Copyright 2013-2013 Eugene Petrenko
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eugenePetrenko.idea.dependencies;
/**
* Dependency processing interface,
* implementation may assume it is called under Read (or even Write) lock
*/
public interface AnalyzeStrategy {
/**
* called at the very beginning to expand modules that are searched
* @param project project
* @param initial user-selected modules set
* @return expanded modules set
*/
@NotNull
Module[] collectAllModules(@NotNull Project project, @NotNull Module[] initial);
/**
* called to post-process collected actual dependencies.
* For example to update exported module dependencies in results
* @param project project
* @param modules expanded set of modules
* @param deps actual collected dependencies
*/ | void updateDetectedDependencies(@NotNull Project project, @NotNull Module[] modules, @NotNull ModulesDependencies deps); |
jonnyzzz/IDEA.Dependencies | src/test/java/com/eugenePetrenko/idea/depedencies/AnalyzerTest.java | // Path: src/main/java/com/eugenePetrenko/idea/dependencies/data/ModulesDependencies.java
// public class ModulesDependencies {
// private final Map<Module, LibOrModuleSet> myModuleToRemove = new HashMap<>();
//
// public void addAll(@NotNull final Module fromModule,
// @NotNull final LibOrModuleSet dependencies) {
// if (dependencies.isEmpty()) return;
//
// final LibOrModuleSet d = myModuleToRemove.get(fromModule);
// if (d == null) {
// myModuleToRemove.put(fromModule, dependencies);
// } else {
// d.addDependencies(dependencies);
// }
// }
//
// @NotNull
// public Collection<Module> modules() {
// return myModuleToRemove.keySet();
// }
//
// @Nullable
// public LibOrModuleSet forModule(@NotNull final Module module) {
// final LibOrModuleSet set = myModuleToRemove.get(module);
// assert set == null || !set.isEmpty();
// return set;
// }
//
// public boolean isEmpty() {
// if (myModuleToRemove.isEmpty()) return true;
// for (LibOrModuleSet val : myModuleToRemove.values()) {
// if (!val.isEmpty()) return false;
// }
// return true;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append("RemoveModulesModel{\n");
// for (Map.Entry<Module, LibOrModuleSet> e : myModuleToRemove.entrySet()) {
// if (e.getValue().isEmpty()) continue;
//
// sb.append(" ").append(e.getKey()).append(" =>\n");
// for (String line : e.getValue().toString().split("[\n\r]+")) {
// if (StringUtil.isEmptyOrSpaces(line)) continue;
// sb.append(" ").append(line).append("\n");
// }
// }
// sb.append('}');
// return sb.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final ModulesDependencies that = (ModulesDependencies) o;
//
// final Set<Module> allKeys = new HashSet<>();
// allKeys.addAll(this.myModuleToRemove.keySet());
// allKeys.addAll(that.myModuleToRemove.keySet());
//
// for (Module key : allKeys) {
// final LibOrModuleSet thisSet = this.myModuleToRemove.get(key);
// final LibOrModuleSet thatSet = that.myModuleToRemove.get(key);
//
// if ((thisSet == null || thisSet.isEmpty()) && (thatSet == null || thatSet.isEmpty())) continue;
// if (thisSet == null || thatSet == null) return false;
// if (!thisSet.equals(thatSet)) return false;
// }
// return true;
// }
//
// @Override
// public int hashCode() {
// return myModuleToRemove.hashCode();
// }
// }
| import com.eugenePetrenko.idea.dependencies.data.ModulesDependencies;
import com.intellij.openapi.roots.libraries.Library;
import static com.eugenePetrenko.idea.dependencies.AnalyzeStrategies.SKIP_EXPORT_DEPENDENCIES;
import static com.eugenePetrenko.idea.dependencies.AnalyzeStrategies.WITH_EXPORT_DEPENDENCIES; | package com.eugenePetrenko.idea.depedencies;
/**
* Created by Eugene Petrenko (eugene.petrenko@gmail.com)
* Date: 09.04.13 10:25
*/
public class AnalyzerTest extends AnalyzerTestCase {
@TestFor(issues = "#4")
public void testTransitiveClasses() throws Throwable {
doTest(new AnalyzerTestAction() {
@Override
protected void testCode() throws Throwable {
final ModuleBuilder m1 = module("m1", "transitiveClasses","a");
final ModuleBuilder m2 = module("m2", "transitiveClasses","b");
final ModuleBuilder m3 = module("m3", "transitiveClasses","c");
final ModuleBuilder m4 = module("m4", "transitiveClasses","d");
dep(m4, m3);
dep(m4, m2);
dep(m4, m1);
dep(m3, m2);
dep(m3, m1); //must not be extra extra
dep(m2, m1);
| // Path: src/main/java/com/eugenePetrenko/idea/dependencies/data/ModulesDependencies.java
// public class ModulesDependencies {
// private final Map<Module, LibOrModuleSet> myModuleToRemove = new HashMap<>();
//
// public void addAll(@NotNull final Module fromModule,
// @NotNull final LibOrModuleSet dependencies) {
// if (dependencies.isEmpty()) return;
//
// final LibOrModuleSet d = myModuleToRemove.get(fromModule);
// if (d == null) {
// myModuleToRemove.put(fromModule, dependencies);
// } else {
// d.addDependencies(dependencies);
// }
// }
//
// @NotNull
// public Collection<Module> modules() {
// return myModuleToRemove.keySet();
// }
//
// @Nullable
// public LibOrModuleSet forModule(@NotNull final Module module) {
// final LibOrModuleSet set = myModuleToRemove.get(module);
// assert set == null || !set.isEmpty();
// return set;
// }
//
// public boolean isEmpty() {
// if (myModuleToRemove.isEmpty()) return true;
// for (LibOrModuleSet val : myModuleToRemove.values()) {
// if (!val.isEmpty()) return false;
// }
// return true;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append("RemoveModulesModel{\n");
// for (Map.Entry<Module, LibOrModuleSet> e : myModuleToRemove.entrySet()) {
// if (e.getValue().isEmpty()) continue;
//
// sb.append(" ").append(e.getKey()).append(" =>\n");
// for (String line : e.getValue().toString().split("[\n\r]+")) {
// if (StringUtil.isEmptyOrSpaces(line)) continue;
// sb.append(" ").append(line).append("\n");
// }
// }
// sb.append('}');
// return sb.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final ModulesDependencies that = (ModulesDependencies) o;
//
// final Set<Module> allKeys = new HashSet<>();
// allKeys.addAll(this.myModuleToRemove.keySet());
// allKeys.addAll(that.myModuleToRemove.keySet());
//
// for (Module key : allKeys) {
// final LibOrModuleSet thisSet = this.myModuleToRemove.get(key);
// final LibOrModuleSet thatSet = that.myModuleToRemove.get(key);
//
// if ((thisSet == null || thisSet.isEmpty()) && (thatSet == null || thatSet.isEmpty())) continue;
// if (thisSet == null || thatSet == null) return false;
// if (!thisSet.equals(thatSet)) return false;
// }
// return true;
// }
//
// @Override
// public int hashCode() {
// return myModuleToRemove.hashCode();
// }
// }
// Path: src/test/java/com/eugenePetrenko/idea/depedencies/AnalyzerTest.java
import com.eugenePetrenko.idea.dependencies.data.ModulesDependencies;
import com.intellij.openapi.roots.libraries.Library;
import static com.eugenePetrenko.idea.dependencies.AnalyzeStrategies.SKIP_EXPORT_DEPENDENCIES;
import static com.eugenePetrenko.idea.dependencies.AnalyzeStrategies.WITH_EXPORT_DEPENDENCIES;
package com.eugenePetrenko.idea.depedencies;
/**
* Created by Eugene Petrenko (eugene.petrenko@gmail.com)
* Date: 09.04.13 10:25
*/
public class AnalyzerTest extends AnalyzerTestCase {
@TestFor(issues = "#4")
public void testTransitiveClasses() throws Throwable {
doTest(new AnalyzerTestAction() {
@Override
protected void testCode() throws Throwable {
final ModuleBuilder m1 = module("m1", "transitiveClasses","a");
final ModuleBuilder m2 = module("m2", "transitiveClasses","b");
final ModuleBuilder m3 = module("m3", "transitiveClasses","c");
final ModuleBuilder m4 = module("m4", "transitiveClasses","d");
dep(m4, m3);
dep(m4, m2);
dep(m4, m1);
dep(m3, m2);
dep(m3, m1); //must not be extra extra
dep(m2, m1);
| ModulesDependencies result = analyzeProject(WITH_EXPORT_DEPENDENCIES); |
jonnyzzz/IDEA.Dependencies | src/main/java/com/eugenePetrenko/idea/dependencies/data/LibOrModuleSet.java | // Path: src/main/java/com/eugenePetrenko/idea/dependencies/DependenciesFilter.java
// public class DependenciesFilter {
// public static final Predicate<OrderEntry> REMOVABLE_DEPENDENCY = input -> input != null && input.accept(new RootPolicy<>() {
// @Override
// public Boolean visitModuleOrderEntry(@NotNull ModuleOrderEntry moduleOrderEntry, Boolean value) {
// return true;
// }
//
// @Override
// public Boolean visitLibraryOrderEntry(@NotNull LibraryOrderEntry libraryOrderEntry, Boolean value) {
// final DependencyScope scope = libraryOrderEntry.getScope();
// return scope == DependencyScope.COMPILE || scope == DependencyScope.TEST;
// }
// }, false);
// }
| import com.eugenePetrenko.idea.dependencies.DependenciesFilter;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.LibraryOrderEntry;
import com.intellij.openapi.roots.ModuleOrderEntry;
import com.intellij.openapi.roots.OrderEntry;
import com.intellij.openapi.roots.RootPolicy;
import com.intellij.openapi.roots.libraries.Library;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set; | /*
* Copyright 2013-2013 Eugene Petrenko
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eugenePetrenko.idea.dependencies.data;
/**
* Created 07.04.13 15:54
*
* @author Eugene Petrenko (eugene.petrenko@jetbrains.com)
*/
public class LibOrModuleSet {
private final Set<Module> myModules = new HashSet<>();
private final Set<Library> myLibs = new HashSet<>();
public boolean contains(@Nullable final Module mod) {
return mod != null && myModules.contains(mod);
}
public boolean contains(@Nullable final Library lib) {
return lib != null && myLibs.contains(lib);
}
public boolean contains(@Nullable final OrderEntry e) {
if (e == null) return false;
return e.accept(CONTAINS, false);
}
public void addDependencies(@NotNull final Collection<? extends OrderEntry> es) {
for (OrderEntry e : es) {
addDependency(e);
}
}
public void addDependencies(@NotNull final LibOrModuleSet deps) {
myLibs.addAll(deps.myLibs);
myModules.addAll(deps.myModules);
}
public void addDependency(@NotNull final OrderEntry e) { | // Path: src/main/java/com/eugenePetrenko/idea/dependencies/DependenciesFilter.java
// public class DependenciesFilter {
// public static final Predicate<OrderEntry> REMOVABLE_DEPENDENCY = input -> input != null && input.accept(new RootPolicy<>() {
// @Override
// public Boolean visitModuleOrderEntry(@NotNull ModuleOrderEntry moduleOrderEntry, Boolean value) {
// return true;
// }
//
// @Override
// public Boolean visitLibraryOrderEntry(@NotNull LibraryOrderEntry libraryOrderEntry, Boolean value) {
// final DependencyScope scope = libraryOrderEntry.getScope();
// return scope == DependencyScope.COMPILE || scope == DependencyScope.TEST;
// }
// }, false);
// }
// Path: src/main/java/com/eugenePetrenko/idea/dependencies/data/LibOrModuleSet.java
import com.eugenePetrenko.idea.dependencies.DependenciesFilter;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.LibraryOrderEntry;
import com.intellij.openapi.roots.ModuleOrderEntry;
import com.intellij.openapi.roots.OrderEntry;
import com.intellij.openapi.roots.RootPolicy;
import com.intellij.openapi.roots.libraries.Library;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
/*
* Copyright 2013-2013 Eugene Petrenko
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eugenePetrenko.idea.dependencies.data;
/**
* Created 07.04.13 15:54
*
* @author Eugene Petrenko (eugene.petrenko@jetbrains.com)
*/
public class LibOrModuleSet {
private final Set<Module> myModules = new HashSet<>();
private final Set<Library> myLibs = new HashSet<>();
public boolean contains(@Nullable final Module mod) {
return mod != null && myModules.contains(mod);
}
public boolean contains(@Nullable final Library lib) {
return lib != null && myLibs.contains(lib);
}
public boolean contains(@Nullable final OrderEntry e) {
if (e == null) return false;
return e.accept(CONTAINS, false);
}
public void addDependencies(@NotNull final Collection<? extends OrderEntry> es) {
for (OrderEntry e : es) {
addDependency(e);
}
}
public void addDependencies(@NotNull final LibOrModuleSet deps) {
myLibs.addAll(deps.myLibs);
myModules.addAll(deps.myModules);
}
public void addDependency(@NotNull final OrderEntry e) { | if (!DependenciesFilter.REMOVABLE_DEPENDENCY.test(e)) return; |
noties/ParcelGen | compiler/src/main/java/ru/noties/parcelable/ParcelableTreeModifier.java | // Path: compiler/src/main/java/ru/noties/parcelable/creator/StatementCreator.java
// public interface StatementCreator {
//
// List<JCTree.JCStatement> createReadFromParcel(
// ASTHelper astHelper,
// Element rootElement,
// JCTree.JCExpression parcel,
// String varName,
// boolean isArray
// );
//
// List<JCTree.JCStatement> createWriteToParcel(
// ASTHelper astHelper,
// Element rootElement,
// JCTree.JCExpression parcel,
// JCTree.JCExpression flags,
// String varName,
// boolean isArray
// );
// }
//
// Path: compiler/src/main/java/ru/noties/parcelable/creator/StatementCreatorFactory.java
// public class StatementCreatorFactory {
//
// private final Map<ParcelableType, StatementCreator> mCache;
//
// public StatementCreatorFactory() {
// this.mCache = new HashMap<>();
// }
//
// public StatementCreator get(ParcelableType type) {
// final StatementCreator creator;
// if (mCache.containsKey(type)) {
// creator = mCache.get(type);
// } else {
// creator = createNew(type);
// mCache.put(type, creator);
// }
// return creator;
// }
//
// private static StatementCreator createNew(ParcelableType type) {
//
// switch (type) {
//
// case BYTE:
// return new StatementCreatorByte();
//
// case INT:
// return new StatementCreatorInt();
//
// case LONG:
// return new StatementCreatorLong();
//
// case FLOAT:
// return new StatementCreatorFloat();
//
// case DOUBLE:
// return new StatementCreatorDouble();
//
// case SERIALIZABLE:
// return new StatementCreatorSerializable();
//
// case STRING:
// return new StatementCreatorString();
//
// case BUNDLE:
// return new StatementCreatorBundle();
//
// case CHAR_SEQUENCE:
// return new StatementCreatorCharSequence();
//
// case TYPED_LIST:
// return new StatementCreatorTypedList();
//
// case PARCELABLE:
// return new StatementCreatorParcelable();
//
// case BOOLEAN:
// return new StatementCreatorBoolean();
//
// case ENUM:
// return new StatementCreatorEnum();
//
// case LIST:
// return new StatementCreatorList();
//
// case OBJECT:
// return new StatementCreatorObject();
//
// default:
// throw new IllegalStateException("Unknown type: " + type);
// }
// }
// }
| import com.sun.source.tree.Tree;
import com.sun.source.util.Trees;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.tree.TreeTranslator;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.Names;
import java.lang.reflect.Modifier;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.type.TypeKind;
import javax.lang.model.util.Elements;
import javax.tools.Diagnostic;
import ru.noties.parcelable.creator.StatementCreator;
import ru.noties.parcelable.creator.StatementCreatorFactory; | mASTHelper.getModifiers(),
mASTHelper.getName(WRITE_PARCEL_VAR_NAME),
mParcelType,
null
);
final JCTree.JCVariableDecl varFlags = mTreeMaker.VarDef(
mASTHelper.getModifiers(),
mASTHelper.getName(WRITE_FLAGS_VAR_NAME),
mASTHelper.getPrimitiveType(TypeKind.INT),
null
);
final JCTree.JCMethodDecl writeToParcelMethod = mTreeMaker.MethodDef(
mASTHelper.getModifiers(Modifier.PUBLIC),
mASTHelper.getName("writeToParcel"),
mASTHelper.getPrimitiveType(TypeKind.VOID),
List.<JCTree.JCTypeParameter>nil(),
List.<JCTree.JCVariableDecl>of(varDest, varFlags),
List.<JCTree.JCExpression>nil(),
mTreeMaker.Block(0L, statements),
null
);
jcClassDecl.defs = jcClassDecl.defs.append(writeToParcelMethod);
}
}
static Statements buildStatements(ASTHelper astHelper, ParcelableData data) {
| // Path: compiler/src/main/java/ru/noties/parcelable/creator/StatementCreator.java
// public interface StatementCreator {
//
// List<JCTree.JCStatement> createReadFromParcel(
// ASTHelper astHelper,
// Element rootElement,
// JCTree.JCExpression parcel,
// String varName,
// boolean isArray
// );
//
// List<JCTree.JCStatement> createWriteToParcel(
// ASTHelper astHelper,
// Element rootElement,
// JCTree.JCExpression parcel,
// JCTree.JCExpression flags,
// String varName,
// boolean isArray
// );
// }
//
// Path: compiler/src/main/java/ru/noties/parcelable/creator/StatementCreatorFactory.java
// public class StatementCreatorFactory {
//
// private final Map<ParcelableType, StatementCreator> mCache;
//
// public StatementCreatorFactory() {
// this.mCache = new HashMap<>();
// }
//
// public StatementCreator get(ParcelableType type) {
// final StatementCreator creator;
// if (mCache.containsKey(type)) {
// creator = mCache.get(type);
// } else {
// creator = createNew(type);
// mCache.put(type, creator);
// }
// return creator;
// }
//
// private static StatementCreator createNew(ParcelableType type) {
//
// switch (type) {
//
// case BYTE:
// return new StatementCreatorByte();
//
// case INT:
// return new StatementCreatorInt();
//
// case LONG:
// return new StatementCreatorLong();
//
// case FLOAT:
// return new StatementCreatorFloat();
//
// case DOUBLE:
// return new StatementCreatorDouble();
//
// case SERIALIZABLE:
// return new StatementCreatorSerializable();
//
// case STRING:
// return new StatementCreatorString();
//
// case BUNDLE:
// return new StatementCreatorBundle();
//
// case CHAR_SEQUENCE:
// return new StatementCreatorCharSequence();
//
// case TYPED_LIST:
// return new StatementCreatorTypedList();
//
// case PARCELABLE:
// return new StatementCreatorParcelable();
//
// case BOOLEAN:
// return new StatementCreatorBoolean();
//
// case ENUM:
// return new StatementCreatorEnum();
//
// case LIST:
// return new StatementCreatorList();
//
// case OBJECT:
// return new StatementCreatorObject();
//
// default:
// throw new IllegalStateException("Unknown type: " + type);
// }
// }
// }
// Path: compiler/src/main/java/ru/noties/parcelable/ParcelableTreeModifier.java
import com.sun.source.tree.Tree;
import com.sun.source.util.Trees;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.tree.TreeTranslator;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.Names;
import java.lang.reflect.Modifier;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.type.TypeKind;
import javax.lang.model.util.Elements;
import javax.tools.Diagnostic;
import ru.noties.parcelable.creator.StatementCreator;
import ru.noties.parcelable.creator.StatementCreatorFactory;
mASTHelper.getModifiers(),
mASTHelper.getName(WRITE_PARCEL_VAR_NAME),
mParcelType,
null
);
final JCTree.JCVariableDecl varFlags = mTreeMaker.VarDef(
mASTHelper.getModifiers(),
mASTHelper.getName(WRITE_FLAGS_VAR_NAME),
mASTHelper.getPrimitiveType(TypeKind.INT),
null
);
final JCTree.JCMethodDecl writeToParcelMethod = mTreeMaker.MethodDef(
mASTHelper.getModifiers(Modifier.PUBLIC),
mASTHelper.getName("writeToParcel"),
mASTHelper.getPrimitiveType(TypeKind.VOID),
List.<JCTree.JCTypeParameter>nil(),
List.<JCTree.JCVariableDecl>of(varDest, varFlags),
List.<JCTree.JCExpression>nil(),
mTreeMaker.Block(0L, statements),
null
);
jcClassDecl.defs = jcClassDecl.defs.append(writeToParcelMethod);
}
}
static Statements buildStatements(ASTHelper astHelper, ParcelableData data) {
| final StatementCreatorFactory factory = new StatementCreatorFactory(); |
noties/ParcelGen | compiler/src/main/java/ru/noties/parcelable/ParcelableTreeModifier.java | // Path: compiler/src/main/java/ru/noties/parcelable/creator/StatementCreator.java
// public interface StatementCreator {
//
// List<JCTree.JCStatement> createReadFromParcel(
// ASTHelper astHelper,
// Element rootElement,
// JCTree.JCExpression parcel,
// String varName,
// boolean isArray
// );
//
// List<JCTree.JCStatement> createWriteToParcel(
// ASTHelper astHelper,
// Element rootElement,
// JCTree.JCExpression parcel,
// JCTree.JCExpression flags,
// String varName,
// boolean isArray
// );
// }
//
// Path: compiler/src/main/java/ru/noties/parcelable/creator/StatementCreatorFactory.java
// public class StatementCreatorFactory {
//
// private final Map<ParcelableType, StatementCreator> mCache;
//
// public StatementCreatorFactory() {
// this.mCache = new HashMap<>();
// }
//
// public StatementCreator get(ParcelableType type) {
// final StatementCreator creator;
// if (mCache.containsKey(type)) {
// creator = mCache.get(type);
// } else {
// creator = createNew(type);
// mCache.put(type, creator);
// }
// return creator;
// }
//
// private static StatementCreator createNew(ParcelableType type) {
//
// switch (type) {
//
// case BYTE:
// return new StatementCreatorByte();
//
// case INT:
// return new StatementCreatorInt();
//
// case LONG:
// return new StatementCreatorLong();
//
// case FLOAT:
// return new StatementCreatorFloat();
//
// case DOUBLE:
// return new StatementCreatorDouble();
//
// case SERIALIZABLE:
// return new StatementCreatorSerializable();
//
// case STRING:
// return new StatementCreatorString();
//
// case BUNDLE:
// return new StatementCreatorBundle();
//
// case CHAR_SEQUENCE:
// return new StatementCreatorCharSequence();
//
// case TYPED_LIST:
// return new StatementCreatorTypedList();
//
// case PARCELABLE:
// return new StatementCreatorParcelable();
//
// case BOOLEAN:
// return new StatementCreatorBoolean();
//
// case ENUM:
// return new StatementCreatorEnum();
//
// case LIST:
// return new StatementCreatorList();
//
// case OBJECT:
// return new StatementCreatorObject();
//
// default:
// throw new IllegalStateException("Unknown type: " + type);
// }
// }
// }
| import com.sun.source.tree.Tree;
import com.sun.source.util.Trees;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.tree.TreeTranslator;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.Names;
import java.lang.reflect.Modifier;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.type.TypeKind;
import javax.lang.model.util.Elements;
import javax.tools.Diagnostic;
import ru.noties.parcelable.creator.StatementCreator;
import ru.noties.parcelable.creator.StatementCreatorFactory; | jcClassDecl.defs = jcClassDecl.defs.append(writeToParcelMethod);
}
}
static Statements buildStatements(ASTHelper astHelper, ParcelableData data) {
final StatementCreatorFactory factory = new StatementCreatorFactory();
final TreeMaker treeMaker = astHelper.getTreeMaker();
final JCTree.JCExpression source = treeMaker.Ident(astHelper.getName(READ_PARCEL_VAR_NAME));
final JCTree.JCExpression dest = treeMaker.Ident(astHelper.getName(WRITE_PARCEL_VAR_NAME));
final JCTree.JCExpression flags = treeMaker.Ident(astHelper.getName(WRITE_FLAGS_VAR_NAME));
List<JCTree.JCStatement> read = List.nil();
List<JCTree.JCStatement> write = List.nil();
boolean isArray;
ParcelableType type;
for (ParcelableItem item: data.items) {
isArray = false;
type = item.type;
if (type == ParcelableType.ARRAY) {
isArray = true;
type = ((ParcelableItemArray)item).arrayType;
}
| // Path: compiler/src/main/java/ru/noties/parcelable/creator/StatementCreator.java
// public interface StatementCreator {
//
// List<JCTree.JCStatement> createReadFromParcel(
// ASTHelper astHelper,
// Element rootElement,
// JCTree.JCExpression parcel,
// String varName,
// boolean isArray
// );
//
// List<JCTree.JCStatement> createWriteToParcel(
// ASTHelper astHelper,
// Element rootElement,
// JCTree.JCExpression parcel,
// JCTree.JCExpression flags,
// String varName,
// boolean isArray
// );
// }
//
// Path: compiler/src/main/java/ru/noties/parcelable/creator/StatementCreatorFactory.java
// public class StatementCreatorFactory {
//
// private final Map<ParcelableType, StatementCreator> mCache;
//
// public StatementCreatorFactory() {
// this.mCache = new HashMap<>();
// }
//
// public StatementCreator get(ParcelableType type) {
// final StatementCreator creator;
// if (mCache.containsKey(type)) {
// creator = mCache.get(type);
// } else {
// creator = createNew(type);
// mCache.put(type, creator);
// }
// return creator;
// }
//
// private static StatementCreator createNew(ParcelableType type) {
//
// switch (type) {
//
// case BYTE:
// return new StatementCreatorByte();
//
// case INT:
// return new StatementCreatorInt();
//
// case LONG:
// return new StatementCreatorLong();
//
// case FLOAT:
// return new StatementCreatorFloat();
//
// case DOUBLE:
// return new StatementCreatorDouble();
//
// case SERIALIZABLE:
// return new StatementCreatorSerializable();
//
// case STRING:
// return new StatementCreatorString();
//
// case BUNDLE:
// return new StatementCreatorBundle();
//
// case CHAR_SEQUENCE:
// return new StatementCreatorCharSequence();
//
// case TYPED_LIST:
// return new StatementCreatorTypedList();
//
// case PARCELABLE:
// return new StatementCreatorParcelable();
//
// case BOOLEAN:
// return new StatementCreatorBoolean();
//
// case ENUM:
// return new StatementCreatorEnum();
//
// case LIST:
// return new StatementCreatorList();
//
// case OBJECT:
// return new StatementCreatorObject();
//
// default:
// throw new IllegalStateException("Unknown type: " + type);
// }
// }
// }
// Path: compiler/src/main/java/ru/noties/parcelable/ParcelableTreeModifier.java
import com.sun.source.tree.Tree;
import com.sun.source.util.Trees;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.tree.TreeTranslator;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.Names;
import java.lang.reflect.Modifier;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.type.TypeKind;
import javax.lang.model.util.Elements;
import javax.tools.Diagnostic;
import ru.noties.parcelable.creator.StatementCreator;
import ru.noties.parcelable.creator.StatementCreatorFactory;
jcClassDecl.defs = jcClassDecl.defs.append(writeToParcelMethod);
}
}
static Statements buildStatements(ASTHelper astHelper, ParcelableData data) {
final StatementCreatorFactory factory = new StatementCreatorFactory();
final TreeMaker treeMaker = astHelper.getTreeMaker();
final JCTree.JCExpression source = treeMaker.Ident(astHelper.getName(READ_PARCEL_VAR_NAME));
final JCTree.JCExpression dest = treeMaker.Ident(astHelper.getName(WRITE_PARCEL_VAR_NAME));
final JCTree.JCExpression flags = treeMaker.Ident(astHelper.getName(WRITE_FLAGS_VAR_NAME));
List<JCTree.JCStatement> read = List.nil();
List<JCTree.JCStatement> write = List.nil();
boolean isArray;
ParcelableType type;
for (ParcelableItem item: data.items) {
isArray = false;
type = item.type;
if (type == ParcelableType.ARRAY) {
isArray = true;
type = ((ParcelableItemArray)item).arrayType;
}
| final StatementCreator creator = factory.get(type); |
noties/ParcelGen | sample/src/main/java/ru/noties/parcelable/obj/SomeParcelableSibling.java | // Path: sample/src/main/java/ru/noties/parcelable/BundleUtils.java
// public class BundleUtils {
//
// private BundleUtils() {}
//
// // no support for arrays of any type
// public static boolean equals(Bundle left, Bundle right) {
//
// if (left == right) {
// return true;
// }
//
// if (left == null
// || right == null) {
// return false;
// }
//
// final Set<String> leftSet = left.keySet();
// final Set<String> rightSet = right.keySet();
//
// if (leftSet.size() != rightSet.size()) {
// return false;
// }
//
// Object leftValue;
// Object rightValue;
//
// for (String key: leftSet) {
//
// if (!rightSet.contains(key)) {
// return false;
// }
//
// leftValue = left.get(key);
// rightValue = right.get(key);
//
// if (leftValue instanceof Bundle) {
//
// if (!(rightValue instanceof Bundle)) {
// return false;
// }
//
// if (!BundleUtils.equals((Bundle) leftValue, (Bundle) rightValue)) {
// return false;
// }
// }
//
// if (leftValue != null ? !leftValue.equals(rightValue) : rightValue != null) {
// return false;
// }
//
// }
//
// return true;
// }
//
// public static String dump(Bundle bundle) {
// if (bundle == null) {
// return "null";
// }
//
// final StringBuilder builder = new StringBuilder("Bundle{");
//
// boolean isFirst = true;
// Object val;
//
// for (String key: bundle.keySet()) {
// if (isFirst) {
// isFirst = false;
// } else {
// builder.append(", ");
// }
// builder.append(key)
// .append(": ");
// val = bundle.get(key);
// if (val instanceof Bundle) {
// builder.append(BundleUtils.dump((Bundle) val));
// } else {
// builder.append(String.valueOf(val));
// }
// }
// builder.append("}");
// return builder.toString();
// }
//
// public static Bundle mutate(Bundle bundle) {
//
// if (bundle == null) {
// return null;
// }
//
// final Parcel in = Parcel.obtain();
// in.writeBundle(bundle);
// final byte[] bytes = in.marshall();
//
// final Parcel out = Parcel.obtain();
// out.unmarshall(bytes, 0, bytes.length);
// out.setDataPosition(0);
//
// try {
// return out.readBundle();
// } finally {
// in.recycle();
// out.recycle();
// }
// }
// }
| import android.os.Bundle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import ru.noties.parcelable.BundleUtils;
import ru.noties.parcelable.ParcelGen; | public SomeParcelableSibling setTypedList(List<SomeParcelable> typedList) {
this.typedList = typedList;
return this;
}
public SomeParcelableSibling setBundle(Bundle bundle) {
this.bundle = bundle;
return this;
}
public SomeParcelableSibling setCharSequence(CharSequence charSequence) {
this.charSequence = charSequence;
return this;
}
public SomeParcelableSibling setCharSequenceArray(CharSequence[] charSequenceArray) {
this.charSequenceArray = charSequenceArray;
return this;
}
public SomeParcelableSibling setTypedArrayList(ArrayList<SomeParcelable> typedArrayList) {
this.typedArrayList = typedArrayList;
return this;
}
@Override
public String toString() {
return "SomeParcelableSibling{" +
"typedList=" + typedList +
", typedArrayList=" + typedArrayList + | // Path: sample/src/main/java/ru/noties/parcelable/BundleUtils.java
// public class BundleUtils {
//
// private BundleUtils() {}
//
// // no support for arrays of any type
// public static boolean equals(Bundle left, Bundle right) {
//
// if (left == right) {
// return true;
// }
//
// if (left == null
// || right == null) {
// return false;
// }
//
// final Set<String> leftSet = left.keySet();
// final Set<String> rightSet = right.keySet();
//
// if (leftSet.size() != rightSet.size()) {
// return false;
// }
//
// Object leftValue;
// Object rightValue;
//
// for (String key: leftSet) {
//
// if (!rightSet.contains(key)) {
// return false;
// }
//
// leftValue = left.get(key);
// rightValue = right.get(key);
//
// if (leftValue instanceof Bundle) {
//
// if (!(rightValue instanceof Bundle)) {
// return false;
// }
//
// if (!BundleUtils.equals((Bundle) leftValue, (Bundle) rightValue)) {
// return false;
// }
// }
//
// if (leftValue != null ? !leftValue.equals(rightValue) : rightValue != null) {
// return false;
// }
//
// }
//
// return true;
// }
//
// public static String dump(Bundle bundle) {
// if (bundle == null) {
// return "null";
// }
//
// final StringBuilder builder = new StringBuilder("Bundle{");
//
// boolean isFirst = true;
// Object val;
//
// for (String key: bundle.keySet()) {
// if (isFirst) {
// isFirst = false;
// } else {
// builder.append(", ");
// }
// builder.append(key)
// .append(": ");
// val = bundle.get(key);
// if (val instanceof Bundle) {
// builder.append(BundleUtils.dump((Bundle) val));
// } else {
// builder.append(String.valueOf(val));
// }
// }
// builder.append("}");
// return builder.toString();
// }
//
// public static Bundle mutate(Bundle bundle) {
//
// if (bundle == null) {
// return null;
// }
//
// final Parcel in = Parcel.obtain();
// in.writeBundle(bundle);
// final byte[] bytes = in.marshall();
//
// final Parcel out = Parcel.obtain();
// out.unmarshall(bytes, 0, bytes.length);
// out.setDataPosition(0);
//
// try {
// return out.readBundle();
// } finally {
// in.recycle();
// out.recycle();
// }
// }
// }
// Path: sample/src/main/java/ru/noties/parcelable/obj/SomeParcelableSibling.java
import android.os.Bundle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import ru.noties.parcelable.BundleUtils;
import ru.noties.parcelable.ParcelGen;
public SomeParcelableSibling setTypedList(List<SomeParcelable> typedList) {
this.typedList = typedList;
return this;
}
public SomeParcelableSibling setBundle(Bundle bundle) {
this.bundle = bundle;
return this;
}
public SomeParcelableSibling setCharSequence(CharSequence charSequence) {
this.charSequence = charSequence;
return this;
}
public SomeParcelableSibling setCharSequenceArray(CharSequence[] charSequenceArray) {
this.charSequenceArray = charSequenceArray;
return this;
}
public SomeParcelableSibling setTypedArrayList(ArrayList<SomeParcelable> typedArrayList) {
this.typedArrayList = typedArrayList;
return this;
}
@Override
public String toString() {
return "SomeParcelableSibling{" +
"typedList=" + typedList +
", typedArrayList=" + typedArrayList + | ", bundle=" + BundleUtils.dump(bundle) + |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/RevealJSConverterTest.java | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/RevealJSConverter.java
// public class RevealJSConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "reveal-js";
//
// protected void beforeStart(final Configuration config) {
//
// config.templateFile(classpath("reveal.js/index.html"));
//
// // CSS
// config.staticFile("css", classpath("reveal.js/css/reveal.css"));
// config.staticFile("css/print", classpath("reveal.js/css/print/paper.css"));
// config.staticFile("css/print", classpath("reveal.js/css/print/pdf.css"));
// config.staticFile("css/theme", classpath("reveal.js/css/theme/simple.css"));
// config.staticFile("lib/css", classpath("reveal.js/lib/css/zenburn.css"));
//
// // JavaScript
// config.staticFile("js", classpath("reveal.js/js/reveal.min.js"));
// config.staticFile("lib/js", classpath("reveal.js/lib/js/classList.js"));
// config.staticFile("lib/js", classpath("reveal.js/lib/js/head.min.js"));
// config.staticFile("lib/js", classpath("reveal.js/lib/js/html5shiv.js"));
// config.staticFile("plugin/highlight", classpath("reveal.js/plugin/highlight/highlight.js"));
// config.staticFile("plugin/zoom-js", classpath("reveal.js/plugin/zoom-js/zoom.js"));
// config.staticFile("plugin/notes", classpath("reveal.js/plugin/notes/notes.js"));
// config.staticFile("plugin/notes", classpath("reveal.js/plugin/notes/notes.html"));
//
// }
//
// protected void transformDocument(final Document slidesDocument, final Configuration config) {
// super.transformDocument(slidesDocument, config);
// if (config.notesIncluded()) {
// for (final Element notesElement : slidesDocument.select("aside")) {
// notesElement.addClass("notes");
// }
// }
// if (config.listsIncremented()) {
// for (final Element list : slidesDocument.select("div li")) {
// list.addClass("fragment").addClass("roll-in");
// }
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://lab.hakim.se/reveal-js/";
// }
//
// }
| import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.RevealJSConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class RevealJSConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException { | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/RevealJSConverter.java
// public class RevealJSConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "reveal-js";
//
// protected void beforeStart(final Configuration config) {
//
// config.templateFile(classpath("reveal.js/index.html"));
//
// // CSS
// config.staticFile("css", classpath("reveal.js/css/reveal.css"));
// config.staticFile("css/print", classpath("reveal.js/css/print/paper.css"));
// config.staticFile("css/print", classpath("reveal.js/css/print/pdf.css"));
// config.staticFile("css/theme", classpath("reveal.js/css/theme/simple.css"));
// config.staticFile("lib/css", classpath("reveal.js/lib/css/zenburn.css"));
//
// // JavaScript
// config.staticFile("js", classpath("reveal.js/js/reveal.min.js"));
// config.staticFile("lib/js", classpath("reveal.js/lib/js/classList.js"));
// config.staticFile("lib/js", classpath("reveal.js/lib/js/head.min.js"));
// config.staticFile("lib/js", classpath("reveal.js/lib/js/html5shiv.js"));
// config.staticFile("plugin/highlight", classpath("reveal.js/plugin/highlight/highlight.js"));
// config.staticFile("plugin/zoom-js", classpath("reveal.js/plugin/zoom-js/zoom.js"));
// config.staticFile("plugin/notes", classpath("reveal.js/plugin/notes/notes.js"));
// config.staticFile("plugin/notes", classpath("reveal.js/plugin/notes/notes.html"));
//
// }
//
// protected void transformDocument(final Document slidesDocument, final Configuration config) {
// super.transformDocument(slidesDocument, config);
// if (config.notesIncluded()) {
// for (final Element notesElement : slidesDocument.select("aside")) {
// notesElement.addClass("notes");
// }
// }
// if (config.listsIncremented()) {
// for (final Element list : slidesDocument.select("div li")) {
// list.addClass("fragment").addClass("roll-in");
// }
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://lab.hakim.se/reveal-js/";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/RevealJSConverterTest.java
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.RevealJSConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class RevealJSConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException { | new RevealJSConverter().render(createConfiguration()); |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/RevealJSConverterTest.java | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/RevealJSConverter.java
// public class RevealJSConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "reveal-js";
//
// protected void beforeStart(final Configuration config) {
//
// config.templateFile(classpath("reveal.js/index.html"));
//
// // CSS
// config.staticFile("css", classpath("reveal.js/css/reveal.css"));
// config.staticFile("css/print", classpath("reveal.js/css/print/paper.css"));
// config.staticFile("css/print", classpath("reveal.js/css/print/pdf.css"));
// config.staticFile("css/theme", classpath("reveal.js/css/theme/simple.css"));
// config.staticFile("lib/css", classpath("reveal.js/lib/css/zenburn.css"));
//
// // JavaScript
// config.staticFile("js", classpath("reveal.js/js/reveal.min.js"));
// config.staticFile("lib/js", classpath("reveal.js/lib/js/classList.js"));
// config.staticFile("lib/js", classpath("reveal.js/lib/js/head.min.js"));
// config.staticFile("lib/js", classpath("reveal.js/lib/js/html5shiv.js"));
// config.staticFile("plugin/highlight", classpath("reveal.js/plugin/highlight/highlight.js"));
// config.staticFile("plugin/zoom-js", classpath("reveal.js/plugin/zoom-js/zoom.js"));
// config.staticFile("plugin/notes", classpath("reveal.js/plugin/notes/notes.js"));
// config.staticFile("plugin/notes", classpath("reveal.js/plugin/notes/notes.html"));
//
// }
//
// protected void transformDocument(final Document slidesDocument, final Configuration config) {
// super.transformDocument(slidesDocument, config);
// if (config.notesIncluded()) {
// for (final Element notesElement : slidesDocument.select("aside")) {
// notesElement.addClass("notes");
// }
// }
// if (config.listsIncremented()) {
// for (final Element list : slidesDocument.select("div li")) {
// list.addClass("fragment").addClass("roll-in");
// }
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://lab.hakim.se/reveal-js/";
// }
//
// }
| import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.RevealJSConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class RevealJSConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new RevealJSConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException { | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/RevealJSConverter.java
// public class RevealJSConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "reveal-js";
//
// protected void beforeStart(final Configuration config) {
//
// config.templateFile(classpath("reveal.js/index.html"));
//
// // CSS
// config.staticFile("css", classpath("reveal.js/css/reveal.css"));
// config.staticFile("css/print", classpath("reveal.js/css/print/paper.css"));
// config.staticFile("css/print", classpath("reveal.js/css/print/pdf.css"));
// config.staticFile("css/theme", classpath("reveal.js/css/theme/simple.css"));
// config.staticFile("lib/css", classpath("reveal.js/lib/css/zenburn.css"));
//
// // JavaScript
// config.staticFile("js", classpath("reveal.js/js/reveal.min.js"));
// config.staticFile("lib/js", classpath("reveal.js/lib/js/classList.js"));
// config.staticFile("lib/js", classpath("reveal.js/lib/js/head.min.js"));
// config.staticFile("lib/js", classpath("reveal.js/lib/js/html5shiv.js"));
// config.staticFile("plugin/highlight", classpath("reveal.js/plugin/highlight/highlight.js"));
// config.staticFile("plugin/zoom-js", classpath("reveal.js/plugin/zoom-js/zoom.js"));
// config.staticFile("plugin/notes", classpath("reveal.js/plugin/notes/notes.js"));
// config.staticFile("plugin/notes", classpath("reveal.js/plugin/notes/notes.html"));
//
// }
//
// protected void transformDocument(final Document slidesDocument, final Configuration config) {
// super.transformDocument(slidesDocument, config);
// if (config.notesIncluded()) {
// for (final Element notesElement : slidesDocument.select("aside")) {
// notesElement.addClass("notes");
// }
// }
// if (config.listsIncremented()) {
// for (final Element list : slidesDocument.select("div li")) {
// list.addClass("fragment").addClass("roll-in");
// }
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://lab.hakim.se/reveal-js/";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/RevealJSConverterTest.java
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.RevealJSConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class RevealJSConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new RevealJSConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException { | ConverterFactory.createConverter(RevealJSConverter.CONVERTER_ID).render(createConfiguration()); |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/PdfConverter.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import static org.apache.commons.io.FileUtils.copyFile;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.IOUtils.closeQuietly;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map.Entry;
import org.xhtmlrenderer.pdf.ITextRenderer;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.lowagie.text.DocumentException; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://itextpdf.com/">iText</a> library capable of converting
* <i>HTML</i> to <i>PDF</i>.
*
* @author Andrey Adamovich
*
*/
public class PdfConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "pdf";
| // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/PdfConverter.java
import static com.aestasit.markdown.Resources.classpath;
import static org.apache.commons.io.FileUtils.copyFile;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.IOUtils.closeQuietly;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map.Entry;
import org.xhtmlrenderer.pdf.ITextRenderer;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.lowagie.text.DocumentException;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://itextpdf.com/">iText</a> library capable of converting
* <i>HTML</i> to <i>PDF</i>.
*
* @author Andrey Adamovich
*
*/
public class PdfConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "pdf";
| protected void beforeStart(final Configuration config) { |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/PdfConverter.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import static org.apache.commons.io.FileUtils.copyFile;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.IOUtils.closeQuietly;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map.Entry;
import org.xhtmlrenderer.pdf.ITextRenderer;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.lowagie.text.DocumentException; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://itextpdf.com/">iText</a> library capable of converting
* <i>HTML</i> to <i>PDF</i>.
*
* @author Andrey Adamovich
*
*/
public class PdfConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "pdf";
protected void beforeStart(final Configuration config) {
config | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/PdfConverter.java
import static com.aestasit.markdown.Resources.classpath;
import static org.apache.commons.io.FileUtils.copyFile;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.IOUtils.closeQuietly;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map.Entry;
import org.xhtmlrenderer.pdf.ITextRenderer;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.lowagie.text.DocumentException;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://itextpdf.com/">iText</a> library capable of converting
* <i>HTML</i> to <i>PDF</i>.
*
* @author Andrey Adamovich
*
*/
public class PdfConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "pdf";
protected void beforeStart(final Configuration config) {
config | .templateFile(classpath("pdf/template.html")) |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/Converter.java | // Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Location.java
// public enum Location {
//
// HEAD_START, HEAD_END, BODY_START, SLIDES_START, SLIDES_END, BODY_END
//
// }
| import java.io.IOException;
import java.util.Collection;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.Location; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Converter interface.
*
* @author Andrey Adamovich
*
*/
public interface Converter {
void render(Configuration config) throws IOException;
String getId();
String getDescription();
Collection<String> getTransitionIds();
String getDefaultTransitionId();
Collection<String> getThemeIds();
String getDefaultThemeId();
| // Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Location.java
// public enum Location {
//
// HEAD_START, HEAD_END, BODY_START, SLIDES_START, SLIDES_END, BODY_END
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/Converter.java
import java.io.IOException;
import java.util.Collection;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.Location;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Converter interface.
*
* @author Andrey Adamovich
*
*/
public interface Converter {
void render(Configuration config) throws IOException;
String getId();
String getDescription();
Collection<String> getTransitionIds();
String getDefaultTransitionId();
Collection<String> getThemeIds();
String getDefaultThemeId();
| Collection<Location> getLocations(); |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/ShowerConverterTest.java | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ShowerConverter.java
// public class ShowerConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "shower";
//
// protected void beforeStart(final Configuration config) {
// config.templateFile(classpath("shower/template.html"));
// config.staticFile("scripts", classpath("shower/scripts/script.js"));
// config.staticFile("themes/ribbon/images", classpath("shower/themes/ribbon/images/grid.png"));
// config.staticFile("themes/ribbon/images", classpath("shower/themes/ribbon/images/linen.png"));
// config.staticFile("themes/ribbon/images", classpath("shower/themes/ribbon/images/ribbon.svg"));
// config.staticFile("themes/ribbon/styles", classpath("shower/themes/ribbon/styles/print.css"));
// config.staticFile("themes/ribbon/styles", classpath("shower/themes/ribbon/styles/reset.css"));
// config.staticFile("themes/ribbon/styles", classpath("shower/themes/ribbon/styles/style.css"));
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "https://github.com/shower/shower";
// }
//
// }
| import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.ShowerConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class ShowerConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException { | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ShowerConverter.java
// public class ShowerConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "shower";
//
// protected void beforeStart(final Configuration config) {
// config.templateFile(classpath("shower/template.html"));
// config.staticFile("scripts", classpath("shower/scripts/script.js"));
// config.staticFile("themes/ribbon/images", classpath("shower/themes/ribbon/images/grid.png"));
// config.staticFile("themes/ribbon/images", classpath("shower/themes/ribbon/images/linen.png"));
// config.staticFile("themes/ribbon/images", classpath("shower/themes/ribbon/images/ribbon.svg"));
// config.staticFile("themes/ribbon/styles", classpath("shower/themes/ribbon/styles/print.css"));
// config.staticFile("themes/ribbon/styles", classpath("shower/themes/ribbon/styles/reset.css"));
// config.staticFile("themes/ribbon/styles", classpath("shower/themes/ribbon/styles/style.css"));
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "https://github.com/shower/shower";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/ShowerConverterTest.java
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.ShowerConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class ShowerConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException { | new ShowerConverter().render(createConfiguration()); |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/ShowerConverterTest.java | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ShowerConverter.java
// public class ShowerConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "shower";
//
// protected void beforeStart(final Configuration config) {
// config.templateFile(classpath("shower/template.html"));
// config.staticFile("scripts", classpath("shower/scripts/script.js"));
// config.staticFile("themes/ribbon/images", classpath("shower/themes/ribbon/images/grid.png"));
// config.staticFile("themes/ribbon/images", classpath("shower/themes/ribbon/images/linen.png"));
// config.staticFile("themes/ribbon/images", classpath("shower/themes/ribbon/images/ribbon.svg"));
// config.staticFile("themes/ribbon/styles", classpath("shower/themes/ribbon/styles/print.css"));
// config.staticFile("themes/ribbon/styles", classpath("shower/themes/ribbon/styles/reset.css"));
// config.staticFile("themes/ribbon/styles", classpath("shower/themes/ribbon/styles/style.css"));
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "https://github.com/shower/shower";
// }
//
// }
| import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.ShowerConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class ShowerConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new ShowerConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException { | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ShowerConverter.java
// public class ShowerConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "shower";
//
// protected void beforeStart(final Configuration config) {
// config.templateFile(classpath("shower/template.html"));
// config.staticFile("scripts", classpath("shower/scripts/script.js"));
// config.staticFile("themes/ribbon/images", classpath("shower/themes/ribbon/images/grid.png"));
// config.staticFile("themes/ribbon/images", classpath("shower/themes/ribbon/images/linen.png"));
// config.staticFile("themes/ribbon/images", classpath("shower/themes/ribbon/images/ribbon.svg"));
// config.staticFile("themes/ribbon/styles", classpath("shower/themes/ribbon/styles/print.css"));
// config.staticFile("themes/ribbon/styles", classpath("shower/themes/ribbon/styles/reset.css"));
// config.staticFile("themes/ribbon/styles", classpath("shower/themes/ribbon/styles/style.css"));
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "https://github.com/shower/shower";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/ShowerConverterTest.java
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.ShowerConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class ShowerConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new ShowerConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException { | ConverterFactory.createConverter(ShowerConverter.CONVERTER_ID).render(createConfiguration()); |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/DZSlidesConverterTest.java | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/DZSlidesConverter.java
// public class DZSlidesConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "dzslides";
//
// protected void beforeStart(final Configuration config) {
// config.templateFile(classpath("dzslides/template.html"));
// config.staticFile(classpath("dzslides/onstage.html"));
// config.staticFile(classpath("dzslides/embedder.html"));
// }
//
// protected void transformDocument(final Document slidesDocument, final Configuration config) {
// super.transformDocument(slidesDocument, config);
// if (config.listsIncremented()) {
// for (final Element list : slidesDocument.select("div ul, div ol")) {
// list.addClass("incremental");
// }
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://paulrouget.com/dzslides/";
// }
//
// }
| import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.DZSlidesConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class DZSlidesConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException { | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/DZSlidesConverter.java
// public class DZSlidesConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "dzslides";
//
// protected void beforeStart(final Configuration config) {
// config.templateFile(classpath("dzslides/template.html"));
// config.staticFile(classpath("dzslides/onstage.html"));
// config.staticFile(classpath("dzslides/embedder.html"));
// }
//
// protected void transformDocument(final Document slidesDocument, final Configuration config) {
// super.transformDocument(slidesDocument, config);
// if (config.listsIncremented()) {
// for (final Element list : slidesDocument.select("div ul, div ol")) {
// list.addClass("incremental");
// }
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://paulrouget.com/dzslides/";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/DZSlidesConverterTest.java
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.DZSlidesConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class DZSlidesConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException { | new DZSlidesConverter().render(createConfiguration()); |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/DZSlidesConverterTest.java | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/DZSlidesConverter.java
// public class DZSlidesConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "dzslides";
//
// protected void beforeStart(final Configuration config) {
// config.templateFile(classpath("dzslides/template.html"));
// config.staticFile(classpath("dzslides/onstage.html"));
// config.staticFile(classpath("dzslides/embedder.html"));
// }
//
// protected void transformDocument(final Document slidesDocument, final Configuration config) {
// super.transformDocument(slidesDocument, config);
// if (config.listsIncremented()) {
// for (final Element list : slidesDocument.select("div ul, div ol")) {
// list.addClass("incremental");
// }
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://paulrouget.com/dzslides/";
// }
//
// }
| import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.DZSlidesConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class DZSlidesConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new DZSlidesConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException { | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/DZSlidesConverter.java
// public class DZSlidesConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "dzslides";
//
// protected void beforeStart(final Configuration config) {
// config.templateFile(classpath("dzslides/template.html"));
// config.staticFile(classpath("dzslides/onstage.html"));
// config.staticFile(classpath("dzslides/embedder.html"));
// }
//
// protected void transformDocument(final Document slidesDocument, final Configuration config) {
// super.transformDocument(slidesDocument, config);
// if (config.listsIncremented()) {
// for (final Element list : slidesDocument.select("div ul, div ol")) {
// list.addClass("incremental");
// }
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://paulrouget.com/dzslides/";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/DZSlidesConverterTest.java
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.DZSlidesConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class DZSlidesConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new DZSlidesConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException { | ConverterFactory.createConverter(DZSlidesConverter.CONVERTER_ID).render(createConfiguration()); |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/PdfConverterTest.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File file(final String filePath) {
// checkPath(filePath);
// return new File(filePath);
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/PdfConverter.java
// public class PdfConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "pdf";
//
// protected void beforeStart(final Configuration config) {
// config
// .templateFile(classpath("pdf/template.html"))
// .staticFile("style", classpath("pdf/style/base.css"))
// .staticFile("style", classpath("pdf/style/code.css"))
// .staticFile("style", classpath("pdf/style/pdf.css"))
// .staticFile("style", classpath("pdf/style/reset.css"));
// }
//
// protected void afterConversion(final File joinedInputFile, final Configuration config) {
// convertToPdf(config.getOutputFile());
// if (config.isSplitOutput()) {
// for (final File inputFile : config.getInputFiles()) {
// convertToPdf(getSplitOutputFile(config.getOutputFile(), inputFile));
// }
// }
// deleteStaticFiles(config);
// }
//
// private void convertToPdf(final File outputFile) {
// File tempFile = null;
// try {
// final ITextRenderer renderer = new ITextRenderer();
// renderer.setDocument(outputFile);
// renderer.layout();
// tempFile = File.createTempFile("slidery", ".pdf");
// final FileOutputStream outputStream = new FileOutputStream(tempFile);
// try {
// renderer.createPDF(outputStream, true);
// } catch (final DocumentException e) {
// throw new RuntimeException(e);
// } finally {
// closeQuietly(outputStream);
// }
// copyFile(tempFile, outputFile);
// } catch (final IOException e) {
// throw new RuntimeException(e);
// } finally {
// deleteQuietly(tempFile);
// }
// }
//
// private void deleteStaticFiles(final Configuration config) {
// final File outputDirectory = config.getOutputFile().getParentFile();
// for (final Entry<String, File> fileEntry : config.getStaticFiles().entries()) {
// final String relativePath = fileEntry.getKey();
// final String fileName = fileEntry.getValue().getName();
// deleteQuietly(new File(new File(outputDirectory, relativePath), fileName));
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "Basic PDF converter.";
// }
//
// }
| import static com.aestasit.markdown.Resources.file;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.PdfConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class PdfConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException { | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File file(final String filePath) {
// checkPath(filePath);
// return new File(filePath);
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/PdfConverter.java
// public class PdfConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "pdf";
//
// protected void beforeStart(final Configuration config) {
// config
// .templateFile(classpath("pdf/template.html"))
// .staticFile("style", classpath("pdf/style/base.css"))
// .staticFile("style", classpath("pdf/style/code.css"))
// .staticFile("style", classpath("pdf/style/pdf.css"))
// .staticFile("style", classpath("pdf/style/reset.css"));
// }
//
// protected void afterConversion(final File joinedInputFile, final Configuration config) {
// convertToPdf(config.getOutputFile());
// if (config.isSplitOutput()) {
// for (final File inputFile : config.getInputFiles()) {
// convertToPdf(getSplitOutputFile(config.getOutputFile(), inputFile));
// }
// }
// deleteStaticFiles(config);
// }
//
// private void convertToPdf(final File outputFile) {
// File tempFile = null;
// try {
// final ITextRenderer renderer = new ITextRenderer();
// renderer.setDocument(outputFile);
// renderer.layout();
// tempFile = File.createTempFile("slidery", ".pdf");
// final FileOutputStream outputStream = new FileOutputStream(tempFile);
// try {
// renderer.createPDF(outputStream, true);
// } catch (final DocumentException e) {
// throw new RuntimeException(e);
// } finally {
// closeQuietly(outputStream);
// }
// copyFile(tempFile, outputFile);
// } catch (final IOException e) {
// throw new RuntimeException(e);
// } finally {
// deleteQuietly(tempFile);
// }
// }
//
// private void deleteStaticFiles(final Configuration config) {
// final File outputDirectory = config.getOutputFile().getParentFile();
// for (final Entry<String, File> fileEntry : config.getStaticFiles().entries()) {
// final String relativePath = fileEntry.getKey();
// final String fileName = fileEntry.getValue().getName();
// deleteQuietly(new File(new File(outputDirectory, relativePath), fileName));
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "Basic PDF converter.";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/PdfConverterTest.java
import static com.aestasit.markdown.Resources.file;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.PdfConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class PdfConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException { | new PdfConverter().render(createConfiguration()); |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/PdfConverterTest.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File file(final String filePath) {
// checkPath(filePath);
// return new File(filePath);
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/PdfConverter.java
// public class PdfConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "pdf";
//
// protected void beforeStart(final Configuration config) {
// config
// .templateFile(classpath("pdf/template.html"))
// .staticFile("style", classpath("pdf/style/base.css"))
// .staticFile("style", classpath("pdf/style/code.css"))
// .staticFile("style", classpath("pdf/style/pdf.css"))
// .staticFile("style", classpath("pdf/style/reset.css"));
// }
//
// protected void afterConversion(final File joinedInputFile, final Configuration config) {
// convertToPdf(config.getOutputFile());
// if (config.isSplitOutput()) {
// for (final File inputFile : config.getInputFiles()) {
// convertToPdf(getSplitOutputFile(config.getOutputFile(), inputFile));
// }
// }
// deleteStaticFiles(config);
// }
//
// private void convertToPdf(final File outputFile) {
// File tempFile = null;
// try {
// final ITextRenderer renderer = new ITextRenderer();
// renderer.setDocument(outputFile);
// renderer.layout();
// tempFile = File.createTempFile("slidery", ".pdf");
// final FileOutputStream outputStream = new FileOutputStream(tempFile);
// try {
// renderer.createPDF(outputStream, true);
// } catch (final DocumentException e) {
// throw new RuntimeException(e);
// } finally {
// closeQuietly(outputStream);
// }
// copyFile(tempFile, outputFile);
// } catch (final IOException e) {
// throw new RuntimeException(e);
// } finally {
// deleteQuietly(tempFile);
// }
// }
//
// private void deleteStaticFiles(final Configuration config) {
// final File outputDirectory = config.getOutputFile().getParentFile();
// for (final Entry<String, File> fileEntry : config.getStaticFiles().entries()) {
// final String relativePath = fileEntry.getKey();
// final String fileName = fileEntry.getValue().getName();
// deleteQuietly(new File(new File(outputDirectory, relativePath), fileName));
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "Basic PDF converter.";
// }
//
// }
| import static com.aestasit.markdown.Resources.file;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.PdfConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class PdfConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new PdfConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException { | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File file(final String filePath) {
// checkPath(filePath);
// return new File(filePath);
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/PdfConverter.java
// public class PdfConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "pdf";
//
// protected void beforeStart(final Configuration config) {
// config
// .templateFile(classpath("pdf/template.html"))
// .staticFile("style", classpath("pdf/style/base.css"))
// .staticFile("style", classpath("pdf/style/code.css"))
// .staticFile("style", classpath("pdf/style/pdf.css"))
// .staticFile("style", classpath("pdf/style/reset.css"));
// }
//
// protected void afterConversion(final File joinedInputFile, final Configuration config) {
// convertToPdf(config.getOutputFile());
// if (config.isSplitOutput()) {
// for (final File inputFile : config.getInputFiles()) {
// convertToPdf(getSplitOutputFile(config.getOutputFile(), inputFile));
// }
// }
// deleteStaticFiles(config);
// }
//
// private void convertToPdf(final File outputFile) {
// File tempFile = null;
// try {
// final ITextRenderer renderer = new ITextRenderer();
// renderer.setDocument(outputFile);
// renderer.layout();
// tempFile = File.createTempFile("slidery", ".pdf");
// final FileOutputStream outputStream = new FileOutputStream(tempFile);
// try {
// renderer.createPDF(outputStream, true);
// } catch (final DocumentException e) {
// throw new RuntimeException(e);
// } finally {
// closeQuietly(outputStream);
// }
// copyFile(tempFile, outputFile);
// } catch (final IOException e) {
// throw new RuntimeException(e);
// } finally {
// deleteQuietly(tempFile);
// }
// }
//
// private void deleteStaticFiles(final Configuration config) {
// final File outputDirectory = config.getOutputFile().getParentFile();
// for (final Entry<String, File> fileEntry : config.getStaticFiles().entries()) {
// final String relativePath = fileEntry.getKey();
// final String fileName = fileEntry.getValue().getName();
// deleteQuietly(new File(new File(outputDirectory, relativePath), fileName));
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "Basic PDF converter.";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/PdfConverterTest.java
import static com.aestasit.markdown.Resources.file;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.PdfConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class PdfConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new PdfConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException { | ConverterFactory.createConverter(PdfConverter.CONVERTER_ID).render(createConfiguration()); |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/PdfConverterTest.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File file(final String filePath) {
// checkPath(filePath);
// return new File(filePath);
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/PdfConverter.java
// public class PdfConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "pdf";
//
// protected void beforeStart(final Configuration config) {
// config
// .templateFile(classpath("pdf/template.html"))
// .staticFile("style", classpath("pdf/style/base.css"))
// .staticFile("style", classpath("pdf/style/code.css"))
// .staticFile("style", classpath("pdf/style/pdf.css"))
// .staticFile("style", classpath("pdf/style/reset.css"));
// }
//
// protected void afterConversion(final File joinedInputFile, final Configuration config) {
// convertToPdf(config.getOutputFile());
// if (config.isSplitOutput()) {
// for (final File inputFile : config.getInputFiles()) {
// convertToPdf(getSplitOutputFile(config.getOutputFile(), inputFile));
// }
// }
// deleteStaticFiles(config);
// }
//
// private void convertToPdf(final File outputFile) {
// File tempFile = null;
// try {
// final ITextRenderer renderer = new ITextRenderer();
// renderer.setDocument(outputFile);
// renderer.layout();
// tempFile = File.createTempFile("slidery", ".pdf");
// final FileOutputStream outputStream = new FileOutputStream(tempFile);
// try {
// renderer.createPDF(outputStream, true);
// } catch (final DocumentException e) {
// throw new RuntimeException(e);
// } finally {
// closeQuietly(outputStream);
// }
// copyFile(tempFile, outputFile);
// } catch (final IOException e) {
// throw new RuntimeException(e);
// } finally {
// deleteQuietly(tempFile);
// }
// }
//
// private void deleteStaticFiles(final Configuration config) {
// final File outputDirectory = config.getOutputFile().getParentFile();
// for (final Entry<String, File> fileEntry : config.getStaticFiles().entries()) {
// final String relativePath = fileEntry.getKey();
// final String fileName = fileEntry.getValue().getName();
// deleteQuietly(new File(new File(outputDirectory, relativePath), fileName));
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "Basic PDF converter.";
// }
//
// }
| import static com.aestasit.markdown.Resources.file;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.PdfConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class PdfConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new PdfConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException {
ConverterFactory.createConverter(PdfConverter.CONVERTER_ID).render(createConfiguration());
}
@Override | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File file(final String filePath) {
// checkPath(filePath);
// return new File(filePath);
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/PdfConverter.java
// public class PdfConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "pdf";
//
// protected void beforeStart(final Configuration config) {
// config
// .templateFile(classpath("pdf/template.html"))
// .staticFile("style", classpath("pdf/style/base.css"))
// .staticFile("style", classpath("pdf/style/code.css"))
// .staticFile("style", classpath("pdf/style/pdf.css"))
// .staticFile("style", classpath("pdf/style/reset.css"));
// }
//
// protected void afterConversion(final File joinedInputFile, final Configuration config) {
// convertToPdf(config.getOutputFile());
// if (config.isSplitOutput()) {
// for (final File inputFile : config.getInputFiles()) {
// convertToPdf(getSplitOutputFile(config.getOutputFile(), inputFile));
// }
// }
// deleteStaticFiles(config);
// }
//
// private void convertToPdf(final File outputFile) {
// File tempFile = null;
// try {
// final ITextRenderer renderer = new ITextRenderer();
// renderer.setDocument(outputFile);
// renderer.layout();
// tempFile = File.createTempFile("slidery", ".pdf");
// final FileOutputStream outputStream = new FileOutputStream(tempFile);
// try {
// renderer.createPDF(outputStream, true);
// } catch (final DocumentException e) {
// throw new RuntimeException(e);
// } finally {
// closeQuietly(outputStream);
// }
// copyFile(tempFile, outputFile);
// } catch (final IOException e) {
// throw new RuntimeException(e);
// } finally {
// deleteQuietly(tempFile);
// }
// }
//
// private void deleteStaticFiles(final Configuration config) {
// final File outputDirectory = config.getOutputFile().getParentFile();
// for (final Entry<String, File> fileEntry : config.getStaticFiles().entries()) {
// final String relativePath = fileEntry.getKey();
// final String fileName = fileEntry.getValue().getName();
// deleteQuietly(new File(new File(outputDirectory, relativePath), fileName));
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "Basic PDF converter.";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/PdfConverterTest.java
import static com.aestasit.markdown.Resources.file;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.PdfConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class PdfConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new PdfConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException {
ConverterFactory.createConverter(PdfConverter.CONVERTER_ID).render(createConfiguration());
}
@Override | protected Configuration createConfiguration() { |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/PdfConverterTest.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File file(final String filePath) {
// checkPath(filePath);
// return new File(filePath);
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/PdfConverter.java
// public class PdfConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "pdf";
//
// protected void beforeStart(final Configuration config) {
// config
// .templateFile(classpath("pdf/template.html"))
// .staticFile("style", classpath("pdf/style/base.css"))
// .staticFile("style", classpath("pdf/style/code.css"))
// .staticFile("style", classpath("pdf/style/pdf.css"))
// .staticFile("style", classpath("pdf/style/reset.css"));
// }
//
// protected void afterConversion(final File joinedInputFile, final Configuration config) {
// convertToPdf(config.getOutputFile());
// if (config.isSplitOutput()) {
// for (final File inputFile : config.getInputFiles()) {
// convertToPdf(getSplitOutputFile(config.getOutputFile(), inputFile));
// }
// }
// deleteStaticFiles(config);
// }
//
// private void convertToPdf(final File outputFile) {
// File tempFile = null;
// try {
// final ITextRenderer renderer = new ITextRenderer();
// renderer.setDocument(outputFile);
// renderer.layout();
// tempFile = File.createTempFile("slidery", ".pdf");
// final FileOutputStream outputStream = new FileOutputStream(tempFile);
// try {
// renderer.createPDF(outputStream, true);
// } catch (final DocumentException e) {
// throw new RuntimeException(e);
// } finally {
// closeQuietly(outputStream);
// }
// copyFile(tempFile, outputFile);
// } catch (final IOException e) {
// throw new RuntimeException(e);
// } finally {
// deleteQuietly(tempFile);
// }
// }
//
// private void deleteStaticFiles(final Configuration config) {
// final File outputDirectory = config.getOutputFile().getParentFile();
// for (final Entry<String, File> fileEntry : config.getStaticFiles().entries()) {
// final String relativePath = fileEntry.getKey();
// final String fileName = fileEntry.getValue().getName();
// deleteQuietly(new File(new File(outputDirectory, relativePath), fileName));
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "Basic PDF converter.";
// }
//
// }
| import static com.aestasit.markdown.Resources.file;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.PdfConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class PdfConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new PdfConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException {
ConverterFactory.createConverter(PdfConverter.CONVERTER_ID).render(createConfiguration());
}
@Override
protected Configuration createConfiguration() {
return super
.createConfiguration() | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File file(final String filePath) {
// checkPath(filePath);
// return new File(filePath);
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/PdfConverter.java
// public class PdfConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "pdf";
//
// protected void beforeStart(final Configuration config) {
// config
// .templateFile(classpath("pdf/template.html"))
// .staticFile("style", classpath("pdf/style/base.css"))
// .staticFile("style", classpath("pdf/style/code.css"))
// .staticFile("style", classpath("pdf/style/pdf.css"))
// .staticFile("style", classpath("pdf/style/reset.css"));
// }
//
// protected void afterConversion(final File joinedInputFile, final Configuration config) {
// convertToPdf(config.getOutputFile());
// if (config.isSplitOutput()) {
// for (final File inputFile : config.getInputFiles()) {
// convertToPdf(getSplitOutputFile(config.getOutputFile(), inputFile));
// }
// }
// deleteStaticFiles(config);
// }
//
// private void convertToPdf(final File outputFile) {
// File tempFile = null;
// try {
// final ITextRenderer renderer = new ITextRenderer();
// renderer.setDocument(outputFile);
// renderer.layout();
// tempFile = File.createTempFile("slidery", ".pdf");
// final FileOutputStream outputStream = new FileOutputStream(tempFile);
// try {
// renderer.createPDF(outputStream, true);
// } catch (final DocumentException e) {
// throw new RuntimeException(e);
// } finally {
// closeQuietly(outputStream);
// }
// copyFile(tempFile, outputFile);
// } catch (final IOException e) {
// throw new RuntimeException(e);
// } finally {
// deleteQuietly(tempFile);
// }
// }
//
// private void deleteStaticFiles(final Configuration config) {
// final File outputDirectory = config.getOutputFile().getParentFile();
// for (final Entry<String, File> fileEntry : config.getStaticFiles().entries()) {
// final String relativePath = fileEntry.getKey();
// final String fileName = fileEntry.getValue().getName();
// deleteQuietly(new File(new File(outputDirectory, relativePath), fileName));
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "Basic PDF converter.";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/PdfConverterTest.java
import static com.aestasit.markdown.Resources.file;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.PdfConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class PdfConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new PdfConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException {
ConverterFactory.createConverter(PdfConverter.CONVERTER_ID).render(createConfiguration());
}
@Override
protected Configuration createConfiguration() {
return super
.createConfiguration() | .outputFile(file("./tmp/presentation.pdf")); |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/ToHtmlSlides.java | // Path: src/main/java/com/aestasit/markdown/visitors/BaseVisitor.java
// public abstract class BaseVisitor implements Visitor {
//
// protected int level = 0;
// protected final static Logger LOG = LoggerFactory.getLogger(BaseVisitor.class);
//
// protected void visitChildren(final Node node) {
// level++;
// for (final Node child : node.getChildren()) {
// if (child instanceof RootNode) {
// visitChildren(child);
// } else {
// child.accept(this);
// }
// }
// level--;
// }
//
// protected void unknownNode(final Node node) {
// LOG.error(">>> UNKNOWN NODE: " + node);
// }
//
// protected void logNode(Node node) {
// LOG.debug(StringUtils.repeat(" ", level) + node.toString());
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/ToHtmlSlides.java
// protected enum SlideComponent {
// NONE, CONTENT, NOTES
// }
| import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.parboiled.common.StringUtils;
import org.pegdown.LinkRenderer;
import org.pegdown.Printer;
import org.pegdown.ast.AbbreviationNode;
import org.pegdown.ast.AutoLinkNode;
import org.pegdown.ast.BlockQuoteNode;
import org.pegdown.ast.BulletListNode;
import org.pegdown.ast.CodeNode;
import org.pegdown.ast.DefinitionListNode;
import org.pegdown.ast.DefinitionNode;
import org.pegdown.ast.DefinitionTermNode;
import org.pegdown.ast.EmphNode;
import org.pegdown.ast.ExpImageNode;
import org.pegdown.ast.ExpLinkNode;
import org.pegdown.ast.HeaderNode;
import org.pegdown.ast.HtmlBlockNode;
import org.pegdown.ast.InlineHtmlNode;
import org.pegdown.ast.ListItemNode;
import org.pegdown.ast.MailLinkNode;
import org.pegdown.ast.Node;
import org.pegdown.ast.OrderedListNode;
import org.pegdown.ast.ParaNode;
import org.pegdown.ast.QuotedNode;
import org.pegdown.ast.RefImageNode;
import org.pegdown.ast.RefLinkNode;
import org.pegdown.ast.ReferenceNode;
import org.pegdown.ast.RootNode;
import org.pegdown.ast.SimpleNode;
import org.pegdown.ast.SpecialTextNode;
import org.pegdown.ast.StrongNode;
import org.pegdown.ast.SuperNode;
import org.pegdown.ast.TableBodyNode;
import org.pegdown.ast.TableCellNode;
import org.pegdown.ast.TableColumnNode;
import org.pegdown.ast.TableHeaderNode;
import org.pegdown.ast.TableNode;
import org.pegdown.ast.TableRowNode;
import org.pegdown.ast.TextNode;
import org.pegdown.ast.VerbatimNode;
import org.pegdown.ast.Visitor;
import org.pegdown.ast.WikiLinkNode;
import com.aestasit.markdown.visitors.BaseVisitor;
import com.google.common.base.Preconditions;
import static com.aestasit.markdown.slidery.ToHtmlSlides.SlideComponent.*; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery;
/**
* <p>
* {@link Visitor} pattern implementation that walks through <i>AST</i> created by <a
* href="https://github.com/sirthias/pegdown">Pegdown</a> parsing library and produces structured output with the help
* of <i>HTML5</i> tags:
* </p>
*
* <pre>
* <body>
* <section>
* <header> ...slide title... </header>
* <div> ...slide content... </div>
* <aside> ...slide notes... </aside>
* </section>
* ...
* </body>
* </pre>
*
* <p>
* Code of this class is largely based on the code of <a
* href="https://raw.github.com/sirthias/pegdown/master/src/main/java/org/pegdown/ToHtmlSerializer.java"
* >ToHtmlSerializer</a> from <a href="https://github.com/sirthias/pegdown">Pegdown</a> parser library.
* </p>
*
* @author Andrey Adamovich
*
*/
public class ToHtmlSlides extends BaseVisitor implements Visitor {
protected Printer printer = new Printer();
// Link output handling.
protected final Map<String, ReferenceNode> references = new HashMap<String, ReferenceNode>();
protected final Map<String, String> abbreviations = new HashMap<String, String>();
protected final LinkRenderer linkRenderer;
// Table output handling.
protected TableNode currentTableNode;
protected int currentTableColumn;
protected boolean inTableHeader;
// Slide output handling.
private boolean inFirstSlide; | // Path: src/main/java/com/aestasit/markdown/visitors/BaseVisitor.java
// public abstract class BaseVisitor implements Visitor {
//
// protected int level = 0;
// protected final static Logger LOG = LoggerFactory.getLogger(BaseVisitor.class);
//
// protected void visitChildren(final Node node) {
// level++;
// for (final Node child : node.getChildren()) {
// if (child instanceof RootNode) {
// visitChildren(child);
// } else {
// child.accept(this);
// }
// }
// level--;
// }
//
// protected void unknownNode(final Node node) {
// LOG.error(">>> UNKNOWN NODE: " + node);
// }
//
// protected void logNode(Node node) {
// LOG.debug(StringUtils.repeat(" ", level) + node.toString());
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/ToHtmlSlides.java
// protected enum SlideComponent {
// NONE, CONTENT, NOTES
// }
// Path: src/main/java/com/aestasit/markdown/slidery/ToHtmlSlides.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.parboiled.common.StringUtils;
import org.pegdown.LinkRenderer;
import org.pegdown.Printer;
import org.pegdown.ast.AbbreviationNode;
import org.pegdown.ast.AutoLinkNode;
import org.pegdown.ast.BlockQuoteNode;
import org.pegdown.ast.BulletListNode;
import org.pegdown.ast.CodeNode;
import org.pegdown.ast.DefinitionListNode;
import org.pegdown.ast.DefinitionNode;
import org.pegdown.ast.DefinitionTermNode;
import org.pegdown.ast.EmphNode;
import org.pegdown.ast.ExpImageNode;
import org.pegdown.ast.ExpLinkNode;
import org.pegdown.ast.HeaderNode;
import org.pegdown.ast.HtmlBlockNode;
import org.pegdown.ast.InlineHtmlNode;
import org.pegdown.ast.ListItemNode;
import org.pegdown.ast.MailLinkNode;
import org.pegdown.ast.Node;
import org.pegdown.ast.OrderedListNode;
import org.pegdown.ast.ParaNode;
import org.pegdown.ast.QuotedNode;
import org.pegdown.ast.RefImageNode;
import org.pegdown.ast.RefLinkNode;
import org.pegdown.ast.ReferenceNode;
import org.pegdown.ast.RootNode;
import org.pegdown.ast.SimpleNode;
import org.pegdown.ast.SpecialTextNode;
import org.pegdown.ast.StrongNode;
import org.pegdown.ast.SuperNode;
import org.pegdown.ast.TableBodyNode;
import org.pegdown.ast.TableCellNode;
import org.pegdown.ast.TableColumnNode;
import org.pegdown.ast.TableHeaderNode;
import org.pegdown.ast.TableNode;
import org.pegdown.ast.TableRowNode;
import org.pegdown.ast.TextNode;
import org.pegdown.ast.VerbatimNode;
import org.pegdown.ast.Visitor;
import org.pegdown.ast.WikiLinkNode;
import com.aestasit.markdown.visitors.BaseVisitor;
import com.google.common.base.Preconditions;
import static com.aestasit.markdown.slidery.ToHtmlSlides.SlideComponent.*;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery;
/**
* <p>
* {@link Visitor} pattern implementation that walks through <i>AST</i> created by <a
* href="https://github.com/sirthias/pegdown">Pegdown</a> parsing library and produces structured output with the help
* of <i>HTML5</i> tags:
* </p>
*
* <pre>
* <body>
* <section>
* <header> ...slide title... </header>
* <div> ...slide content... </div>
* <aside> ...slide notes... </aside>
* </section>
* ...
* </body>
* </pre>
*
* <p>
* Code of this class is largely based on the code of <a
* href="https://raw.github.com/sirthias/pegdown/master/src/main/java/org/pegdown/ToHtmlSerializer.java"
* >ToHtmlSerializer</a> from <a href="https://github.com/sirthias/pegdown">Pegdown</a> parser library.
* </p>
*
* @author Andrey Adamovich
*
*/
public class ToHtmlSlides extends BaseVisitor implements Visitor {
protected Printer printer = new Printer();
// Link output handling.
protected final Map<String, ReferenceNode> references = new HashMap<String, ReferenceNode>();
protected final Map<String, String> abbreviations = new HashMap<String, String>();
protected final LinkRenderer linkRenderer;
// Table output handling.
protected TableNode currentTableNode;
protected int currentTableColumn;
protected boolean inTableHeader;
// Slide output handling.
private boolean inFirstSlide; | private SlideComponent currentSlideComponent; |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/DeckJSConverterTest.java | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/DeckJSConverter.java
// public class DeckJSConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "deck-js";
//
// protected void beforeStart(final Configuration config) {
//
// config.templateFile(classpath("deck.js/boilerplate.html"));
//
// config.staticFile(classpath("deck.js/jquery-1.7.2.min.js"));
// config.staticFile(classpath("deck.js/modernizr.custom.js"));
//
// config.staticFile("core", classpath("deck.js/core/deck.core.css"));
// config.staticFile("core", classpath("deck.js/core/deck.core.js"));
//
// addExtension(config, "status");
// addExtension(config, "scale");
// addExtension(config, "navigation");
// addExtension(config, "hash");
// addExtension(config, "goto");
// addExtension(config, "menu");
//
// if (config.getLogo() != null) {
// addCssExtension(config, "logo");
// }
// addCssExtension(config, "title");
// addCssExtension(config, "highlight");
//
// if (isBlank(config.getTheme())) {
// config.theme("web-2.0");
// }
//
// config.staticFile("themes/style", classpath("deck.js/themes/style/" + config.getTheme() + ".css"));
// config.staticFile("themes/transition", classpath("deck.js/themes/transition/horizontal-slide.css"));
//
// }
//
// private void addExtension(final ConfigurationBuilder config, final String extension) {
// final String basePath = baseExtensionPath(extension);
// config.staticFile("extensions/" + extension, classpath(basePath + ".css"));
// config.staticFile("extensions/" + extension, classpath(basePath + ".js"));
// }
//
// private String baseExtensionPath(final String extension) {
// return "deck.js/extensions/" + extension + "/deck." + extension;
// }
//
// private void addCssExtension(final ConfigurationBuilder config, final String extension) {
// final String basePath = baseExtensionPath(extension);
// config.staticFile("extensions/" + extension, classpath(basePath + ".css"));
// }
//
// protected void transformDocument(final Document slidesDocument, final Configuration config) {
// super.transformDocument(slidesDocument, config);
// if (config.listsIncremented()) {
// for (final Element list : slidesDocument.select("div li")) {
// list.addClass("slide");
// }
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://imakewebthings.com/deck.js/";
// }
//
// }
| import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.DeckJSConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class DeckJSConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException { | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/DeckJSConverter.java
// public class DeckJSConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "deck-js";
//
// protected void beforeStart(final Configuration config) {
//
// config.templateFile(classpath("deck.js/boilerplate.html"));
//
// config.staticFile(classpath("deck.js/jquery-1.7.2.min.js"));
// config.staticFile(classpath("deck.js/modernizr.custom.js"));
//
// config.staticFile("core", classpath("deck.js/core/deck.core.css"));
// config.staticFile("core", classpath("deck.js/core/deck.core.js"));
//
// addExtension(config, "status");
// addExtension(config, "scale");
// addExtension(config, "navigation");
// addExtension(config, "hash");
// addExtension(config, "goto");
// addExtension(config, "menu");
//
// if (config.getLogo() != null) {
// addCssExtension(config, "logo");
// }
// addCssExtension(config, "title");
// addCssExtension(config, "highlight");
//
// if (isBlank(config.getTheme())) {
// config.theme("web-2.0");
// }
//
// config.staticFile("themes/style", classpath("deck.js/themes/style/" + config.getTheme() + ".css"));
// config.staticFile("themes/transition", classpath("deck.js/themes/transition/horizontal-slide.css"));
//
// }
//
// private void addExtension(final ConfigurationBuilder config, final String extension) {
// final String basePath = baseExtensionPath(extension);
// config.staticFile("extensions/" + extension, classpath(basePath + ".css"));
// config.staticFile("extensions/" + extension, classpath(basePath + ".js"));
// }
//
// private String baseExtensionPath(final String extension) {
// return "deck.js/extensions/" + extension + "/deck." + extension;
// }
//
// private void addCssExtension(final ConfigurationBuilder config, final String extension) {
// final String basePath = baseExtensionPath(extension);
// config.staticFile("extensions/" + extension, classpath(basePath + ".css"));
// }
//
// protected void transformDocument(final Document slidesDocument, final Configuration config) {
// super.transformDocument(slidesDocument, config);
// if (config.listsIncremented()) {
// for (final Element list : slidesDocument.select("div li")) {
// list.addClass("slide");
// }
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://imakewebthings.com/deck.js/";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/DeckJSConverterTest.java
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.DeckJSConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class DeckJSConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException { | new DeckJSConverter().render(createConfiguration()); |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/DeckJSConverterTest.java | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/DeckJSConverter.java
// public class DeckJSConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "deck-js";
//
// protected void beforeStart(final Configuration config) {
//
// config.templateFile(classpath("deck.js/boilerplate.html"));
//
// config.staticFile(classpath("deck.js/jquery-1.7.2.min.js"));
// config.staticFile(classpath("deck.js/modernizr.custom.js"));
//
// config.staticFile("core", classpath("deck.js/core/deck.core.css"));
// config.staticFile("core", classpath("deck.js/core/deck.core.js"));
//
// addExtension(config, "status");
// addExtension(config, "scale");
// addExtension(config, "navigation");
// addExtension(config, "hash");
// addExtension(config, "goto");
// addExtension(config, "menu");
//
// if (config.getLogo() != null) {
// addCssExtension(config, "logo");
// }
// addCssExtension(config, "title");
// addCssExtension(config, "highlight");
//
// if (isBlank(config.getTheme())) {
// config.theme("web-2.0");
// }
//
// config.staticFile("themes/style", classpath("deck.js/themes/style/" + config.getTheme() + ".css"));
// config.staticFile("themes/transition", classpath("deck.js/themes/transition/horizontal-slide.css"));
//
// }
//
// private void addExtension(final ConfigurationBuilder config, final String extension) {
// final String basePath = baseExtensionPath(extension);
// config.staticFile("extensions/" + extension, classpath(basePath + ".css"));
// config.staticFile("extensions/" + extension, classpath(basePath + ".js"));
// }
//
// private String baseExtensionPath(final String extension) {
// return "deck.js/extensions/" + extension + "/deck." + extension;
// }
//
// private void addCssExtension(final ConfigurationBuilder config, final String extension) {
// final String basePath = baseExtensionPath(extension);
// config.staticFile("extensions/" + extension, classpath(basePath + ".css"));
// }
//
// protected void transformDocument(final Document slidesDocument, final Configuration config) {
// super.transformDocument(slidesDocument, config);
// if (config.listsIncremented()) {
// for (final Element list : slidesDocument.select("div li")) {
// list.addClass("slide");
// }
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://imakewebthings.com/deck.js/";
// }
//
// }
| import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.DeckJSConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class DeckJSConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new DeckJSConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException { | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/DeckJSConverter.java
// public class DeckJSConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "deck-js";
//
// protected void beforeStart(final Configuration config) {
//
// config.templateFile(classpath("deck.js/boilerplate.html"));
//
// config.staticFile(classpath("deck.js/jquery-1.7.2.min.js"));
// config.staticFile(classpath("deck.js/modernizr.custom.js"));
//
// config.staticFile("core", classpath("deck.js/core/deck.core.css"));
// config.staticFile("core", classpath("deck.js/core/deck.core.js"));
//
// addExtension(config, "status");
// addExtension(config, "scale");
// addExtension(config, "navigation");
// addExtension(config, "hash");
// addExtension(config, "goto");
// addExtension(config, "menu");
//
// if (config.getLogo() != null) {
// addCssExtension(config, "logo");
// }
// addCssExtension(config, "title");
// addCssExtension(config, "highlight");
//
// if (isBlank(config.getTheme())) {
// config.theme("web-2.0");
// }
//
// config.staticFile("themes/style", classpath("deck.js/themes/style/" + config.getTheme() + ".css"));
// config.staticFile("themes/transition", classpath("deck.js/themes/transition/horizontal-slide.css"));
//
// }
//
// private void addExtension(final ConfigurationBuilder config, final String extension) {
// final String basePath = baseExtensionPath(extension);
// config.staticFile("extensions/" + extension, classpath(basePath + ".css"));
// config.staticFile("extensions/" + extension, classpath(basePath + ".js"));
// }
//
// private String baseExtensionPath(final String extension) {
// return "deck.js/extensions/" + extension + "/deck." + extension;
// }
//
// private void addCssExtension(final ConfigurationBuilder config, final String extension) {
// final String basePath = baseExtensionPath(extension);
// config.staticFile("extensions/" + extension, classpath(basePath + ".css"));
// }
//
// protected void transformDocument(final Document slidesDocument, final Configuration config) {
// super.transformDocument(slidesDocument, config);
// if (config.listsIncremented()) {
// for (final Element list : slidesDocument.select("div li")) {
// list.addClass("slide");
// }
// }
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://imakewebthings.com/deck.js/";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/DeckJSConverterTest.java
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.DeckJSConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class DeckJSConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new DeckJSConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException { | ConverterFactory.createConverter(DeckJSConverter.CONVERTER_ID).render(createConfiguration()); |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/SlideryTest.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static String toSlides(RootNode node) {
// Preconditions.checkNotNull(node, "astRoot");
// return getConverter().toHtml(node);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import static com.aestasit.markdown.slidery.Slidery.toSlides;
import static org.jsoup.Jsoup.isValid;
import static org.jsoup.safety.Whitelist.relaxed;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import com.aestasit.markdown.BaseTest; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery;
/**
* @author Andrey Adamovich
*
*/
public class SlideryTest extends BaseTest {
@Test
public void testLoadingMethods() throws IOException {
// from InputStream | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static String toSlides(RootNode node) {
// Preconditions.checkNotNull(node, "astRoot");
// return getConverter().toHtml(node);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/SlideryTest.java
import static com.aestasit.markdown.Resources.classpath;
import static com.aestasit.markdown.slidery.Slidery.toSlides;
import static org.jsoup.Jsoup.isValid;
import static org.jsoup.safety.Whitelist.relaxed;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import com.aestasit.markdown.BaseTest;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery;
/**
* @author Andrey Adamovich
*
*/
public class SlideryTest extends BaseTest {
@Test
public void testLoadingMethods() throws IOException {
// from InputStream | validateSlides(toSlides(allTestData())); |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/SlideryTest.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static String toSlides(RootNode node) {
// Preconditions.checkNotNull(node, "astRoot");
// return getConverter().toHtml(node);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import static com.aestasit.markdown.slidery.Slidery.toSlides;
import static org.jsoup.Jsoup.isValid;
import static org.jsoup.safety.Whitelist.relaxed;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import com.aestasit.markdown.BaseTest; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery;
/**
* @author Andrey Adamovich
*
*/
public class SlideryTest extends BaseTest {
@Test
public void testLoadingMethods() throws IOException {
// from InputStream
validateSlides(toSlides(allTestData()));
// from File
validateSlides(toSlides(allTestData()));
// from URL | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static String toSlides(RootNode node) {
// Preconditions.checkNotNull(node, "astRoot");
// return getConverter().toHtml(node);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/SlideryTest.java
import static com.aestasit.markdown.Resources.classpath;
import static com.aestasit.markdown.slidery.Slidery.toSlides;
import static org.jsoup.Jsoup.isValid;
import static org.jsoup.safety.Whitelist.relaxed;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import com.aestasit.markdown.BaseTest;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery;
/**
* @author Andrey Adamovich
*
*/
public class SlideryTest extends BaseTest {
@Test
public void testLoadingMethods() throws IOException {
// from InputStream
validateSlides(toSlides(allTestData()));
// from File
validateSlides(toSlides(allTestData()));
// from URL | validateSlides(toSlides(classpath("01_simple_slides.md").toURI().toURL())); |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/DZSlidesConverter.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://paulrouget.com/dzslides/">DZSlides</a> framework.
*
* @author Andrey Adamovich
*
*/
public class DZSlidesConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "dzslides";
| // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/DZSlidesConverter.java
import static com.aestasit.markdown.Resources.classpath;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://paulrouget.com/dzslides/">DZSlides</a> framework.
*
* @author Andrey Adamovich
*
*/
public class DZSlidesConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "dzslides";
| protected void beforeStart(final Configuration config) { |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/DZSlidesConverter.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://paulrouget.com/dzslides/">DZSlides</a> framework.
*
* @author Andrey Adamovich
*
*/
public class DZSlidesConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "dzslides";
protected void beforeStart(final Configuration config) { | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/DZSlidesConverter.java
import static com.aestasit.markdown.Resources.classpath;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://paulrouget.com/dzslides/">DZSlides</a> framework.
*
* @author Andrey Adamovich
*
*/
public class DZSlidesConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "dzslides";
protected void beforeStart(final Configuration config) { | config.templateFile(classpath("dzslides/template.html")); |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/DeckJSConverter.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import static org.apache.commons.lang3.StringUtils.isBlank;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://imakewebthings.com/deck.js/">deck.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class DeckJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "deck-js";
| // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/DeckJSConverter.java
import static com.aestasit.markdown.Resources.classpath;
import static org.apache.commons.lang3.StringUtils.isBlank;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://imakewebthings.com/deck.js/">deck.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class DeckJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "deck-js";
| protected void beforeStart(final Configuration config) { |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/DeckJSConverter.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import static org.apache.commons.lang3.StringUtils.isBlank;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://imakewebthings.com/deck.js/">deck.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class DeckJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "deck-js";
protected void beforeStart(final Configuration config) {
| // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/DeckJSConverter.java
import static com.aestasit.markdown.Resources.classpath;
import static org.apache.commons.lang3.StringUtils.isBlank;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://imakewebthings.com/deck.js/">deck.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class DeckJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "deck-js";
protected void beforeStart(final Configuration config) {
| config.templateFile(classpath("deck.js/boilerplate.html")); |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/DeckJSConverter.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import static org.apache.commons.lang3.StringUtils.isBlank;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://imakewebthings.com/deck.js/">deck.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class DeckJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "deck-js";
protected void beforeStart(final Configuration config) {
config.templateFile(classpath("deck.js/boilerplate.html"));
config.staticFile(classpath("deck.js/jquery-1.7.2.min.js"));
config.staticFile(classpath("deck.js/modernizr.custom.js"));
config.staticFile("core", classpath("deck.js/core/deck.core.css"));
config.staticFile("core", classpath("deck.js/core/deck.core.js"));
addExtension(config, "status");
addExtension(config, "scale");
addExtension(config, "navigation");
addExtension(config, "hash");
addExtension(config, "goto");
addExtension(config, "menu");
if (config.getLogo() != null) {
addCssExtension(config, "logo");
}
addCssExtension(config, "title");
addCssExtension(config, "highlight");
if (isBlank(config.getTheme())) {
config.theme("web-2.0");
}
config.staticFile("themes/style", classpath("deck.js/themes/style/" + config.getTheme() + ".css"));
config.staticFile("themes/transition", classpath("deck.js/themes/transition/horizontal-slide.css"));
}
| // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/DeckJSConverter.java
import static com.aestasit.markdown.Resources.classpath;
import static org.apache.commons.lang3.StringUtils.isBlank;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://imakewebthings.com/deck.js/">deck.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class DeckJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "deck-js";
protected void beforeStart(final Configuration config) {
config.templateFile(classpath("deck.js/boilerplate.html"));
config.staticFile(classpath("deck.js/jquery-1.7.2.min.js"));
config.staticFile(classpath("deck.js/modernizr.custom.js"));
config.staticFile("core", classpath("deck.js/core/deck.core.css"));
config.staticFile("core", classpath("deck.js/core/deck.core.js"));
addExtension(config, "status");
addExtension(config, "scale");
addExtension(config, "navigation");
addExtension(config, "hash");
addExtension(config, "goto");
addExtension(config, "menu");
if (config.getLogo() != null) {
addCssExtension(config, "logo");
}
addCssExtension(config, "title");
addCssExtension(config, "highlight");
if (isBlank(config.getTheme())) {
config.theme("web-2.0");
}
config.staticFile("themes/style", classpath("deck.js/themes/style/" + config.getTheme() + ".css"));
config.staticFile("themes/transition", classpath("deck.js/themes/transition/horizontal-slide.css"));
}
| private void addExtension(final ConfigurationBuilder config, final String extension) { |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/ImpressJSConverterTest.java | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ImpressJSConverter.java
// public class ImpressJSConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "impress-js";
//
// protected void beforeStart(final Configuration config) {
// config.templateFile(classpath("impress.js/index.html"));
// config.staticFile("css", classpath("impress.js/css/impress-demo.css"));
// config.staticFile("js", classpath("impress.js/js/impress.js"));
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://bartaz.github.com/impress.js";
// }
//
// }
| import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.ImpressJSConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class ImpressJSConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException { | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ImpressJSConverter.java
// public class ImpressJSConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "impress-js";
//
// protected void beforeStart(final Configuration config) {
// config.templateFile(classpath("impress.js/index.html"));
// config.staticFile("css", classpath("impress.js/css/impress-demo.css"));
// config.staticFile("js", classpath("impress.js/js/impress.js"));
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://bartaz.github.com/impress.js";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/ImpressJSConverterTest.java
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.ImpressJSConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class ImpressJSConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException { | new ImpressJSConverter().render(createConfiguration()); |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/ImpressJSConverterTest.java | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ImpressJSConverter.java
// public class ImpressJSConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "impress-js";
//
// protected void beforeStart(final Configuration config) {
// config.templateFile(classpath("impress.js/index.html"));
// config.staticFile("css", classpath("impress.js/css/impress-demo.css"));
// config.staticFile("js", classpath("impress.js/js/impress.js"));
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://bartaz.github.com/impress.js";
// }
//
// }
| import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.ImpressJSConverter; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class ImpressJSConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new ImpressJSConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException { | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ImpressJSConverter.java
// public class ImpressJSConverter extends TextTemplateConverter {
//
// public static final String CONVERTER_ID = "impress-js";
//
// protected void beforeStart(final Configuration config) {
// config.templateFile(classpath("impress.js/index.html"));
// config.staticFile("css", classpath("impress.js/css/impress-demo.css"));
// config.staticFile("js", classpath("impress.js/js/impress.js"));
// }
//
// public String getId() {
// return CONVERTER_ID;
// }
//
// public String getDescription() {
// return "http://bartaz.github.com/impress.js";
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/ImpressJSConverterTest.java
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
import com.aestasit.markdown.slidery.converters.ImpressJSConverter;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class ImpressJSConverterTest extends BaseConverterTest {
@Test
public void testDirectConversion() throws IOException {
new ImpressJSConverter().render(createConfiguration());
}
@Test
public void testFactoryConversion() throws IOException { | ConverterFactory.createConverter(ImpressJSConverter.CONVERTER_ID).render(createConfiguration()); |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/Slidery.java | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public class Markdown {
//
// // ////////////////////////////////////////////////////////////////////////////////////////////////////////
// // AST
// // ////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// public static RootNode toAst(final char[] text, final int options) throws IOException {
// return new PegDownProcessor(options).parser.parse(text);
// }
//
// public static RootNode toAst(final String text) throws IOException {
// return toAst(text.toCharArray());
// }
//
// public static RootNode toAst(final String text, final int options) throws IOException {
// return toAst(text.toCharArray(), options);
// }
//
// public static RootNode toAst(final InputStream stream) throws IOException {
// return toAst(IOUtils.toCharArray(stream));
// }
//
// public static RootNode toAst(final InputStream stream, final int options) throws IOException {
// return toAst(IOUtils.toCharArray(stream), options);
// }
//
// public static RootNode toAst(final File filePath) throws IOException {
// return toAst(new FileInputStream(filePath));
// }
//
// public static RootNode toAst(final File filePath, final int options) throws IOException {
// return toAst(new FileInputStream(filePath), options);
// }
//
// public static RootNode toAst(final URL url) throws IOException {
// return toAst(url.openStream());
// }
//
// public static RootNode toAst(final URL url, final int options) throws IOException {
// return toAst(url.openStream(), options);
// }
//
// // ////////////////////////////////////////////////////////////////////////////////////////////////////////
// // MISC.
// // ////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// public static String extractText(final RootNode node) {
// final ByteArrayOutputStream data = new ByteArrayOutputStream();
// new TextExtractor(new PrintStream(data)).visit(node);
// return new String(data.toByteArray());
// }
//
// public static String printAst(final RootNode node) {
// final ByteArrayOutputStream data = new ByteArrayOutputStream();
// new AstPrinter(new PrintStream(data)).visit(node);
// return new String(data.toByteArray());
// }
//
// public static void logAst(final RootNode node) {
// new LoggingVisitor().visit(node);
// }
//
// }
| import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.pegdown.Extensions;
import org.pegdown.LinkRenderer;
import org.pegdown.ast.RootNode;
import com.aestasit.markdown.Markdown;
import com.google.common.base.Preconditions; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery;
/**
* <code>Slidery</code> conversion methods from <i>Markdown</i> to <i>HTML</i> to <i>DOM</i>.
*
* @author Andrey Adamovich
*
*/
public final class Slidery {
public static int PEGDOWN_ENABLE_ALL_EXTENSIONS = Extensions.ALL;
public static int PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML = Extensions.ALL + Extensions.SUPPRESS_ALL_HTML;
public static int DEFAULT_PEGDOWN_OPTIONS = PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
public static String toSlides(RootNode node) {
Preconditions.checkNotNull(node, "astRoot");
return getConverter().toHtml(node);
}
public static String toSlides(InputStream stream, int options) throws IOException {
Preconditions.checkNotNull(stream, "inputStream"); | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public class Markdown {
//
// // ////////////////////////////////////////////////////////////////////////////////////////////////////////
// // AST
// // ////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// public static RootNode toAst(final char[] text, final int options) throws IOException {
// return new PegDownProcessor(options).parser.parse(text);
// }
//
// public static RootNode toAst(final String text) throws IOException {
// return toAst(text.toCharArray());
// }
//
// public static RootNode toAst(final String text, final int options) throws IOException {
// return toAst(text.toCharArray(), options);
// }
//
// public static RootNode toAst(final InputStream stream) throws IOException {
// return toAst(IOUtils.toCharArray(stream));
// }
//
// public static RootNode toAst(final InputStream stream, final int options) throws IOException {
// return toAst(IOUtils.toCharArray(stream), options);
// }
//
// public static RootNode toAst(final File filePath) throws IOException {
// return toAst(new FileInputStream(filePath));
// }
//
// public static RootNode toAst(final File filePath, final int options) throws IOException {
// return toAst(new FileInputStream(filePath), options);
// }
//
// public static RootNode toAst(final URL url) throws IOException {
// return toAst(url.openStream());
// }
//
// public static RootNode toAst(final URL url, final int options) throws IOException {
// return toAst(url.openStream(), options);
// }
//
// // ////////////////////////////////////////////////////////////////////////////////////////////////////////
// // MISC.
// // ////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// public static String extractText(final RootNode node) {
// final ByteArrayOutputStream data = new ByteArrayOutputStream();
// new TextExtractor(new PrintStream(data)).visit(node);
// return new String(data.toByteArray());
// }
//
// public static String printAst(final RootNode node) {
// final ByteArrayOutputStream data = new ByteArrayOutputStream();
// new AstPrinter(new PrintStream(data)).visit(node);
// return new String(data.toByteArray());
// }
//
// public static void logAst(final RootNode node) {
// new LoggingVisitor().visit(node);
// }
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.pegdown.Extensions;
import org.pegdown.LinkRenderer;
import org.pegdown.ast.RootNode;
import com.aestasit.markdown.Markdown;
import com.google.common.base.Preconditions;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery;
/**
* <code>Slidery</code> conversion methods from <i>Markdown</i> to <i>HTML</i> to <i>DOM</i>.
*
* @author Andrey Adamovich
*
*/
public final class Slidery {
public static int PEGDOWN_ENABLE_ALL_EXTENSIONS = Extensions.ALL;
public static int PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML = Extensions.ALL + Extensions.SUPPRESS_ALL_HTML;
public static int DEFAULT_PEGDOWN_OPTIONS = PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
public static String toSlides(RootNode node) {
Preconditions.checkNotNull(node, "astRoot");
return getConverter().toHtml(node);
}
public static String toSlides(InputStream stream, int options) throws IOException {
Preconditions.checkNotNull(stream, "inputStream"); | return getConverter().toHtml(Markdown.toAst(stream, options)); |
aestasit/slidery | src/test/java/com/aestasit/markdown/visitors/LoggingVisitorTest.java | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static void logAst(final RootNode node) {
// new LoggingVisitor().visit(node);
// }
//
// Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
| import static com.aestasit.markdown.Markdown.logAst;
import static com.aestasit.markdown.Markdown.toAst;
import static com.aestasit.markdown.slidery.Slidery.DEFAULT_PEGDOWN_OPTIONS;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.BaseTest; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.visitors;
/**
* @author Andrey Adamovich
*
*/
public class LoggingVisitorTest extends BaseTest {
@Test
public void test() throws IOException { | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static void logAst(final RootNode node) {
// new LoggingVisitor().visit(node);
// }
//
// Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/visitors/LoggingVisitorTest.java
import static com.aestasit.markdown.Markdown.logAst;
import static com.aestasit.markdown.Markdown.toAst;
import static com.aestasit.markdown.slidery.Slidery.DEFAULT_PEGDOWN_OPTIONS;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.BaseTest;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.visitors;
/**
* @author Andrey Adamovich
*
*/
public class LoggingVisitorTest extends BaseTest {
@Test
public void test() throws IOException { | logAst(toAst(allTestData(), DEFAULT_PEGDOWN_OPTIONS)); |
aestasit/slidery | src/test/java/com/aestasit/markdown/visitors/LoggingVisitorTest.java | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static void logAst(final RootNode node) {
// new LoggingVisitor().visit(node);
// }
//
// Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
| import static com.aestasit.markdown.Markdown.logAst;
import static com.aestasit.markdown.Markdown.toAst;
import static com.aestasit.markdown.slidery.Slidery.DEFAULT_PEGDOWN_OPTIONS;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.BaseTest; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.visitors;
/**
* @author Andrey Adamovich
*
*/
public class LoggingVisitorTest extends BaseTest {
@Test
public void test() throws IOException { | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static void logAst(final RootNode node) {
// new LoggingVisitor().visit(node);
// }
//
// Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/visitors/LoggingVisitorTest.java
import static com.aestasit.markdown.Markdown.logAst;
import static com.aestasit.markdown.Markdown.toAst;
import static com.aestasit.markdown.slidery.Slidery.DEFAULT_PEGDOWN_OPTIONS;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.BaseTest;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.visitors;
/**
* @author Andrey Adamovich
*
*/
public class LoggingVisitorTest extends BaseTest {
@Test
public void test() throws IOException { | logAst(toAst(allTestData(), DEFAULT_PEGDOWN_OPTIONS)); |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/RevealJSConverter.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://lab.hakim.se/reveal-js/">reveal.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class RevealJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "reveal-js";
| // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/RevealJSConverter.java
import static com.aestasit.markdown.Resources.classpath;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://lab.hakim.se/reveal-js/">reveal.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class RevealJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "reveal-js";
| protected void beforeStart(final Configuration config) { |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/RevealJSConverter.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://lab.hakim.se/reveal-js/">reveal.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class RevealJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "reveal-js";
protected void beforeStart(final Configuration config) {
| // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/RevealJSConverter.java
import static com.aestasit.markdown.Resources.classpath;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.aestasit.markdown.slidery.configuration.Configuration;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://lab.hakim.se/reveal-js/">reveal.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class RevealJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "reveal-js";
protected void beforeStart(final Configuration config) {
| config.templateFile(classpath("reveal.js/index.html")); |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/ImpressJSConverter.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import com.aestasit.markdown.slidery.configuration.Configuration; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://bartaz.github.com/impress.js">impress.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class ImpressJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "impress-js";
| // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ImpressJSConverter.java
import static com.aestasit.markdown.Resources.classpath;
import com.aestasit.markdown.slidery.configuration.Configuration;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://bartaz.github.com/impress.js">impress.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class ImpressJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "impress-js";
| protected void beforeStart(final Configuration config) { |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/ImpressJSConverter.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import com.aestasit.markdown.slidery.configuration.Configuration; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://bartaz.github.com/impress.js">impress.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class ImpressJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "impress-js";
protected void beforeStart(final Configuration config) { | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ImpressJSConverter.java
import static com.aestasit.markdown.Resources.classpath;
import com.aestasit.markdown.slidery.configuration.Configuration;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="http://bartaz.github.com/impress.js">impress.js</a> framework.
*
* @author Andrey Adamovich
*
*/
public class ImpressJSConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "impress-js";
protected void beforeStart(final Configuration config) { | config.templateFile(classpath("impress.js/index.html")); |
aestasit/slidery | src/test/java/com/aestasit/markdown/visitors/AstPrinterTest.java | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static String printAst(final RootNode node) {
// final ByteArrayOutputStream data = new ByteArrayOutputStream();
// new AstPrinter(new PrintStream(data)).visit(node);
// return new String(data.toByteArray());
// }
//
// Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
| import static com.aestasit.markdown.Markdown.printAst;
import static com.aestasit.markdown.Markdown.toAst;
import static com.aestasit.markdown.slidery.Slidery.DEFAULT_PEGDOWN_OPTIONS;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.BaseTest; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.visitors;
/**
* @author Andrey Adamovich
*
*/
public class AstPrinterTest extends BaseTest {
@Test
public void testAstPrinter() throws IOException { | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static String printAst(final RootNode node) {
// final ByteArrayOutputStream data = new ByteArrayOutputStream();
// new AstPrinter(new PrintStream(data)).visit(node);
// return new String(data.toByteArray());
// }
//
// Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/visitors/AstPrinterTest.java
import static com.aestasit.markdown.Markdown.printAst;
import static com.aestasit.markdown.Markdown.toAst;
import static com.aestasit.markdown.slidery.Slidery.DEFAULT_PEGDOWN_OPTIONS;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.BaseTest;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.visitors;
/**
* @author Andrey Adamovich
*
*/
public class AstPrinterTest extends BaseTest {
@Test
public void testAstPrinter() throws IOException { | String astString = printAst(toAst(allTestData(), DEFAULT_PEGDOWN_OPTIONS)); |
aestasit/slidery | src/test/java/com/aestasit/markdown/visitors/AstPrinterTest.java | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static String printAst(final RootNode node) {
// final ByteArrayOutputStream data = new ByteArrayOutputStream();
// new AstPrinter(new PrintStream(data)).visit(node);
// return new String(data.toByteArray());
// }
//
// Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
| import static com.aestasit.markdown.Markdown.printAst;
import static com.aestasit.markdown.Markdown.toAst;
import static com.aestasit.markdown.slidery.Slidery.DEFAULT_PEGDOWN_OPTIONS;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.BaseTest; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.visitors;
/**
* @author Andrey Adamovich
*
*/
public class AstPrinterTest extends BaseTest {
@Test
public void testAstPrinter() throws IOException { | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static String printAst(final RootNode node) {
// final ByteArrayOutputStream data = new ByteArrayOutputStream();
// new AstPrinter(new PrintStream(data)).visit(node);
// return new String(data.toByteArray());
// }
//
// Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/visitors/AstPrinterTest.java
import static com.aestasit.markdown.Markdown.printAst;
import static com.aestasit.markdown.Markdown.toAst;
import static com.aestasit.markdown.slidery.Slidery.DEFAULT_PEGDOWN_OPTIONS;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Test;
import com.aestasit.markdown.BaseTest;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.visitors;
/**
* @author Andrey Adamovich
*
*/
public class AstPrinterTest extends BaseTest {
@Test
public void testAstPrinter() throws IOException { | String astString = printAst(toAst(allTestData(), DEFAULT_PEGDOWN_OPTIONS)); |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/ShowerConverter.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import com.aestasit.markdown.slidery.configuration.Configuration; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="https://github.com/shower/shower">shower</a> framework.
*
* @author Andrey Adamovich
*
*/
public class ShowerConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "shower";
| // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ShowerConverter.java
import static com.aestasit.markdown.Resources.classpath;
import com.aestasit.markdown.slidery.configuration.Configuration;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="https://github.com/shower/shower">shower</a> framework.
*
* @author Andrey Adamovich
*
*/
public class ShowerConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "shower";
| protected void beforeStart(final Configuration config) { |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/ShowerConverter.java | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
| import static com.aestasit.markdown.Resources.classpath;
import com.aestasit.markdown.slidery.configuration.Configuration; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="https://github.com/shower/shower">shower</a> framework.
*
* @author Andrey Adamovich
*
*/
public class ShowerConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "shower";
protected void beforeStart(final Configuration config) { | // Path: src/main/java/com/aestasit/markdown/Resources.java
// public static File classpath(final String filePath) {
// checkPath(filePath);
// final File tempFile = tempFile(filePath);
// copy(classLoader().getResourceAsStream(filePath), silentOpen(tempFile));
// return tempFile;
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/ShowerConverter.java
import static com.aestasit.markdown.Resources.classpath;
import com.aestasit.markdown.slidery.configuration.Configuration;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* Presentation converter that is based on <a href="https://github.com/shower/shower">shower</a> framework.
*
* @author Andrey Adamovich
*
*/
public class ShowerConverter extends TextTemplateConverter {
public static final String CONVERTER_ID = "shower";
protected void beforeStart(final Configuration config) { | config.templateFile(classpath("shower/template.html")); |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/BaseConverter.java | // Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS = Extensions.ALL;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML = Extensions.ALL + Extensions.SUPPRESS_ALL_HTML;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static Document toDom(String text) throws IOException {
// return Jsoup.parse(toSlides(text));
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
| import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS;
import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
import static com.aestasit.markdown.slidery.Slidery.toDom;
import static org.apache.commons.io.FileUtils.copyFileToDirectory;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.FileUtils.forceMkdir;
import static org.apache.commons.io.FileUtils.openOutputStream;
import static org.apache.commons.io.FileUtils.readLines;
import static org.apache.commons.io.FileUtils.writeLines;
import static org.apache.commons.io.FilenameUtils.getBaseName;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.closeQuietly;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import org.jsoup.nodes.Document;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
import com.google.common.collect.Multimap; | private void copyStaticFiles(Multimap<String, File> staticFiles, File outputDir) throws IOException {
for (Entry<String, File> templateFile : staticFiles.entries()) {
String relativePath = templateFile.getKey();
File destDir = new File(outputDir, relativePath);
forceMkdir(destDir);
copyFileToDirectory(templateFile.getValue(), destDir);
}
}
private void createOutput(File joinedFile, Configuration config) throws IOException {
beforeConversion(joinedFile, config);
convertFile(config, joinedFile, config.getOutputFile());
if (config.isSplitOutput()) {
for (File inputFile : config.getInputFiles()) {
convertFile(config, inputFile, getSplitOutputFile(config.getOutputFile(), inputFile));
}
}
afterConversion(joinedFile, config);
deleteTemporaryFiles(joinedFile, config);
}
protected File getSplitOutputFile(File outputFile, File inputFile) {
String inputFileName = getBaseName(inputFile.getName()) + '.' + getExtension(outputFile.getName());
return new File(outputFile.getParentFile(), inputFileName);
}
private void convertFile(Configuration config, File inputFile, File outputFile) throws IOException {
FileOutputStream outputStream = null;
try {
outputStream = openOutputStream(outputFile); | // Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS = Extensions.ALL;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML = Extensions.ALL + Extensions.SUPPRESS_ALL_HTML;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static Document toDom(String text) throws IOException {
// return Jsoup.parse(toSlides(text));
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/BaseConverter.java
import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS;
import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
import static com.aestasit.markdown.slidery.Slidery.toDom;
import static org.apache.commons.io.FileUtils.copyFileToDirectory;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.FileUtils.forceMkdir;
import static org.apache.commons.io.FileUtils.openOutputStream;
import static org.apache.commons.io.FileUtils.readLines;
import static org.apache.commons.io.FileUtils.writeLines;
import static org.apache.commons.io.FilenameUtils.getBaseName;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.closeQuietly;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import org.jsoup.nodes.Document;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
import com.google.common.collect.Multimap;
private void copyStaticFiles(Multimap<String, File> staticFiles, File outputDir) throws IOException {
for (Entry<String, File> templateFile : staticFiles.entries()) {
String relativePath = templateFile.getKey();
File destDir = new File(outputDir, relativePath);
forceMkdir(destDir);
copyFileToDirectory(templateFile.getValue(), destDir);
}
}
private void createOutput(File joinedFile, Configuration config) throws IOException {
beforeConversion(joinedFile, config);
convertFile(config, joinedFile, config.getOutputFile());
if (config.isSplitOutput()) {
for (File inputFile : config.getInputFiles()) {
convertFile(config, inputFile, getSplitOutputFile(config.getOutputFile(), inputFile));
}
}
afterConversion(joinedFile, config);
deleteTemporaryFiles(joinedFile, config);
}
protected File getSplitOutputFile(File outputFile, File inputFile) {
String inputFileName = getBaseName(inputFile.getName()) + '.' + getExtension(outputFile.getName());
return new File(outputFile.getParentFile(), inputFileName);
}
private void convertFile(Configuration config, File inputFile, File outputFile) throws IOException {
FileOutputStream outputStream = null;
try {
outputStream = openOutputStream(outputFile); | int parserOptions = PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML; |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/BaseConverter.java | // Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS = Extensions.ALL;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML = Extensions.ALL + Extensions.SUPPRESS_ALL_HTML;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static Document toDom(String text) throws IOException {
// return Jsoup.parse(toSlides(text));
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
| import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS;
import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
import static com.aestasit.markdown.slidery.Slidery.toDom;
import static org.apache.commons.io.FileUtils.copyFileToDirectory;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.FileUtils.forceMkdir;
import static org.apache.commons.io.FileUtils.openOutputStream;
import static org.apache.commons.io.FileUtils.readLines;
import static org.apache.commons.io.FileUtils.writeLines;
import static org.apache.commons.io.FilenameUtils.getBaseName;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.closeQuietly;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import org.jsoup.nodes.Document;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
import com.google.common.collect.Multimap; | String relativePath = templateFile.getKey();
File destDir = new File(outputDir, relativePath);
forceMkdir(destDir);
copyFileToDirectory(templateFile.getValue(), destDir);
}
}
private void createOutput(File joinedFile, Configuration config) throws IOException {
beforeConversion(joinedFile, config);
convertFile(config, joinedFile, config.getOutputFile());
if (config.isSplitOutput()) {
for (File inputFile : config.getInputFiles()) {
convertFile(config, inputFile, getSplitOutputFile(config.getOutputFile(), inputFile));
}
}
afterConversion(joinedFile, config);
deleteTemporaryFiles(joinedFile, config);
}
protected File getSplitOutputFile(File outputFile, File inputFile) {
String inputFileName = getBaseName(inputFile.getName()) + '.' + getExtension(outputFile.getName());
return new File(outputFile.getParentFile(), inputFileName);
}
private void convertFile(Configuration config, File inputFile, File outputFile) throws IOException {
FileOutputStream outputStream = null;
try {
outputStream = openOutputStream(outputFile);
int parserOptions = PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
if (!config.htmlStripped()) { | // Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS = Extensions.ALL;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML = Extensions.ALL + Extensions.SUPPRESS_ALL_HTML;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static Document toDom(String text) throws IOException {
// return Jsoup.parse(toSlides(text));
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/BaseConverter.java
import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS;
import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
import static com.aestasit.markdown.slidery.Slidery.toDom;
import static org.apache.commons.io.FileUtils.copyFileToDirectory;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.FileUtils.forceMkdir;
import static org.apache.commons.io.FileUtils.openOutputStream;
import static org.apache.commons.io.FileUtils.readLines;
import static org.apache.commons.io.FileUtils.writeLines;
import static org.apache.commons.io.FilenameUtils.getBaseName;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.closeQuietly;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import org.jsoup.nodes.Document;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
import com.google.common.collect.Multimap;
String relativePath = templateFile.getKey();
File destDir = new File(outputDir, relativePath);
forceMkdir(destDir);
copyFileToDirectory(templateFile.getValue(), destDir);
}
}
private void createOutput(File joinedFile, Configuration config) throws IOException {
beforeConversion(joinedFile, config);
convertFile(config, joinedFile, config.getOutputFile());
if (config.isSplitOutput()) {
for (File inputFile : config.getInputFiles()) {
convertFile(config, inputFile, getSplitOutputFile(config.getOutputFile(), inputFile));
}
}
afterConversion(joinedFile, config);
deleteTemporaryFiles(joinedFile, config);
}
protected File getSplitOutputFile(File outputFile, File inputFile) {
String inputFileName = getBaseName(inputFile.getName()) + '.' + getExtension(outputFile.getName());
return new File(outputFile.getParentFile(), inputFileName);
}
private void convertFile(Configuration config, File inputFile, File outputFile) throws IOException {
FileOutputStream outputStream = null;
try {
outputStream = openOutputStream(outputFile);
int parserOptions = PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
if (!config.htmlStripped()) { | parserOptions = PEGDOWN_ENABLE_ALL_EXTENSIONS; |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/BaseConverter.java | // Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS = Extensions.ALL;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML = Extensions.ALL + Extensions.SUPPRESS_ALL_HTML;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static Document toDom(String text) throws IOException {
// return Jsoup.parse(toSlides(text));
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
| import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS;
import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
import static com.aestasit.markdown.slidery.Slidery.toDom;
import static org.apache.commons.io.FileUtils.copyFileToDirectory;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.FileUtils.forceMkdir;
import static org.apache.commons.io.FileUtils.openOutputStream;
import static org.apache.commons.io.FileUtils.readLines;
import static org.apache.commons.io.FileUtils.writeLines;
import static org.apache.commons.io.FilenameUtils.getBaseName;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.closeQuietly;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import org.jsoup.nodes.Document;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
import com.google.common.collect.Multimap; | forceMkdir(destDir);
copyFileToDirectory(templateFile.getValue(), destDir);
}
}
private void createOutput(File joinedFile, Configuration config) throws IOException {
beforeConversion(joinedFile, config);
convertFile(config, joinedFile, config.getOutputFile());
if (config.isSplitOutput()) {
for (File inputFile : config.getInputFiles()) {
convertFile(config, inputFile, getSplitOutputFile(config.getOutputFile(), inputFile));
}
}
afterConversion(joinedFile, config);
deleteTemporaryFiles(joinedFile, config);
}
protected File getSplitOutputFile(File outputFile, File inputFile) {
String inputFileName = getBaseName(inputFile.getName()) + '.' + getExtension(outputFile.getName());
return new File(outputFile.getParentFile(), inputFileName);
}
private void convertFile(Configuration config, File inputFile, File outputFile) throws IOException {
FileOutputStream outputStream = null;
try {
outputStream = openOutputStream(outputFile);
int parserOptions = PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
if (!config.htmlStripped()) {
parserOptions = PEGDOWN_ENABLE_ALL_EXTENSIONS;
} | // Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS = Extensions.ALL;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML = Extensions.ALL + Extensions.SUPPRESS_ALL_HTML;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static Document toDom(String text) throws IOException {
// return Jsoup.parse(toSlides(text));
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/BaseConverter.java
import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS;
import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
import static com.aestasit.markdown.slidery.Slidery.toDom;
import static org.apache.commons.io.FileUtils.copyFileToDirectory;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.FileUtils.forceMkdir;
import static org.apache.commons.io.FileUtils.openOutputStream;
import static org.apache.commons.io.FileUtils.readLines;
import static org.apache.commons.io.FileUtils.writeLines;
import static org.apache.commons.io.FilenameUtils.getBaseName;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.closeQuietly;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import org.jsoup.nodes.Document;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
import com.google.common.collect.Multimap;
forceMkdir(destDir);
copyFileToDirectory(templateFile.getValue(), destDir);
}
}
private void createOutput(File joinedFile, Configuration config) throws IOException {
beforeConversion(joinedFile, config);
convertFile(config, joinedFile, config.getOutputFile());
if (config.isSplitOutput()) {
for (File inputFile : config.getInputFiles()) {
convertFile(config, inputFile, getSplitOutputFile(config.getOutputFile(), inputFile));
}
}
afterConversion(joinedFile, config);
deleteTemporaryFiles(joinedFile, config);
}
protected File getSplitOutputFile(File outputFile, File inputFile) {
String inputFileName = getBaseName(inputFile.getName()) + '.' + getExtension(outputFile.getName());
return new File(outputFile.getParentFile(), inputFileName);
}
private void convertFile(Configuration config, File inputFile, File outputFile) throws IOException {
FileOutputStream outputStream = null;
try {
outputStream = openOutputStream(outputFile);
int parserOptions = PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
if (!config.htmlStripped()) {
parserOptions = PEGDOWN_ENABLE_ALL_EXTENSIONS;
} | convert(new OutputStreamWriter(outputStream), toDom(inputFile, parserOptions), config); |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/BaseConverter.java | // Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS = Extensions.ALL;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML = Extensions.ALL + Extensions.SUPPRESS_ALL_HTML;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static Document toDom(String text) throws IOException {
// return Jsoup.parse(toSlides(text));
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
| import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS;
import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
import static com.aestasit.markdown.slidery.Slidery.toDom;
import static org.apache.commons.io.FileUtils.copyFileToDirectory;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.FileUtils.forceMkdir;
import static org.apache.commons.io.FileUtils.openOutputStream;
import static org.apache.commons.io.FileUtils.readLines;
import static org.apache.commons.io.FileUtils.writeLines;
import static org.apache.commons.io.FilenameUtils.getBaseName;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.closeQuietly;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import org.jsoup.nodes.Document;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
import com.google.common.collect.Multimap; | int parserOptions = PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
if (!config.htmlStripped()) {
parserOptions = PEGDOWN_ENABLE_ALL_EXTENSIONS;
}
convert(new OutputStreamWriter(outputStream), toDom(inputFile, parserOptions), config);
} finally {
closeQuietly(outputStream);
}
}
private void deleteTemporaryFiles(File joinedFile, Configuration config) {
for (File staticFile : config.getStaticFiles().values()) {
deleteTemporaryFile(staticFile);
}
deleteQuietly(joinedFile);
}
private void deleteTemporaryFile(File staticFile) {
File systemTempDir = new File(System.getProperty("java.io.tmpdir"));
if (staticFile.getAbsolutePath().contains(systemTempDir.getAbsolutePath())) {
try {
deleteDirectory(staticFile.getParentFile());
} catch (IOException e) {
}
}
}
protected void beforeStart(Configuration config) {
}
| // Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS = Extensions.ALL;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static int PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML = Extensions.ALL + Extensions.SUPPRESS_ALL_HTML;
//
// Path: src/main/java/com/aestasit/markdown/slidery/Slidery.java
// public static Document toDom(String text) throws IOException {
// return Jsoup.parse(toSlides(text));
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/BaseConverter.java
import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS;
import static com.aestasit.markdown.slidery.Slidery.PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
import static com.aestasit.markdown.slidery.Slidery.toDom;
import static org.apache.commons.io.FileUtils.copyFileToDirectory;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.FileUtils.forceMkdir;
import static org.apache.commons.io.FileUtils.openOutputStream;
import static org.apache.commons.io.FileUtils.readLines;
import static org.apache.commons.io.FileUtils.writeLines;
import static org.apache.commons.io.FilenameUtils.getBaseName;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.closeQuietly;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import org.jsoup.nodes.Document;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
import com.google.common.collect.Multimap;
int parserOptions = PEGDOWN_ENABLE_ALL_EXTENSIONS_AND_SUPPRESS_HTML;
if (!config.htmlStripped()) {
parserOptions = PEGDOWN_ENABLE_ALL_EXTENSIONS;
}
convert(new OutputStreamWriter(outputStream), toDom(inputFile, parserOptions), config);
} finally {
closeQuietly(outputStream);
}
}
private void deleteTemporaryFiles(File joinedFile, Configuration config) {
for (File staticFile : config.getStaticFiles().values()) {
deleteTemporaryFile(staticFile);
}
deleteQuietly(joinedFile);
}
private void deleteTemporaryFile(File staticFile) {
File systemTempDir = new File(System.getProperty("java.io.tmpdir"));
if (staticFile.getAbsolutePath().contains(systemTempDir.getAbsolutePath())) {
try {
deleteDirectory(staticFile.getParentFile());
} catch (IOException e) {
}
}
}
protected void beforeStart(Configuration config) {
}
| protected void beforeConversion(File inputFile, ConfigurationBuilder config) { |
aestasit/slidery | src/test/java/com/aestasit/markdown/slidery/converters/ConverterFactoryTest.java | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
| import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import com.aestasit.markdown.slidery.converters.ConverterFactory; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class ConverterFactoryTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void testNotExistingConverter() {
thrown.expect(RuntimeException.class); | // Path: src/main/java/com/aestasit/markdown/slidery/converters/ConverterFactory.java
// public final class ConverterFactory {
//
// /**
// * Lookups <code><id>.properties</pre></code> under <code>META-INF/slidery-converters</code> directory
// * in the class path and based on <code>converter-class</code> property value creates {@link Converter} instance.
// *
// * @param id converter identifier.
// * @return converter instance.
// */
// public static Converter createConverter(String id) {
// return doCreateConverter(getConverterClassName(id));
// }
//
// private static Converter doCreateConverter(String converterClassName) {
// try {
// Class<?> converterClass = Class.forName(converterClassName);
// Object converter = converterClass.newInstance();
// if (!(converter instanceof Converter)) {
// converter = null;
// }
// return (Converter) converter;
// } catch (ClassNotFoundException e) {
// throw new RuntimeException(e);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static String getConverterClassName(String id) {
// try {
// Properties properties = new Properties();
// properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/slidery-converters/" + id + ".properties"));
// String converterClassName = properties.getProperty("converter-class");
// return converterClassName;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/slidery/converters/ConverterFactoryTest.java
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import com.aestasit.markdown.slidery.converters.ConverterFactory;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.slidery.converters;
/**
* @author Andrey Adamovich
*
*/
public class ConverterFactoryTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void testNotExistingConverter() {
thrown.expect(RuntimeException.class); | ConverterFactory.createConverter("not-existing"); |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/TextTemplateConverter.java | // Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Location.java
// public enum Location {
//
// HEAD_START, HEAD_END, BODY_START, SLIDES_START, SLIDES_END, BODY_END
//
// }
| import static org.apache.commons.io.FileUtils.readFileToString;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
import static org.apache.commons.lang3.StringUtils.isBlank;
import groovy.text.SimpleTemplateEngine;
import groovy.text.Template;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Writer;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.groovy.control.CompilationFailedException;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.select.Elements;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
import com.aestasit.markdown.slidery.configuration.Location;
import com.uwyn.jhighlight.renderer.Renderer;
import com.uwyn.jhighlight.renderer.XhtmlRendererFactory; | private void bindTitle(HashMap<String, Object> binding, Document slidesDocument, Configuration config) {
if (!isBlank(config.getTitle())) {
binding.put("title", config.getTitle());
} else {
binding.put("title", getFirstSlideTitle(slidesDocument));
}
}
private void bindConfigurationElements(HashMap<String, Object> binding, Configuration config) {
binding.put("author", config.getAuthor());
binding.put("company", config.getCompany());
binding.put("description", defaultIfNull(config.getDescription(), binding.get("title")));
binding.put("date", new SimpleDateFormat("dd-MM-yyyy").format(config.getDate()));
binding.put("backgroundColor", config.getBackgroundColor());
binding.put("fontColor", config.getFontColor());
binding.put("fontName", config.getFontName());
binding.put("fontLink", config.getFontLink());
binding.put("theme", config.getTheme());
if (config.getLogo() != null) {
binding.put("logoFile", config.getLogo().getName());
} else {
binding.put("logoFile", null);
}
if (config.getOutputFile() != null) {
binding.put("outputFile", config.getOutputFile().getName());
} else {
binding.put("outputFile", null);
}
}
| // Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Location.java
// public enum Location {
//
// HEAD_START, HEAD_END, BODY_START, SLIDES_START, SLIDES_END, BODY_END
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/TextTemplateConverter.java
import static org.apache.commons.io.FileUtils.readFileToString;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
import static org.apache.commons.lang3.StringUtils.isBlank;
import groovy.text.SimpleTemplateEngine;
import groovy.text.Template;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Writer;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.groovy.control.CompilationFailedException;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.select.Elements;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
import com.aestasit.markdown.slidery.configuration.Location;
import com.uwyn.jhighlight.renderer.Renderer;
import com.uwyn.jhighlight.renderer.XhtmlRendererFactory;
private void bindTitle(HashMap<String, Object> binding, Document slidesDocument, Configuration config) {
if (!isBlank(config.getTitle())) {
binding.put("title", config.getTitle());
} else {
binding.put("title", getFirstSlideTitle(slidesDocument));
}
}
private void bindConfigurationElements(HashMap<String, Object> binding, Configuration config) {
binding.put("author", config.getAuthor());
binding.put("company", config.getCompany());
binding.put("description", defaultIfNull(config.getDescription(), binding.get("title")));
binding.put("date", new SimpleDateFormat("dd-MM-yyyy").format(config.getDate()));
binding.put("backgroundColor", config.getBackgroundColor());
binding.put("fontColor", config.getFontColor());
binding.put("fontName", config.getFontName());
binding.put("fontLink", config.getFontLink());
binding.put("theme", config.getTheme());
if (config.getLogo() != null) {
binding.put("logoFile", config.getLogo().getName());
} else {
binding.put("logoFile", null);
}
if (config.getOutputFile() != null) {
binding.put("outputFile", config.getOutputFile().getName());
} else {
binding.put("outputFile", null);
}
}
| protected void expandBinding(final HashMap<String, Object> binding, Document slidesDocument, ConfigurationBuilder config) { |
aestasit/slidery | src/main/java/com/aestasit/markdown/slidery/converters/TextTemplateConverter.java | // Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Location.java
// public enum Location {
//
// HEAD_START, HEAD_END, BODY_START, SLIDES_START, SLIDES_END, BODY_END
//
// }
| import static org.apache.commons.io.FileUtils.readFileToString;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
import static org.apache.commons.lang3.StringUtils.isBlank;
import groovy.text.SimpleTemplateEngine;
import groovy.text.Template;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Writer;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.groovy.control.CompilationFailedException;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.select.Elements;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
import com.aestasit.markdown.slidery.configuration.Location;
import com.uwyn.jhighlight.renderer.Renderer;
import com.uwyn.jhighlight.renderer.XhtmlRendererFactory; |
protected Template compileTemplate(String templateText) throws IOException {
SimpleTemplateEngine engine = new SimpleTemplateEngine();
Template template = null;
try {
template = engine.createTemplate(templateText);
} catch (CompilationFailedException e) {
throw new IOException(e);
} catch (ClassNotFoundException e) {
throw new IOException(e);
}
return template;
}
public Collection<String> getTransitionIds() {
return Collections.<String> emptyList();
}
public String getDefaultTransitionId() {
return "default";
}
public Collection<String> getThemeIds() {
return Collections.<String> emptyList();
}
public String getDefaultThemeId() {
return "default";
}
| // Path: src/main/java/com/aestasit/markdown/slidery/configuration/Configuration.java
// public interface Configuration extends ConfigurationBuilder, ConfigurationReader {
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/ConfigurationBuilder.java
// public interface ConfigurationBuilder {
//
// void validate() throws IllegalStateException;
//
// ConfigurationBuilder configuration(ConfigurationReader config);
//
// ConfigurationBuilder clear();
//
// ConfigurationBuilder clearInputFiles();
//
// ConfigurationBuilder clearStaticFiles();
//
// ConfigurationBuilder clearTemplateFiles();
//
// ConfigurationBuilder clearSnippets();
//
// ConfigurationBuilder inputFile(File inputFile);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition);
//
// ConfigurationBuilder inputFile(File inputFile, Styling styling);
//
// ConfigurationBuilder inputFile(File inputFile, Transition transition, Styling styling);
//
// ConfigurationBuilder snippet(Location location, String snippet);
//
// ConfigurationBuilder defaultTransition(Transition transition);
//
// ConfigurationBuilder defaultStyling(Styling styling);
//
// ConfigurationBuilder inputFiles(Collection<File> inputFiles);
//
// Configuration encoding(String encoding);
//
// ConfigurationBuilder encoding(Charset encoding);
//
// ConfigurationBuilder templateFile(File templateFile);
//
// ConfigurationBuilder templateFile(String targetName, File templateFile);
//
// ConfigurationBuilder templateFiles(Collection<File> templateFile);
//
// ConfigurationBuilder staticFile(File staticFile);
//
// ConfigurationBuilder staticFiles(Collection<File> staticFiles);
//
// ConfigurationBuilder staticFile(String relativePath, File staticFile);
//
// ConfigurationBuilder staticFiles(String relativePath, Collection<File> staticFiles);
//
// Configuration outputFile(File outputFile);
//
// // Meta-data
// ConfigurationBuilder author(String name);
//
// ConfigurationBuilder company(String name);
//
// ConfigurationBuilder title(String title);
//
// ConfigurationBuilder description(String description);
//
// ConfigurationBuilder date(Date date);
//
// ConfigurationBuilder currentDate();
//
// ConfigurationBuilder logo(File file);
//
// ConfigurationBuilder incrementalLists();
//
// ConfigurationBuilder incrementalLists(boolean state);
//
// ConfigurationBuilder includeNotes();
//
// ConfigurationBuilder includeNotes(boolean state);
//
// ConfigurationBuilder excludeNotes();
//
// ConfigurationBuilder stripHtml();
//
// ConfigurationBuilder stripHtml(boolean state);
//
// // Styling
// ConfigurationBuilder theme(String name);
//
// ConfigurationBuilder font(String name, URL link);
//
// ConfigurationBuilder font(String name);
//
// ConfigurationBuilder backgroundColor(String color);
//
// ConfigurationBuilder fontColor(String color);
//
// ConfigurationBuilder color(String ref, String color);
//
// ConfigurationBuilder option(String name, String value);
//
// // Rules
// ConfigurationBuilder transitionRule(String selector, String rule);
//
// ConfigurationBuilder stylingRule(String selector, String rule);
//
// ConfigurationBuilder splitOutput();
//
// ConfigurationBuilder splitOutput(boolean state);
//
// ConfigurationBuilder verbose();
//
// ConfigurationBuilder verbose(boolean state);
//
// }
//
// Path: src/main/java/com/aestasit/markdown/slidery/configuration/Location.java
// public enum Location {
//
// HEAD_START, HEAD_END, BODY_START, SLIDES_START, SLIDES_END, BODY_END
//
// }
// Path: src/main/java/com/aestasit/markdown/slidery/converters/TextTemplateConverter.java
import static org.apache.commons.io.FileUtils.readFileToString;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
import static org.apache.commons.lang3.StringUtils.isBlank;
import groovy.text.SimpleTemplateEngine;
import groovy.text.Template;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Writer;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.groovy.control.CompilationFailedException;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.select.Elements;
import com.aestasit.markdown.slidery.configuration.Configuration;
import com.aestasit.markdown.slidery.configuration.ConfigurationBuilder;
import com.aestasit.markdown.slidery.configuration.Location;
import com.uwyn.jhighlight.renderer.Renderer;
import com.uwyn.jhighlight.renderer.XhtmlRendererFactory;
protected Template compileTemplate(String templateText) throws IOException {
SimpleTemplateEngine engine = new SimpleTemplateEngine();
Template template = null;
try {
template = engine.createTemplate(templateText);
} catch (CompilationFailedException e) {
throw new IOException(e);
} catch (ClassNotFoundException e) {
throw new IOException(e);
}
return template;
}
public Collection<String> getTransitionIds() {
return Collections.<String> emptyList();
}
public String getDefaultTransitionId() {
return "default";
}
public Collection<String> getThemeIds() {
return Collections.<String> emptyList();
}
public String getDefaultThemeId() {
return "default";
}
| public Collection<Location> getLocations() { |
aestasit/slidery | src/test/java/com/aestasit/markdown/visitors/TextExtractorTest.java | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static String extractText(final RootNode node) {
// final ByteArrayOutputStream data = new ByteArrayOutputStream();
// new TextExtractor(new PrintStream(data)).visit(node);
// return new String(data.toByteArray());
// }
//
// Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
| import static com.aestasit.markdown.Markdown.extractText;
import static com.aestasit.markdown.Markdown.toAst;
import static com.aestasit.markdown.slidery.Slidery.DEFAULT_PEGDOWN_OPTIONS;
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.io.IOException;
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Test;
import com.aestasit.markdown.BaseTest; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.visitors;
/**
* @author Andrey Adamovich
*
*/
public class TextExtractorTest extends BaseTest {
@Test
public void testExtraction() throws IOException { | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static String extractText(final RootNode node) {
// final ByteArrayOutputStream data = new ByteArrayOutputStream();
// new TextExtractor(new PrintStream(data)).visit(node);
// return new String(data.toByteArray());
// }
//
// Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/visitors/TextExtractorTest.java
import static com.aestasit.markdown.Markdown.extractText;
import static com.aestasit.markdown.Markdown.toAst;
import static com.aestasit.markdown.slidery.Slidery.DEFAULT_PEGDOWN_OPTIONS;
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.io.IOException;
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Test;
import com.aestasit.markdown.BaseTest;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.visitors;
/**
* @author Andrey Adamovich
*
*/
public class TextExtractorTest extends BaseTest {
@Test
public void testExtraction() throws IOException { | String text = extractText(toAst(allTestData(), DEFAULT_PEGDOWN_OPTIONS)); |
aestasit/slidery | src/test/java/com/aestasit/markdown/visitors/TextExtractorTest.java | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static String extractText(final RootNode node) {
// final ByteArrayOutputStream data = new ByteArrayOutputStream();
// new TextExtractor(new PrintStream(data)).visit(node);
// return new String(data.toByteArray());
// }
//
// Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
| import static com.aestasit.markdown.Markdown.extractText;
import static com.aestasit.markdown.Markdown.toAst;
import static com.aestasit.markdown.slidery.Slidery.DEFAULT_PEGDOWN_OPTIONS;
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.io.IOException;
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Test;
import com.aestasit.markdown.BaseTest; | /*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.visitors;
/**
* @author Andrey Adamovich
*
*/
public class TextExtractorTest extends BaseTest {
@Test
public void testExtraction() throws IOException { | // Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static String extractText(final RootNode node) {
// final ByteArrayOutputStream data = new ByteArrayOutputStream();
// new TextExtractor(new PrintStream(data)).visit(node);
// return new String(data.toByteArray());
// }
//
// Path: src/main/java/com/aestasit/markdown/Markdown.java
// public static RootNode toAst(final char[] text) throws IOException {
// return new PegDownProcessor().parser.parse(text);
// }
//
// Path: src/test/java/com/aestasit/markdown/BaseTest.java
// public class BaseTest {
//
// protected Logger log = LoggerFactory.getLogger("com.aestasit.markdown.slidery.tests");
//
// protected static InputStream testData(String fileName) throws IOException {
// return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
// }
//
// protected static InputStream allTestData() throws IOException {
// ByteArrayOutputStream data = new ByteArrayOutputStream();
// for (String fileName : allTestFiles()) {
// IOUtils.write(IOUtils.toString(testData(fileName)), data);
// }
// IOUtils.closeQuietly(data);
// return new ByteArrayInputStream(data.toByteArray());
// }
//
// protected static String[] allTestFiles() {
// return new String[] {
// "01_simple_slides.md",
// "02_image_slides.md",
// "03_code_slides.md",
// "04_slide_notes.md",
// "05_table_slides.md",
// "06_slides_with_links.md",
// "07_nested_lists.md",
// "08_titleless_slides.md",
// };
// }
//
// }
// Path: src/test/java/com/aestasit/markdown/visitors/TextExtractorTest.java
import static com.aestasit.markdown.Markdown.extractText;
import static com.aestasit.markdown.Markdown.toAst;
import static com.aestasit.markdown.slidery.Slidery.DEFAULT_PEGDOWN_OPTIONS;
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.io.IOException;
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Test;
import com.aestasit.markdown.BaseTest;
/*
* Copyright (C) 2011-2014 Aestas/IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aestasit.markdown.visitors;
/**
* @author Andrey Adamovich
*
*/
public class TextExtractorTest extends BaseTest {
@Test
public void testExtraction() throws IOException { | String text = extractText(toAst(allTestData(), DEFAULT_PEGDOWN_OPTIONS)); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.