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
|
---|---|---|---|---|---|---|
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/client/DefaultRequestExecutorFactory.java | // Path: src/main/java/com/webfluxclient/codec/ExtendedClientCodecConfigurer.java
// public interface ExtendedClientCodecConfigurer extends ClientCodecConfigurer {
//
// List<HttpErrorReader> getErrorReaders();
//
// ExtendedCustomCodecs customCodecs();
//
// ExtendedClientDefaultCodecs defaultCodecs();
//
// static ExtendedClientCodecConfigurer create(){
// return new DefaultExtendedClientCodecConfigurer();
// }
//
// interface ExtendedClientDefaultCodecs extends ClientDefaultCodecs {
// void httpClientErrorDecoder(HttpClientErrorDecoder clientErrorDecoder);
// void httpServerErrorDecoder(HttpServerErrorDecoder serverErrorDecoder);
// }
//
// interface ExtendedCustomCodecs extends CustomCodecs{
// void errorReader(HttpErrorReader errorReader);
// void errorDecoder(ErrorDecoder errorDecoder);
// }
// }
| import com.webfluxclient.codec.ExtendedClientCodecConfigurer;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.ExchangeFunctions;
import org.springframework.web.reactive.function.client.ExchangeStrategies;
import org.springframework.web.reactive.function.client.WebClient; | package com.webfluxclient.client;
public class DefaultRequestExecutorFactory implements RequestExecutorFactory {
@Override | // Path: src/main/java/com/webfluxclient/codec/ExtendedClientCodecConfigurer.java
// public interface ExtendedClientCodecConfigurer extends ClientCodecConfigurer {
//
// List<HttpErrorReader> getErrorReaders();
//
// ExtendedCustomCodecs customCodecs();
//
// ExtendedClientDefaultCodecs defaultCodecs();
//
// static ExtendedClientCodecConfigurer create(){
// return new DefaultExtendedClientCodecConfigurer();
// }
//
// interface ExtendedClientDefaultCodecs extends ClientDefaultCodecs {
// void httpClientErrorDecoder(HttpClientErrorDecoder clientErrorDecoder);
// void httpServerErrorDecoder(HttpServerErrorDecoder serverErrorDecoder);
// }
//
// interface ExtendedCustomCodecs extends CustomCodecs{
// void errorReader(HttpErrorReader errorReader);
// void errorDecoder(ErrorDecoder errorDecoder);
// }
// }
// Path: src/main/java/com/webfluxclient/client/DefaultRequestExecutorFactory.java
import com.webfluxclient.codec.ExtendedClientCodecConfigurer;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.ExchangeFunctions;
import org.springframework.web.reactive.function.client.ExchangeStrategies;
import org.springframework.web.reactive.function.client.WebClient;
package com.webfluxclient.client;
public class DefaultRequestExecutorFactory implements RequestExecutorFactory {
@Override | public RequestExecutor build(ExtendedClientCodecConfigurer codecConfigurer, ExchangeFilterFunction exchangeFilterFunction) { |
jbrixhe/spring-webflux-client | src/test/java/com/webfluxclient/metadata/MethodMetadataFactoryTest.java | // Path: src/main/java/com/webfluxclient/metadata/request/RequestHeader.java
// @EqualsAndHashCode
// class BasicRequestHeader implements RequestHeader {
//
// private String name;
// private String value;
//
// public BasicRequestHeader(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return Collections.singletonList(value);
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestTemplate.java
// @Getter
// @AllArgsConstructor
// public class RequestTemplate {
// private UriBuilder uriBuilder;
// private HttpMethod httpMethod;
// private RequestHeaders requestHeaders;
// private Integer bodyIndex;
// private ResolvableType requestBodyType;
// private MultiValueMap<Integer, String> variableIndexToName;
//
// public Request apply(Object[] args) {
// return new DefaultRequest(uriBuilder,
// httpMethod,
// requestHeaders.encode(args),
// nameToVariable(args),
// buildBody(args));
// }
//
// private BodyInserter<?, ? super ClientHttpRequest> buildBody(Object[] args) {
// if (bodyIndex == null) {
// return BodyInserters.empty();
// }
//
// Object body = args[bodyIndex];
// if (isDataBufferPublisher(requestBodyType)) {
// return BodyInserters.fromDataBuffers((Publisher<DataBuffer>) body);
// } else if (isPublisher(requestBodyType)) {
// return BodyInserters.fromPublisher((Publisher) body, requestBodyType.getGeneric(0).getRawClass());
// } else if (isResource(requestBodyType)) {
// return BodyInserters.fromResource((Resource) body);
// } else if (isFormData(requestBodyType)) {
// return BodyInserters.fromFormData((MultiValueMap<String, String>) body);
// } else {
// return BodyInserters.fromObject(body);
// }
// }
//
// private Map<String, Object> nameToVariable(Object[] args) {
// Map<String, Object> nameToVariable = new HashMap<>();
// variableIndexToName.forEach((variableIndex, variableNames) -> {
// variableNames
// .forEach(variableName -> nameToVariable.put(variableName, args[variableIndex]));
// });
// return nameToVariable;
// }
// }
| import com.webfluxclient.metadata.request.RequestHeader.BasicRequestHeader;
import com.webfluxclient.metadata.request.RequestTemplate;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.*;
import java.net.URI;
import java.util.AbstractMap.SimpleEntry;
import java.util.List;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; | package com.webfluxclient.metadata;
@RunWith(MockitoJUnitRunner.class)
public class MethodMetadataFactoryTest {
@InjectMocks
private MethodMetadataFactory methodMetadataFactory;
@Test
public void processRootMethodMetadata_withSingleInterface() { | // Path: src/main/java/com/webfluxclient/metadata/request/RequestHeader.java
// @EqualsAndHashCode
// class BasicRequestHeader implements RequestHeader {
//
// private String name;
// private String value;
//
// public BasicRequestHeader(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return Collections.singletonList(value);
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestTemplate.java
// @Getter
// @AllArgsConstructor
// public class RequestTemplate {
// private UriBuilder uriBuilder;
// private HttpMethod httpMethod;
// private RequestHeaders requestHeaders;
// private Integer bodyIndex;
// private ResolvableType requestBodyType;
// private MultiValueMap<Integer, String> variableIndexToName;
//
// public Request apply(Object[] args) {
// return new DefaultRequest(uriBuilder,
// httpMethod,
// requestHeaders.encode(args),
// nameToVariable(args),
// buildBody(args));
// }
//
// private BodyInserter<?, ? super ClientHttpRequest> buildBody(Object[] args) {
// if (bodyIndex == null) {
// return BodyInserters.empty();
// }
//
// Object body = args[bodyIndex];
// if (isDataBufferPublisher(requestBodyType)) {
// return BodyInserters.fromDataBuffers((Publisher<DataBuffer>) body);
// } else if (isPublisher(requestBodyType)) {
// return BodyInserters.fromPublisher((Publisher) body, requestBodyType.getGeneric(0).getRawClass());
// } else if (isResource(requestBodyType)) {
// return BodyInserters.fromResource((Resource) body);
// } else if (isFormData(requestBodyType)) {
// return BodyInserters.fromFormData((MultiValueMap<String, String>) body);
// } else {
// return BodyInserters.fromObject(body);
// }
// }
//
// private Map<String, Object> nameToVariable(Object[] args) {
// Map<String, Object> nameToVariable = new HashMap<>();
// variableIndexToName.forEach((variableIndex, variableNames) -> {
// variableNames
// .forEach(variableName -> nameToVariable.put(variableName, args[variableIndex]));
// });
// return nameToVariable;
// }
// }
// Path: src/test/java/com/webfluxclient/metadata/MethodMetadataFactoryTest.java
import com.webfluxclient.metadata.request.RequestHeader.BasicRequestHeader;
import com.webfluxclient.metadata.request.RequestTemplate;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.*;
import java.net.URI;
import java.util.AbstractMap.SimpleEntry;
import java.util.List;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
package com.webfluxclient.metadata;
@RunWith(MockitoJUnitRunner.class)
public class MethodMetadataFactoryTest {
@InjectMocks
private MethodMetadataFactory methodMetadataFactory;
@Test
public void processRootMethodMetadata_withSingleInterface() { | RequestTemplate requestTemplate = methodMetadataFactory.processTarget(ParentReactiveClient.class, URI.create("")).getRequestTemplate(); |
jbrixhe/spring-webflux-client | src/test/java/com/webfluxclient/metadata/MethodMetadataFactoryTest.java | // Path: src/main/java/com/webfluxclient/metadata/request/RequestHeader.java
// @EqualsAndHashCode
// class BasicRequestHeader implements RequestHeader {
//
// private String name;
// private String value;
//
// public BasicRequestHeader(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return Collections.singletonList(value);
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestTemplate.java
// @Getter
// @AllArgsConstructor
// public class RequestTemplate {
// private UriBuilder uriBuilder;
// private HttpMethod httpMethod;
// private RequestHeaders requestHeaders;
// private Integer bodyIndex;
// private ResolvableType requestBodyType;
// private MultiValueMap<Integer, String> variableIndexToName;
//
// public Request apply(Object[] args) {
// return new DefaultRequest(uriBuilder,
// httpMethod,
// requestHeaders.encode(args),
// nameToVariable(args),
// buildBody(args));
// }
//
// private BodyInserter<?, ? super ClientHttpRequest> buildBody(Object[] args) {
// if (bodyIndex == null) {
// return BodyInserters.empty();
// }
//
// Object body = args[bodyIndex];
// if (isDataBufferPublisher(requestBodyType)) {
// return BodyInserters.fromDataBuffers((Publisher<DataBuffer>) body);
// } else if (isPublisher(requestBodyType)) {
// return BodyInserters.fromPublisher((Publisher) body, requestBodyType.getGeneric(0).getRawClass());
// } else if (isResource(requestBodyType)) {
// return BodyInserters.fromResource((Resource) body);
// } else if (isFormData(requestBodyType)) {
// return BodyInserters.fromFormData((MultiValueMap<String, String>) body);
// } else {
// return BodyInserters.fromObject(body);
// }
// }
//
// private Map<String, Object> nameToVariable(Object[] args) {
// Map<String, Object> nameToVariable = new HashMap<>();
// variableIndexToName.forEach((variableIndex, variableNames) -> {
// variableNames
// .forEach(variableName -> nameToVariable.put(variableName, args[variableIndex]));
// });
// return nameToVariable;
// }
// }
| import com.webfluxclient.metadata.request.RequestHeader.BasicRequestHeader;
import com.webfluxclient.metadata.request.RequestTemplate;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.*;
import java.net.URI;
import java.util.AbstractMap.SimpleEntry;
import java.util.List;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; | assertThatThrownBy(() -> methodMetadataFactory.parsePath(singletonMap("value", new String[]{"/parent", "/child"}), MethodMetadata.newBuilder(URI.create(""))))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
public void parseMethod() {
MethodMetadata.Builder requestTemplateBuilder = MethodMetadata.newBuilder(URI.create(""));
methodMetadataFactory.parseMethod(singletonMap("method", new RequestMethod[]{RequestMethod.GET}), requestTemplateBuilder);
assertThat(requestTemplateBuilder.build().getRequestTemplate().getHttpMethod()).isEqualTo(HttpMethod.GET);
}
@Test
public void parseMethod_withNoMethod() {
MethodMetadata.Builder requestTemplateBuilder = MethodMetadata.newBuilder(URI.create(""));
methodMetadataFactory.parseMethod(singletonMap("method", new RequestMethod[]{}), requestTemplateBuilder);
assertThat(requestTemplateBuilder.build().getRequestTemplate().getHttpMethod()).isEqualTo(HttpMethod.GET);
}
@Test
public void parseMethod_withTooManyMethod() {
assertThatThrownBy(() -> methodMetadataFactory.parseMethod(singletonMap("method", new RequestMethod[]{RequestMethod.PUT, RequestMethod.POST}), MethodMetadata.newBuilder(URI.create(""))))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
public void parseHeaders() {
MethodMetadata.Builder requestTemplateBuilder = MethodMetadata.newBuilder(URI.create(""));
methodMetadataFactory.parseHeaders(singletonMap("headers", new String[]{"header1=value1", "header2=value2"}), requestTemplateBuilder);
assertThat(requestTemplateBuilder.build().getRequestTemplate().getRequestHeaders().getHeaders())
.containsOnlyKeys("header1", "header2") | // Path: src/main/java/com/webfluxclient/metadata/request/RequestHeader.java
// @EqualsAndHashCode
// class BasicRequestHeader implements RequestHeader {
//
// private String name;
// private String value;
//
// public BasicRequestHeader(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return Collections.singletonList(value);
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestTemplate.java
// @Getter
// @AllArgsConstructor
// public class RequestTemplate {
// private UriBuilder uriBuilder;
// private HttpMethod httpMethod;
// private RequestHeaders requestHeaders;
// private Integer bodyIndex;
// private ResolvableType requestBodyType;
// private MultiValueMap<Integer, String> variableIndexToName;
//
// public Request apply(Object[] args) {
// return new DefaultRequest(uriBuilder,
// httpMethod,
// requestHeaders.encode(args),
// nameToVariable(args),
// buildBody(args));
// }
//
// private BodyInserter<?, ? super ClientHttpRequest> buildBody(Object[] args) {
// if (bodyIndex == null) {
// return BodyInserters.empty();
// }
//
// Object body = args[bodyIndex];
// if (isDataBufferPublisher(requestBodyType)) {
// return BodyInserters.fromDataBuffers((Publisher<DataBuffer>) body);
// } else if (isPublisher(requestBodyType)) {
// return BodyInserters.fromPublisher((Publisher) body, requestBodyType.getGeneric(0).getRawClass());
// } else if (isResource(requestBodyType)) {
// return BodyInserters.fromResource((Resource) body);
// } else if (isFormData(requestBodyType)) {
// return BodyInserters.fromFormData((MultiValueMap<String, String>) body);
// } else {
// return BodyInserters.fromObject(body);
// }
// }
//
// private Map<String, Object> nameToVariable(Object[] args) {
// Map<String, Object> nameToVariable = new HashMap<>();
// variableIndexToName.forEach((variableIndex, variableNames) -> {
// variableNames
// .forEach(variableName -> nameToVariable.put(variableName, args[variableIndex]));
// });
// return nameToVariable;
// }
// }
// Path: src/test/java/com/webfluxclient/metadata/MethodMetadataFactoryTest.java
import com.webfluxclient.metadata.request.RequestHeader.BasicRequestHeader;
import com.webfluxclient.metadata.request.RequestTemplate;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.*;
import java.net.URI;
import java.util.AbstractMap.SimpleEntry;
import java.util.List;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
assertThatThrownBy(() -> methodMetadataFactory.parsePath(singletonMap("value", new String[]{"/parent", "/child"}), MethodMetadata.newBuilder(URI.create(""))))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
public void parseMethod() {
MethodMetadata.Builder requestTemplateBuilder = MethodMetadata.newBuilder(URI.create(""));
methodMetadataFactory.parseMethod(singletonMap("method", new RequestMethod[]{RequestMethod.GET}), requestTemplateBuilder);
assertThat(requestTemplateBuilder.build().getRequestTemplate().getHttpMethod()).isEqualTo(HttpMethod.GET);
}
@Test
public void parseMethod_withNoMethod() {
MethodMetadata.Builder requestTemplateBuilder = MethodMetadata.newBuilder(URI.create(""));
methodMetadataFactory.parseMethod(singletonMap("method", new RequestMethod[]{}), requestTemplateBuilder);
assertThat(requestTemplateBuilder.build().getRequestTemplate().getHttpMethod()).isEqualTo(HttpMethod.GET);
}
@Test
public void parseMethod_withTooManyMethod() {
assertThatThrownBy(() -> methodMetadataFactory.parseMethod(singletonMap("method", new RequestMethod[]{RequestMethod.PUT, RequestMethod.POST}), MethodMetadata.newBuilder(URI.create(""))))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
public void parseHeaders() {
MethodMetadata.Builder requestTemplateBuilder = MethodMetadata.newBuilder(URI.create(""));
methodMetadataFactory.parseHeaders(singletonMap("headers", new String[]{"header1=value1", "header2=value2"}), requestTemplateBuilder);
assertThat(requestTemplateBuilder.build().getRequestTemplate().getRequestHeaders().getHeaders())
.containsOnlyKeys("header1", "header2") | .containsValues(new BasicRequestHeader("header1", "value1"), new BasicRequestHeader("header2", "value2")); |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/metadata/MethodMetadataFactory.java | // Path: src/main/java/com/webfluxclient/metadata/annotation/AnnotatedParameterProcessor.java
// public interface AnnotatedParameterProcessor {
//
// Class<? extends Annotation> getAnnotationType();
//
// void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType);
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/PathVariableParameterProcessor.java
// public class PathVariableParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return PathVariable.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// String name = PathVariable.class.cast(annotation).value();
// Assert.isTrue(StringUtils.hasText(name), "");
// requestTemplateBuilder.addPathIndex(integer, name);
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestBodyParameterProcessor.java
// public class RequestBodyParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestBody.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer index, Type parameterType) {
// requestTemplateBuilder.body(index, parameterType);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestHeaderParameterProcessor.java
// public class RequestHeaderParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestHeader.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestHeader requestParam = RequestHeader.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addHeader(integer, name);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestParamParameterProcessor.java
// public class RequestParamParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestParam.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestParam requestParam = RequestParam.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addParameter(integer, name);
// }
//
// }
| import com.webfluxclient.metadata.annotation.AnnotatedParameterProcessor;
import com.webfluxclient.metadata.annotation.PathVariableParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestBodyParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestHeaderParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestParamParameterProcessor;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.core.type.StandardMethodMetadata;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream; | package com.webfluxclient.metadata;
public class MethodMetadataFactory {
private Map<Class<? extends Annotation>, AnnotatedParameterProcessor> annotatedArgumentProcessors;
public MethodMetadataFactory() {
this.annotatedArgumentProcessors = Stream.of( | // Path: src/main/java/com/webfluxclient/metadata/annotation/AnnotatedParameterProcessor.java
// public interface AnnotatedParameterProcessor {
//
// Class<? extends Annotation> getAnnotationType();
//
// void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType);
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/PathVariableParameterProcessor.java
// public class PathVariableParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return PathVariable.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// String name = PathVariable.class.cast(annotation).value();
// Assert.isTrue(StringUtils.hasText(name), "");
// requestTemplateBuilder.addPathIndex(integer, name);
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestBodyParameterProcessor.java
// public class RequestBodyParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestBody.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer index, Type parameterType) {
// requestTemplateBuilder.body(index, parameterType);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestHeaderParameterProcessor.java
// public class RequestHeaderParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestHeader.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestHeader requestParam = RequestHeader.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addHeader(integer, name);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestParamParameterProcessor.java
// public class RequestParamParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestParam.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestParam requestParam = RequestParam.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addParameter(integer, name);
// }
//
// }
// Path: src/main/java/com/webfluxclient/metadata/MethodMetadataFactory.java
import com.webfluxclient.metadata.annotation.AnnotatedParameterProcessor;
import com.webfluxclient.metadata.annotation.PathVariableParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestBodyParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestHeaderParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestParamParameterProcessor;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.core.type.StandardMethodMetadata;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
package com.webfluxclient.metadata;
public class MethodMetadataFactory {
private Map<Class<? extends Annotation>, AnnotatedParameterProcessor> annotatedArgumentProcessors;
public MethodMetadataFactory() {
this.annotatedArgumentProcessors = Stream.of( | new PathVariableParameterProcessor(), |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/metadata/MethodMetadataFactory.java | // Path: src/main/java/com/webfluxclient/metadata/annotation/AnnotatedParameterProcessor.java
// public interface AnnotatedParameterProcessor {
//
// Class<? extends Annotation> getAnnotationType();
//
// void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType);
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/PathVariableParameterProcessor.java
// public class PathVariableParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return PathVariable.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// String name = PathVariable.class.cast(annotation).value();
// Assert.isTrue(StringUtils.hasText(name), "");
// requestTemplateBuilder.addPathIndex(integer, name);
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestBodyParameterProcessor.java
// public class RequestBodyParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestBody.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer index, Type parameterType) {
// requestTemplateBuilder.body(index, parameterType);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestHeaderParameterProcessor.java
// public class RequestHeaderParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestHeader.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestHeader requestParam = RequestHeader.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addHeader(integer, name);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestParamParameterProcessor.java
// public class RequestParamParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestParam.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestParam requestParam = RequestParam.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addParameter(integer, name);
// }
//
// }
| import com.webfluxclient.metadata.annotation.AnnotatedParameterProcessor;
import com.webfluxclient.metadata.annotation.PathVariableParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestBodyParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestHeaderParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestParamParameterProcessor;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.core.type.StandardMethodMetadata;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream; | package com.webfluxclient.metadata;
public class MethodMetadataFactory {
private Map<Class<? extends Annotation>, AnnotatedParameterProcessor> annotatedArgumentProcessors;
public MethodMetadataFactory() {
this.annotatedArgumentProcessors = Stream.of(
new PathVariableParameterProcessor(), | // Path: src/main/java/com/webfluxclient/metadata/annotation/AnnotatedParameterProcessor.java
// public interface AnnotatedParameterProcessor {
//
// Class<? extends Annotation> getAnnotationType();
//
// void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType);
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/PathVariableParameterProcessor.java
// public class PathVariableParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return PathVariable.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// String name = PathVariable.class.cast(annotation).value();
// Assert.isTrue(StringUtils.hasText(name), "");
// requestTemplateBuilder.addPathIndex(integer, name);
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestBodyParameterProcessor.java
// public class RequestBodyParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestBody.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer index, Type parameterType) {
// requestTemplateBuilder.body(index, parameterType);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestHeaderParameterProcessor.java
// public class RequestHeaderParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestHeader.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestHeader requestParam = RequestHeader.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addHeader(integer, name);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestParamParameterProcessor.java
// public class RequestParamParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestParam.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestParam requestParam = RequestParam.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addParameter(integer, name);
// }
//
// }
// Path: src/main/java/com/webfluxclient/metadata/MethodMetadataFactory.java
import com.webfluxclient.metadata.annotation.AnnotatedParameterProcessor;
import com.webfluxclient.metadata.annotation.PathVariableParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestBodyParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestHeaderParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestParamParameterProcessor;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.core.type.StandardMethodMetadata;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
package com.webfluxclient.metadata;
public class MethodMetadataFactory {
private Map<Class<? extends Annotation>, AnnotatedParameterProcessor> annotatedArgumentProcessors;
public MethodMetadataFactory() {
this.annotatedArgumentProcessors = Stream.of(
new PathVariableParameterProcessor(), | new RequestParamParameterProcessor(), |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/metadata/MethodMetadataFactory.java | // Path: src/main/java/com/webfluxclient/metadata/annotation/AnnotatedParameterProcessor.java
// public interface AnnotatedParameterProcessor {
//
// Class<? extends Annotation> getAnnotationType();
//
// void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType);
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/PathVariableParameterProcessor.java
// public class PathVariableParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return PathVariable.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// String name = PathVariable.class.cast(annotation).value();
// Assert.isTrue(StringUtils.hasText(name), "");
// requestTemplateBuilder.addPathIndex(integer, name);
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestBodyParameterProcessor.java
// public class RequestBodyParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestBody.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer index, Type parameterType) {
// requestTemplateBuilder.body(index, parameterType);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestHeaderParameterProcessor.java
// public class RequestHeaderParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestHeader.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestHeader requestParam = RequestHeader.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addHeader(integer, name);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestParamParameterProcessor.java
// public class RequestParamParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestParam.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestParam requestParam = RequestParam.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addParameter(integer, name);
// }
//
// }
| import com.webfluxclient.metadata.annotation.AnnotatedParameterProcessor;
import com.webfluxclient.metadata.annotation.PathVariableParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestBodyParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestHeaderParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestParamParameterProcessor;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.core.type.StandardMethodMetadata;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream; | package com.webfluxclient.metadata;
public class MethodMetadataFactory {
private Map<Class<? extends Annotation>, AnnotatedParameterProcessor> annotatedArgumentProcessors;
public MethodMetadataFactory() {
this.annotatedArgumentProcessors = Stream.of(
new PathVariableParameterProcessor(),
new RequestParamParameterProcessor(), | // Path: src/main/java/com/webfluxclient/metadata/annotation/AnnotatedParameterProcessor.java
// public interface AnnotatedParameterProcessor {
//
// Class<? extends Annotation> getAnnotationType();
//
// void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType);
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/PathVariableParameterProcessor.java
// public class PathVariableParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return PathVariable.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// String name = PathVariable.class.cast(annotation).value();
// Assert.isTrue(StringUtils.hasText(name), "");
// requestTemplateBuilder.addPathIndex(integer, name);
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestBodyParameterProcessor.java
// public class RequestBodyParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestBody.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer index, Type parameterType) {
// requestTemplateBuilder.body(index, parameterType);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestHeaderParameterProcessor.java
// public class RequestHeaderParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestHeader.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestHeader requestParam = RequestHeader.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addHeader(integer, name);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestParamParameterProcessor.java
// public class RequestParamParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestParam.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestParam requestParam = RequestParam.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addParameter(integer, name);
// }
//
// }
// Path: src/main/java/com/webfluxclient/metadata/MethodMetadataFactory.java
import com.webfluxclient.metadata.annotation.AnnotatedParameterProcessor;
import com.webfluxclient.metadata.annotation.PathVariableParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestBodyParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestHeaderParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestParamParameterProcessor;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.core.type.StandardMethodMetadata;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
package com.webfluxclient.metadata;
public class MethodMetadataFactory {
private Map<Class<? extends Annotation>, AnnotatedParameterProcessor> annotatedArgumentProcessors;
public MethodMetadataFactory() {
this.annotatedArgumentProcessors = Stream.of(
new PathVariableParameterProcessor(),
new RequestParamParameterProcessor(), | new RequestHeaderParameterProcessor(), |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/metadata/MethodMetadataFactory.java | // Path: src/main/java/com/webfluxclient/metadata/annotation/AnnotatedParameterProcessor.java
// public interface AnnotatedParameterProcessor {
//
// Class<? extends Annotation> getAnnotationType();
//
// void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType);
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/PathVariableParameterProcessor.java
// public class PathVariableParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return PathVariable.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// String name = PathVariable.class.cast(annotation).value();
// Assert.isTrue(StringUtils.hasText(name), "");
// requestTemplateBuilder.addPathIndex(integer, name);
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestBodyParameterProcessor.java
// public class RequestBodyParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestBody.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer index, Type parameterType) {
// requestTemplateBuilder.body(index, parameterType);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestHeaderParameterProcessor.java
// public class RequestHeaderParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestHeader.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestHeader requestParam = RequestHeader.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addHeader(integer, name);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestParamParameterProcessor.java
// public class RequestParamParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestParam.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestParam requestParam = RequestParam.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addParameter(integer, name);
// }
//
// }
| import com.webfluxclient.metadata.annotation.AnnotatedParameterProcessor;
import com.webfluxclient.metadata.annotation.PathVariableParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestBodyParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestHeaderParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestParamParameterProcessor;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.core.type.StandardMethodMetadata;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream; | package com.webfluxclient.metadata;
public class MethodMetadataFactory {
private Map<Class<? extends Annotation>, AnnotatedParameterProcessor> annotatedArgumentProcessors;
public MethodMetadataFactory() {
this.annotatedArgumentProcessors = Stream.of(
new PathVariableParameterProcessor(),
new RequestParamParameterProcessor(),
new RequestHeaderParameterProcessor(), | // Path: src/main/java/com/webfluxclient/metadata/annotation/AnnotatedParameterProcessor.java
// public interface AnnotatedParameterProcessor {
//
// Class<? extends Annotation> getAnnotationType();
//
// void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType);
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/PathVariableParameterProcessor.java
// public class PathVariableParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return PathVariable.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// String name = PathVariable.class.cast(annotation).value();
// Assert.isTrue(StringUtils.hasText(name), "");
// requestTemplateBuilder.addPathIndex(integer, name);
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestBodyParameterProcessor.java
// public class RequestBodyParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestBody.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer index, Type parameterType) {
// requestTemplateBuilder.body(index, parameterType);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestHeaderParameterProcessor.java
// public class RequestHeaderParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestHeader.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestHeader requestParam = RequestHeader.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addHeader(integer, name);
// }
//
// }
//
// Path: src/main/java/com/webfluxclient/metadata/annotation/RequestParamParameterProcessor.java
// public class RequestParamParameterProcessor implements AnnotatedParameterProcessor {
//
// @Override
// public Class<? extends Annotation> getAnnotationType() {
// return RequestParam.class;
// }
//
// @Override
// public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) {
// RequestParam requestParam = RequestParam.class.cast(annotation);
// String name = requestParam.value();
// Assert.isTrue(StringUtils.hasText(name), "");
//
// requestTemplateBuilder.addParameter(integer, name);
// }
//
// }
// Path: src/main/java/com/webfluxclient/metadata/MethodMetadataFactory.java
import com.webfluxclient.metadata.annotation.AnnotatedParameterProcessor;
import com.webfluxclient.metadata.annotation.PathVariableParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestBodyParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestHeaderParameterProcessor;
import com.webfluxclient.metadata.annotation.RequestParamParameterProcessor;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.core.type.StandardMethodMetadata;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
package com.webfluxclient.metadata;
public class MethodMetadataFactory {
private Map<Class<? extends Annotation>, AnnotatedParameterProcessor> annotatedArgumentProcessors;
public MethodMetadataFactory() {
this.annotatedArgumentProcessors = Stream.of(
new PathVariableParameterProcessor(),
new RequestParamParameterProcessor(),
new RequestHeaderParameterProcessor(), | new RequestBodyParameterProcessor()) |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/metadata/annotation/AnnotatedParameterProcessor.java | // Path: src/main/java/com/webfluxclient/metadata/MethodMetadata.java
// @Getter
// public class MethodMetadata {
// private Method targetMethod;
// private ResolvableType responseBodyType;
// private RequestTemplate requestTemplate;
//
// private MethodMetadata(Builder builder) {
// targetMethod = builder.targetMethod;
// responseBodyType = builder.returnType;
// requestTemplate = new RequestTemplate(
// builder.uriBuilder,
// builder.httpMethod,
// new RequestHeaders(builder.headers, builder.headerIndexToName),
// builder.bodyIndex,
// builder.bodyType,
// builder.variableIndexToName);
// }
//
// public static Builder newBuilder(URI baseUri) {
// return new Builder(baseUri.getScheme(), baseUri.getAuthority());
// }
//
// public static Builder newBuilder(MethodMetadata other) {
// return new Builder(other);
// }
//
// public static class Builder {
// private UriBuilder uriBuilder;
// private MultiValueMap<Integer, String> variableIndexToName;
// private Map<String, RequestHeader> headers;
// private Map<Integer, String> headerIndexToName;
// private HttpMethod httpMethod;
// private Method targetMethod;
// private Integer bodyIndex;
// private ResolvableType returnType;
// private ResolvableType bodyType;
//
// private Builder() {
// variableIndexToName = new LinkedMultiValueMap<>();
// headers = new HashMap<>();
// headerIndexToName = new HashMap<>();
// }
//
// public Builder(String scheme, String authority) {
// this();
// if (scheme != null && authority != null) {
// uriBuilder = new DefaultUriBuilderFactory(scheme + "://" + authority).builder();
// }
// else {
// uriBuilder = new DefaultUriBuilderFactory().builder();
// }
// }
//
// public Builder(MethodMetadata other) {
// this();
// uriBuilder = new DefaultUriBuilderFactory(other.getRequestTemplate().getUriBuilder().build().toString()).builder();
// variableIndexToName.putAll(other.getRequestTemplate().getVariableIndexToName());
// headers.putAll(other.getRequestTemplate().getRequestHeaders().getHeaders());
// headerIndexToName.putAll(other.getRequestTemplate().getRequestHeaders().getIndexToName());
// httpMethod = other.getRequestTemplate().getHttpMethod();
// targetMethod = other.getTargetMethod();
// }
//
// public Builder addPath(String path) {
// uriBuilder.path(path);
// return this;
// }
//
// public Builder addPathIndex(Integer index, String pathVariable) {
// this.variableIndexToName.add(index, pathVariable);
// return this;
// }
//
// public Builder addHeader(String name, String value) {
// headers.put(name, new RequestHeader.BasicRequestHeader(name, value));
// return this;
// }
//
// public Builder addHeader(Integer index, String name) {
// headers.put(name, new RequestHeader.DynamicRequestHeader(name));
// headerIndexToName.put(index, name);
// return this;
// }
//
// public Builder addParameter(Integer index, String name) {
// variableIndexToName.add(index, name);
// uriBuilder.query(name + "={" + name + "}");
// return this;
// }
//
// public Builder httpMethod(HttpMethod httpMethod) {
// this.httpMethod = httpMethod;
// return this;
// }
//
// public Builder body(Integer bodyIndex, Type bodyType) {
// if (this.bodyType != null && this.bodyIndex != null) {
// throw new IllegalArgumentException();
// }
//
// this.bodyIndex = bodyIndex;
// this.bodyType = ResolvableType.forType(bodyType);
// return this;
// }
//
// public Builder targetMethod(Method targetMethod) {
// this.targetMethod = targetMethod;
// this.returnType = ResolvableType.forMethodReturnType(targetMethod);
// return this;
// }
//
// public MethodMetadata build() {
// return new MethodMetadata(this);
// }
// }
// }
| import com.webfluxclient.metadata.MethodMetadata;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type; | package com.webfluxclient.metadata.annotation;
public interface AnnotatedParameterProcessor {
Class<? extends Annotation> getAnnotationType();
| // Path: src/main/java/com/webfluxclient/metadata/MethodMetadata.java
// @Getter
// public class MethodMetadata {
// private Method targetMethod;
// private ResolvableType responseBodyType;
// private RequestTemplate requestTemplate;
//
// private MethodMetadata(Builder builder) {
// targetMethod = builder.targetMethod;
// responseBodyType = builder.returnType;
// requestTemplate = new RequestTemplate(
// builder.uriBuilder,
// builder.httpMethod,
// new RequestHeaders(builder.headers, builder.headerIndexToName),
// builder.bodyIndex,
// builder.bodyType,
// builder.variableIndexToName);
// }
//
// public static Builder newBuilder(URI baseUri) {
// return new Builder(baseUri.getScheme(), baseUri.getAuthority());
// }
//
// public static Builder newBuilder(MethodMetadata other) {
// return new Builder(other);
// }
//
// public static class Builder {
// private UriBuilder uriBuilder;
// private MultiValueMap<Integer, String> variableIndexToName;
// private Map<String, RequestHeader> headers;
// private Map<Integer, String> headerIndexToName;
// private HttpMethod httpMethod;
// private Method targetMethod;
// private Integer bodyIndex;
// private ResolvableType returnType;
// private ResolvableType bodyType;
//
// private Builder() {
// variableIndexToName = new LinkedMultiValueMap<>();
// headers = new HashMap<>();
// headerIndexToName = new HashMap<>();
// }
//
// public Builder(String scheme, String authority) {
// this();
// if (scheme != null && authority != null) {
// uriBuilder = new DefaultUriBuilderFactory(scheme + "://" + authority).builder();
// }
// else {
// uriBuilder = new DefaultUriBuilderFactory().builder();
// }
// }
//
// public Builder(MethodMetadata other) {
// this();
// uriBuilder = new DefaultUriBuilderFactory(other.getRequestTemplate().getUriBuilder().build().toString()).builder();
// variableIndexToName.putAll(other.getRequestTemplate().getVariableIndexToName());
// headers.putAll(other.getRequestTemplate().getRequestHeaders().getHeaders());
// headerIndexToName.putAll(other.getRequestTemplate().getRequestHeaders().getIndexToName());
// httpMethod = other.getRequestTemplate().getHttpMethod();
// targetMethod = other.getTargetMethod();
// }
//
// public Builder addPath(String path) {
// uriBuilder.path(path);
// return this;
// }
//
// public Builder addPathIndex(Integer index, String pathVariable) {
// this.variableIndexToName.add(index, pathVariable);
// return this;
// }
//
// public Builder addHeader(String name, String value) {
// headers.put(name, new RequestHeader.BasicRequestHeader(name, value));
// return this;
// }
//
// public Builder addHeader(Integer index, String name) {
// headers.put(name, new RequestHeader.DynamicRequestHeader(name));
// headerIndexToName.put(index, name);
// return this;
// }
//
// public Builder addParameter(Integer index, String name) {
// variableIndexToName.add(index, name);
// uriBuilder.query(name + "={" + name + "}");
// return this;
// }
//
// public Builder httpMethod(HttpMethod httpMethod) {
// this.httpMethod = httpMethod;
// return this;
// }
//
// public Builder body(Integer bodyIndex, Type bodyType) {
// if (this.bodyType != null && this.bodyIndex != null) {
// throw new IllegalArgumentException();
// }
//
// this.bodyIndex = bodyIndex;
// this.bodyType = ResolvableType.forType(bodyType);
// return this;
// }
//
// public Builder targetMethod(Method targetMethod) {
// this.targetMethod = targetMethod;
// this.returnType = ResolvableType.forMethodReturnType(targetMethod);
// return this;
// }
//
// public MethodMetadata build() {
// return new MethodMetadata(this);
// }
// }
// }
// Path: src/main/java/com/webfluxclient/metadata/annotation/AnnotatedParameterProcessor.java
import com.webfluxclient.metadata.MethodMetadata;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
package com.webfluxclient.metadata.annotation;
public interface AnnotatedParameterProcessor {
Class<? extends Annotation> getAnnotationType();
| void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType); |
jbrixhe/spring-webflux-client | src/test/java/com/webfluxclient/metadata/request/RequestHeadersTest.java | // Path: src/main/java/com/webfluxclient/metadata/request/RequestHeader.java
// @EqualsAndHashCode
// class DynamicRequestHeader implements RequestHeader {
//
// private String name;
//
// public DynamicRequestHeader(String name) {
// this.name = name;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return parameterValues.getOrDefault(name, Collections.emptyList());
// }
//
// }
| import com.webfluxclient.metadata.request.RequestHeader.DynamicRequestHeader;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.http.HttpHeaders;
import java.util.AbstractMap.SimpleEntry;
import java.util.HashMap;
import java.util.Map;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap; | package com.webfluxclient.metadata.request;
@RunWith(MockitoJUnitRunner.class)
public class RequestHeadersTest {
@Test
public void requestHeaders_withDynamicHeader() {
RequestHeaders requestHeaders = getDynamic("header1", 0);
HttpHeaders httpHeaders = requestHeaders.encode(new Object[]{"headerDynamicHeader"});
Assertions.assertThat(httpHeaders)
.containsExactly(new SimpleEntry<>("header1", singletonList("headerDynamicHeader")));
}
@Test
public void requestHeaders_withStaticHeader() {
RequestHeaders requestHeaders = getBasic("header1", "headerBasicValue");
HttpHeaders httpHeaders = requestHeaders.encode(new Object[]{});
Assertions.assertThat(httpHeaders)
.containsExactly(new SimpleEntry<>("header1", singletonList("headerBasicValue")));
}
@Test
public void requestHeaders_withStaticAndDynamicHeaders() {
Map<String, RequestHeader> requestHeaderByName = new HashMap<>(); | // Path: src/main/java/com/webfluxclient/metadata/request/RequestHeader.java
// @EqualsAndHashCode
// class DynamicRequestHeader implements RequestHeader {
//
// private String name;
//
// public DynamicRequestHeader(String name) {
// this.name = name;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return parameterValues.getOrDefault(name, Collections.emptyList());
// }
//
// }
// Path: src/test/java/com/webfluxclient/metadata/request/RequestHeadersTest.java
import com.webfluxclient.metadata.request.RequestHeader.DynamicRequestHeader;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.http.HttpHeaders;
import java.util.AbstractMap.SimpleEntry;
import java.util.HashMap;
import java.util.Map;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
package com.webfluxclient.metadata.request;
@RunWith(MockitoJUnitRunner.class)
public class RequestHeadersTest {
@Test
public void requestHeaders_withDynamicHeader() {
RequestHeaders requestHeaders = getDynamic("header1", 0);
HttpHeaders httpHeaders = requestHeaders.encode(new Object[]{"headerDynamicHeader"});
Assertions.assertThat(httpHeaders)
.containsExactly(new SimpleEntry<>("header1", singletonList("headerDynamicHeader")));
}
@Test
public void requestHeaders_withStaticHeader() {
RequestHeaders requestHeaders = getBasic("header1", "headerBasicValue");
HttpHeaders httpHeaders = requestHeaders.encode(new Object[]{});
Assertions.assertThat(httpHeaders)
.containsExactly(new SimpleEntry<>("header1", singletonList("headerBasicValue")));
}
@Test
public void requestHeaders_withStaticAndDynamicHeaders() {
Map<String, RequestHeader> requestHeaderByName = new HashMap<>(); | requestHeaderByName.put("header1", new RequestHeader.DynamicRequestHeader("header1")); |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/client/ExchangeFilterFunctionFactory.java | // Path: src/main/java/com/webfluxclient/LogLevel.java
// public enum LogLevel {
// /** No logs. */
// NONE,
//
// /**
// * Logs request and response lines.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: application/json
// *
// * <-- 200 OK POST /hello (22ms)
// * }</pre>
// */
// BASIC,
//
// /**
// * Logs request and response lines and their respective headers.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: plain/text
// * Headers:
// * - Accept-Language: en
// * - Accept-Charset: UTF-8
// * --> END POST
// *
// * <-- 200 OK POST /hello (22ms)
// * Headers:
// * - Content-Type: plain/text
// * <-- END HTTP
// * }</pre>
// */
// HEADERS
// }
//
// Path: src/main/java/com/webfluxclient/Logger.java
// public interface Logger {
// void log(Supplier<String> messageSupplier);
// void log(String message);
// }
//
// Path: src/main/java/com/webfluxclient/RequestProcessor.java
// @FunctionalInterface
// public interface RequestProcessor {
//
// ClientRequest process(ClientRequest request);
//
// default RequestProcessor andThen(RequestProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
//
// Path: src/main/java/com/webfluxclient/ResponseProcessor.java
// @FunctionalInterface
// public interface ResponseProcessor {
//
// ClientResponse process(ClientResponse clientResponse);
//
// default ResponseProcessor andThen(ResponseProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
| import com.webfluxclient.LogLevel;
import com.webfluxclient.Logger;
import com.webfluxclient.RequestProcessor;
import com.webfluxclient.ResponseProcessor;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import java.util.List; | package com.webfluxclient.client;
public interface ExchangeFilterFunctionFactory {
ExchangeFilterFunction build(List<RequestProcessor> requestProcessors, | // Path: src/main/java/com/webfluxclient/LogLevel.java
// public enum LogLevel {
// /** No logs. */
// NONE,
//
// /**
// * Logs request and response lines.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: application/json
// *
// * <-- 200 OK POST /hello (22ms)
// * }</pre>
// */
// BASIC,
//
// /**
// * Logs request and response lines and their respective headers.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: plain/text
// * Headers:
// * - Accept-Language: en
// * - Accept-Charset: UTF-8
// * --> END POST
// *
// * <-- 200 OK POST /hello (22ms)
// * Headers:
// * - Content-Type: plain/text
// * <-- END HTTP
// * }</pre>
// */
// HEADERS
// }
//
// Path: src/main/java/com/webfluxclient/Logger.java
// public interface Logger {
// void log(Supplier<String> messageSupplier);
// void log(String message);
// }
//
// Path: src/main/java/com/webfluxclient/RequestProcessor.java
// @FunctionalInterface
// public interface RequestProcessor {
//
// ClientRequest process(ClientRequest request);
//
// default RequestProcessor andThen(RequestProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
//
// Path: src/main/java/com/webfluxclient/ResponseProcessor.java
// @FunctionalInterface
// public interface ResponseProcessor {
//
// ClientResponse process(ClientResponse clientResponse);
//
// default ResponseProcessor andThen(ResponseProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
// Path: src/main/java/com/webfluxclient/client/ExchangeFilterFunctionFactory.java
import com.webfluxclient.LogLevel;
import com.webfluxclient.Logger;
import com.webfluxclient.RequestProcessor;
import com.webfluxclient.ResponseProcessor;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import java.util.List;
package com.webfluxclient.client;
public interface ExchangeFilterFunctionFactory {
ExchangeFilterFunction build(List<RequestProcessor> requestProcessors, | List<ResponseProcessor> responseProcessors, |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/client/ExchangeFilterFunctionFactory.java | // Path: src/main/java/com/webfluxclient/LogLevel.java
// public enum LogLevel {
// /** No logs. */
// NONE,
//
// /**
// * Logs request and response lines.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: application/json
// *
// * <-- 200 OK POST /hello (22ms)
// * }</pre>
// */
// BASIC,
//
// /**
// * Logs request and response lines and their respective headers.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: plain/text
// * Headers:
// * - Accept-Language: en
// * - Accept-Charset: UTF-8
// * --> END POST
// *
// * <-- 200 OK POST /hello (22ms)
// * Headers:
// * - Content-Type: plain/text
// * <-- END HTTP
// * }</pre>
// */
// HEADERS
// }
//
// Path: src/main/java/com/webfluxclient/Logger.java
// public interface Logger {
// void log(Supplier<String> messageSupplier);
// void log(String message);
// }
//
// Path: src/main/java/com/webfluxclient/RequestProcessor.java
// @FunctionalInterface
// public interface RequestProcessor {
//
// ClientRequest process(ClientRequest request);
//
// default RequestProcessor andThen(RequestProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
//
// Path: src/main/java/com/webfluxclient/ResponseProcessor.java
// @FunctionalInterface
// public interface ResponseProcessor {
//
// ClientResponse process(ClientResponse clientResponse);
//
// default ResponseProcessor andThen(ResponseProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
| import com.webfluxclient.LogLevel;
import com.webfluxclient.Logger;
import com.webfluxclient.RequestProcessor;
import com.webfluxclient.ResponseProcessor;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import java.util.List; | package com.webfluxclient.client;
public interface ExchangeFilterFunctionFactory {
ExchangeFilterFunction build(List<RequestProcessor> requestProcessors,
List<ResponseProcessor> responseProcessors, | // Path: src/main/java/com/webfluxclient/LogLevel.java
// public enum LogLevel {
// /** No logs. */
// NONE,
//
// /**
// * Logs request and response lines.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: application/json
// *
// * <-- 200 OK POST /hello (22ms)
// * }</pre>
// */
// BASIC,
//
// /**
// * Logs request and response lines and their respective headers.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: plain/text
// * Headers:
// * - Accept-Language: en
// * - Accept-Charset: UTF-8
// * --> END POST
// *
// * <-- 200 OK POST /hello (22ms)
// * Headers:
// * - Content-Type: plain/text
// * <-- END HTTP
// * }</pre>
// */
// HEADERS
// }
//
// Path: src/main/java/com/webfluxclient/Logger.java
// public interface Logger {
// void log(Supplier<String> messageSupplier);
// void log(String message);
// }
//
// Path: src/main/java/com/webfluxclient/RequestProcessor.java
// @FunctionalInterface
// public interface RequestProcessor {
//
// ClientRequest process(ClientRequest request);
//
// default RequestProcessor andThen(RequestProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
//
// Path: src/main/java/com/webfluxclient/ResponseProcessor.java
// @FunctionalInterface
// public interface ResponseProcessor {
//
// ClientResponse process(ClientResponse clientResponse);
//
// default ResponseProcessor andThen(ResponseProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
// Path: src/main/java/com/webfluxclient/client/ExchangeFilterFunctionFactory.java
import com.webfluxclient.LogLevel;
import com.webfluxclient.Logger;
import com.webfluxclient.RequestProcessor;
import com.webfluxclient.ResponseProcessor;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import java.util.List;
package com.webfluxclient.client;
public interface ExchangeFilterFunctionFactory {
ExchangeFilterFunction build(List<RequestProcessor> requestProcessors,
List<ResponseProcessor> responseProcessors, | Logger logger, |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/client/ExchangeFilterFunctionFactory.java | // Path: src/main/java/com/webfluxclient/LogLevel.java
// public enum LogLevel {
// /** No logs. */
// NONE,
//
// /**
// * Logs request and response lines.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: application/json
// *
// * <-- 200 OK POST /hello (22ms)
// * }</pre>
// */
// BASIC,
//
// /**
// * Logs request and response lines and their respective headers.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: plain/text
// * Headers:
// * - Accept-Language: en
// * - Accept-Charset: UTF-8
// * --> END POST
// *
// * <-- 200 OK POST /hello (22ms)
// * Headers:
// * - Content-Type: plain/text
// * <-- END HTTP
// * }</pre>
// */
// HEADERS
// }
//
// Path: src/main/java/com/webfluxclient/Logger.java
// public interface Logger {
// void log(Supplier<String> messageSupplier);
// void log(String message);
// }
//
// Path: src/main/java/com/webfluxclient/RequestProcessor.java
// @FunctionalInterface
// public interface RequestProcessor {
//
// ClientRequest process(ClientRequest request);
//
// default RequestProcessor andThen(RequestProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
//
// Path: src/main/java/com/webfluxclient/ResponseProcessor.java
// @FunctionalInterface
// public interface ResponseProcessor {
//
// ClientResponse process(ClientResponse clientResponse);
//
// default ResponseProcessor andThen(ResponseProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
| import com.webfluxclient.LogLevel;
import com.webfluxclient.Logger;
import com.webfluxclient.RequestProcessor;
import com.webfluxclient.ResponseProcessor;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import java.util.List; | package com.webfluxclient.client;
public interface ExchangeFilterFunctionFactory {
ExchangeFilterFunction build(List<RequestProcessor> requestProcessors,
List<ResponseProcessor> responseProcessors,
Logger logger, | // Path: src/main/java/com/webfluxclient/LogLevel.java
// public enum LogLevel {
// /** No logs. */
// NONE,
//
// /**
// * Logs request and response lines.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: application/json
// *
// * <-- 200 OK POST /hello (22ms)
// * }</pre>
// */
// BASIC,
//
// /**
// * Logs request and response lines and their respective headers.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: plain/text
// * Headers:
// * - Accept-Language: en
// * - Accept-Charset: UTF-8
// * --> END POST
// *
// * <-- 200 OK POST /hello (22ms)
// * Headers:
// * - Content-Type: plain/text
// * <-- END HTTP
// * }</pre>
// */
// HEADERS
// }
//
// Path: src/main/java/com/webfluxclient/Logger.java
// public interface Logger {
// void log(Supplier<String> messageSupplier);
// void log(String message);
// }
//
// Path: src/main/java/com/webfluxclient/RequestProcessor.java
// @FunctionalInterface
// public interface RequestProcessor {
//
// ClientRequest process(ClientRequest request);
//
// default RequestProcessor andThen(RequestProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
//
// Path: src/main/java/com/webfluxclient/ResponseProcessor.java
// @FunctionalInterface
// public interface ResponseProcessor {
//
// ClientResponse process(ClientResponse clientResponse);
//
// default ResponseProcessor andThen(ResponseProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
// Path: src/main/java/com/webfluxclient/client/ExchangeFilterFunctionFactory.java
import com.webfluxclient.LogLevel;
import com.webfluxclient.Logger;
import com.webfluxclient.RequestProcessor;
import com.webfluxclient.ResponseProcessor;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import java.util.List;
package com.webfluxclient.client;
public interface ExchangeFilterFunctionFactory {
ExchangeFilterFunction build(List<RequestProcessor> requestProcessors,
List<ResponseProcessor> responseProcessors,
Logger logger, | LogLevel logLevel); |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/DefaultClientBuilder.java | // Path: src/main/java/com/webfluxclient/codec/ExtendedClientCodecConfigurer.java
// public interface ExtendedClientCodecConfigurer extends ClientCodecConfigurer {
//
// List<HttpErrorReader> getErrorReaders();
//
// ExtendedCustomCodecs customCodecs();
//
// ExtendedClientDefaultCodecs defaultCodecs();
//
// static ExtendedClientCodecConfigurer create(){
// return new DefaultExtendedClientCodecConfigurer();
// }
//
// interface ExtendedClientDefaultCodecs extends ClientDefaultCodecs {
// void httpClientErrorDecoder(HttpClientErrorDecoder clientErrorDecoder);
// void httpServerErrorDecoder(HttpServerErrorDecoder serverErrorDecoder);
// }
//
// interface ExtendedCustomCodecs extends CustomCodecs{
// void errorReader(HttpErrorReader errorReader);
// void errorDecoder(ErrorDecoder errorDecoder);
// }
// }
//
// Path: src/main/java/com/webfluxclient/handler/ReactiveInvocationHandlerFactory.java
// public interface ReactiveInvocationHandlerFactory {
// InvocationHandler build(
// ExtendedClientCodecConfigurer codecConfigurer,
// List<RequestProcessor> requestProcessors,
// List<ResponseProcessor> responseProcessors,
// Logger logger,
// LogLevel logLevel,
// Class<?> target,
// URI uri);
// }
| import com.webfluxclient.codec.ExtendedClientCodecConfigurer;
import com.webfluxclient.handler.ReactiveInvocationHandlerFactory;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer; | package com.webfluxclient;
class DefaultClientBuilder implements ClientBuilder {
private ReactiveInvocationHandlerFactory reactiveInvocationHandlerFactory; | // Path: src/main/java/com/webfluxclient/codec/ExtendedClientCodecConfigurer.java
// public interface ExtendedClientCodecConfigurer extends ClientCodecConfigurer {
//
// List<HttpErrorReader> getErrorReaders();
//
// ExtendedCustomCodecs customCodecs();
//
// ExtendedClientDefaultCodecs defaultCodecs();
//
// static ExtendedClientCodecConfigurer create(){
// return new DefaultExtendedClientCodecConfigurer();
// }
//
// interface ExtendedClientDefaultCodecs extends ClientDefaultCodecs {
// void httpClientErrorDecoder(HttpClientErrorDecoder clientErrorDecoder);
// void httpServerErrorDecoder(HttpServerErrorDecoder serverErrorDecoder);
// }
//
// interface ExtendedCustomCodecs extends CustomCodecs{
// void errorReader(HttpErrorReader errorReader);
// void errorDecoder(ErrorDecoder errorDecoder);
// }
// }
//
// Path: src/main/java/com/webfluxclient/handler/ReactiveInvocationHandlerFactory.java
// public interface ReactiveInvocationHandlerFactory {
// InvocationHandler build(
// ExtendedClientCodecConfigurer codecConfigurer,
// List<RequestProcessor> requestProcessors,
// List<ResponseProcessor> responseProcessors,
// Logger logger,
// LogLevel logLevel,
// Class<?> target,
// URI uri);
// }
// Path: src/main/java/com/webfluxclient/DefaultClientBuilder.java
import com.webfluxclient.codec.ExtendedClientCodecConfigurer;
import com.webfluxclient.handler.ReactiveInvocationHandlerFactory;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
package com.webfluxclient;
class DefaultClientBuilder implements ClientBuilder {
private ReactiveInvocationHandlerFactory reactiveInvocationHandlerFactory; | private ExtendedClientCodecConfigurer codecConfigurer; |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/codec/HttpServerErrorDecoder.java | // Path: src/main/java/com/webfluxclient/utils/DataBuffers.java
// public class DataBuffers {
//
// public static String readToString(DataBuffer dataBuffer) {
// try {
// return FileCopyUtils.copyToString(new InputStreamReader(dataBuffer.asInputStream()));
// }
// catch (IOException e) {
// return e.getMessage();
// }
// }
// }
| import com.webfluxclient.utils.DataBuffers;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpStatus; | package com.webfluxclient.codec;
public class HttpServerErrorDecoder implements ErrorDecoder<HttpServerException> {
@Override
public boolean canDecode(HttpStatus httpStatus) {
return httpStatus.is5xxServerError();
}
@Override
public HttpServerException decode(HttpStatus httpStatus, DataBuffer inputMessage) { | // Path: src/main/java/com/webfluxclient/utils/DataBuffers.java
// public class DataBuffers {
//
// public static String readToString(DataBuffer dataBuffer) {
// try {
// return FileCopyUtils.copyToString(new InputStreamReader(dataBuffer.asInputStream()));
// }
// catch (IOException e) {
// return e.getMessage();
// }
// }
// }
// Path: src/main/java/com/webfluxclient/codec/HttpServerErrorDecoder.java
import com.webfluxclient.utils.DataBuffers;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpStatus;
package com.webfluxclient.codec;
public class HttpServerErrorDecoder implements ErrorDecoder<HttpServerException> {
@Override
public boolean canDecode(HttpStatus httpStatus) {
return httpStatus.is5xxServerError();
}
@Override
public HttpServerException decode(HttpStatus httpStatus, DataBuffer inputMessage) { | return new HttpServerException(httpStatus, DataBuffers.readToString(inputMessage)); |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/metadata/MethodMetadata.java | // Path: src/main/java/com/webfluxclient/metadata/request/RequestHeader.java
// public interface RequestHeader {
// String getName();
//
// List<String> getValues(Map<String, List<String>> parameterValues);
//
// @EqualsAndHashCode
// class BasicRequestHeader implements RequestHeader {
//
// private String name;
// private String value;
//
// public BasicRequestHeader(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return Collections.singletonList(value);
// }
// }
//
// @EqualsAndHashCode
// class DynamicRequestHeader implements RequestHeader {
//
// private String name;
//
// public DynamicRequestHeader(String name) {
// this.name = name;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return parameterValues.getOrDefault(name, Collections.emptyList());
// }
//
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestHeaders.java
// public class RequestHeaders {
// private ParameterEncoder parameterEncoder;
// private Map<String, RequestHeader> headers;
// private Map<Integer, String> indexToName;
//
// public RequestHeaders(Map<String, RequestHeader> headers, Map<Integer, String> indexToName) {
// this.parameterEncoder = ParameterEncoder.create(false);
// this.headers = unmodifiableMap(headers);
// this.indexToName = unmodifiableMap(indexToName);
// }
//
// public Map<String, RequestHeader> getHeaders() {
// return headers;
// }
//
// public Map<Integer, String> getIndexToName() {
// return indexToName;
// }
//
// public HttpHeaders encode(Object[] parameterValues) {
// Map<String, List<String>> headerDynamicValue = parameterEncoder.convertToListOfString(indexToName, parameterValues);
// HttpHeaders httpHeaders = new HttpHeaders();
// for (RequestHeader header : headers.values()) {
// List<String> headerValues = header.getValues(headerDynamicValue);
// if (!headerValues.isEmpty()) {
// httpHeaders.put(header.getName(), headerValues);
// }
// }
// return httpHeaders;
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestTemplate.java
// @Getter
// @AllArgsConstructor
// public class RequestTemplate {
// private UriBuilder uriBuilder;
// private HttpMethod httpMethod;
// private RequestHeaders requestHeaders;
// private Integer bodyIndex;
// private ResolvableType requestBodyType;
// private MultiValueMap<Integer, String> variableIndexToName;
//
// public Request apply(Object[] args) {
// return new DefaultRequest(uriBuilder,
// httpMethod,
// requestHeaders.encode(args),
// nameToVariable(args),
// buildBody(args));
// }
//
// private BodyInserter<?, ? super ClientHttpRequest> buildBody(Object[] args) {
// if (bodyIndex == null) {
// return BodyInserters.empty();
// }
//
// Object body = args[bodyIndex];
// if (isDataBufferPublisher(requestBodyType)) {
// return BodyInserters.fromDataBuffers((Publisher<DataBuffer>) body);
// } else if (isPublisher(requestBodyType)) {
// return BodyInserters.fromPublisher((Publisher) body, requestBodyType.getGeneric(0).getRawClass());
// } else if (isResource(requestBodyType)) {
// return BodyInserters.fromResource((Resource) body);
// } else if (isFormData(requestBodyType)) {
// return BodyInserters.fromFormData((MultiValueMap<String, String>) body);
// } else {
// return BodyInserters.fromObject(body);
// }
// }
//
// private Map<String, Object> nameToVariable(Object[] args) {
// Map<String, Object> nameToVariable = new HashMap<>();
// variableIndexToName.forEach((variableIndex, variableNames) -> {
// variableNames
// .forEach(variableName -> nameToVariable.put(variableName, args[variableIndex]));
// });
// return nameToVariable;
// }
// }
| import com.webfluxclient.metadata.request.RequestHeader;
import com.webfluxclient.metadata.request.RequestHeaders;
import com.webfluxclient.metadata.request.RequestTemplate;
import lombok.Getter;
import org.springframework.core.ResolvableType;
import org.springframework.http.HttpMethod;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.DefaultUriBuilderFactory;
import org.springframework.web.util.UriBuilder;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.net.URI;
import java.util.HashMap;
import java.util.Map; | package com.webfluxclient.metadata;
@Getter
public class MethodMetadata {
private Method targetMethod;
private ResolvableType responseBodyType; | // Path: src/main/java/com/webfluxclient/metadata/request/RequestHeader.java
// public interface RequestHeader {
// String getName();
//
// List<String> getValues(Map<String, List<String>> parameterValues);
//
// @EqualsAndHashCode
// class BasicRequestHeader implements RequestHeader {
//
// private String name;
// private String value;
//
// public BasicRequestHeader(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return Collections.singletonList(value);
// }
// }
//
// @EqualsAndHashCode
// class DynamicRequestHeader implements RequestHeader {
//
// private String name;
//
// public DynamicRequestHeader(String name) {
// this.name = name;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return parameterValues.getOrDefault(name, Collections.emptyList());
// }
//
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestHeaders.java
// public class RequestHeaders {
// private ParameterEncoder parameterEncoder;
// private Map<String, RequestHeader> headers;
// private Map<Integer, String> indexToName;
//
// public RequestHeaders(Map<String, RequestHeader> headers, Map<Integer, String> indexToName) {
// this.parameterEncoder = ParameterEncoder.create(false);
// this.headers = unmodifiableMap(headers);
// this.indexToName = unmodifiableMap(indexToName);
// }
//
// public Map<String, RequestHeader> getHeaders() {
// return headers;
// }
//
// public Map<Integer, String> getIndexToName() {
// return indexToName;
// }
//
// public HttpHeaders encode(Object[] parameterValues) {
// Map<String, List<String>> headerDynamicValue = parameterEncoder.convertToListOfString(indexToName, parameterValues);
// HttpHeaders httpHeaders = new HttpHeaders();
// for (RequestHeader header : headers.values()) {
// List<String> headerValues = header.getValues(headerDynamicValue);
// if (!headerValues.isEmpty()) {
// httpHeaders.put(header.getName(), headerValues);
// }
// }
// return httpHeaders;
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestTemplate.java
// @Getter
// @AllArgsConstructor
// public class RequestTemplate {
// private UriBuilder uriBuilder;
// private HttpMethod httpMethod;
// private RequestHeaders requestHeaders;
// private Integer bodyIndex;
// private ResolvableType requestBodyType;
// private MultiValueMap<Integer, String> variableIndexToName;
//
// public Request apply(Object[] args) {
// return new DefaultRequest(uriBuilder,
// httpMethod,
// requestHeaders.encode(args),
// nameToVariable(args),
// buildBody(args));
// }
//
// private BodyInserter<?, ? super ClientHttpRequest> buildBody(Object[] args) {
// if (bodyIndex == null) {
// return BodyInserters.empty();
// }
//
// Object body = args[bodyIndex];
// if (isDataBufferPublisher(requestBodyType)) {
// return BodyInserters.fromDataBuffers((Publisher<DataBuffer>) body);
// } else if (isPublisher(requestBodyType)) {
// return BodyInserters.fromPublisher((Publisher) body, requestBodyType.getGeneric(0).getRawClass());
// } else if (isResource(requestBodyType)) {
// return BodyInserters.fromResource((Resource) body);
// } else if (isFormData(requestBodyType)) {
// return BodyInserters.fromFormData((MultiValueMap<String, String>) body);
// } else {
// return BodyInserters.fromObject(body);
// }
// }
//
// private Map<String, Object> nameToVariable(Object[] args) {
// Map<String, Object> nameToVariable = new HashMap<>();
// variableIndexToName.forEach((variableIndex, variableNames) -> {
// variableNames
// .forEach(variableName -> nameToVariable.put(variableName, args[variableIndex]));
// });
// return nameToVariable;
// }
// }
// Path: src/main/java/com/webfluxclient/metadata/MethodMetadata.java
import com.webfluxclient.metadata.request.RequestHeader;
import com.webfluxclient.metadata.request.RequestHeaders;
import com.webfluxclient.metadata.request.RequestTemplate;
import lombok.Getter;
import org.springframework.core.ResolvableType;
import org.springframework.http.HttpMethod;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.DefaultUriBuilderFactory;
import org.springframework.web.util.UriBuilder;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
package com.webfluxclient.metadata;
@Getter
public class MethodMetadata {
private Method targetMethod;
private ResolvableType responseBodyType; | private RequestTemplate requestTemplate; |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/metadata/MethodMetadata.java | // Path: src/main/java/com/webfluxclient/metadata/request/RequestHeader.java
// public interface RequestHeader {
// String getName();
//
// List<String> getValues(Map<String, List<String>> parameterValues);
//
// @EqualsAndHashCode
// class BasicRequestHeader implements RequestHeader {
//
// private String name;
// private String value;
//
// public BasicRequestHeader(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return Collections.singletonList(value);
// }
// }
//
// @EqualsAndHashCode
// class DynamicRequestHeader implements RequestHeader {
//
// private String name;
//
// public DynamicRequestHeader(String name) {
// this.name = name;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return parameterValues.getOrDefault(name, Collections.emptyList());
// }
//
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestHeaders.java
// public class RequestHeaders {
// private ParameterEncoder parameterEncoder;
// private Map<String, RequestHeader> headers;
// private Map<Integer, String> indexToName;
//
// public RequestHeaders(Map<String, RequestHeader> headers, Map<Integer, String> indexToName) {
// this.parameterEncoder = ParameterEncoder.create(false);
// this.headers = unmodifiableMap(headers);
// this.indexToName = unmodifiableMap(indexToName);
// }
//
// public Map<String, RequestHeader> getHeaders() {
// return headers;
// }
//
// public Map<Integer, String> getIndexToName() {
// return indexToName;
// }
//
// public HttpHeaders encode(Object[] parameterValues) {
// Map<String, List<String>> headerDynamicValue = parameterEncoder.convertToListOfString(indexToName, parameterValues);
// HttpHeaders httpHeaders = new HttpHeaders();
// for (RequestHeader header : headers.values()) {
// List<String> headerValues = header.getValues(headerDynamicValue);
// if (!headerValues.isEmpty()) {
// httpHeaders.put(header.getName(), headerValues);
// }
// }
// return httpHeaders;
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestTemplate.java
// @Getter
// @AllArgsConstructor
// public class RequestTemplate {
// private UriBuilder uriBuilder;
// private HttpMethod httpMethod;
// private RequestHeaders requestHeaders;
// private Integer bodyIndex;
// private ResolvableType requestBodyType;
// private MultiValueMap<Integer, String> variableIndexToName;
//
// public Request apply(Object[] args) {
// return new DefaultRequest(uriBuilder,
// httpMethod,
// requestHeaders.encode(args),
// nameToVariable(args),
// buildBody(args));
// }
//
// private BodyInserter<?, ? super ClientHttpRequest> buildBody(Object[] args) {
// if (bodyIndex == null) {
// return BodyInserters.empty();
// }
//
// Object body = args[bodyIndex];
// if (isDataBufferPublisher(requestBodyType)) {
// return BodyInserters.fromDataBuffers((Publisher<DataBuffer>) body);
// } else if (isPublisher(requestBodyType)) {
// return BodyInserters.fromPublisher((Publisher) body, requestBodyType.getGeneric(0).getRawClass());
// } else if (isResource(requestBodyType)) {
// return BodyInserters.fromResource((Resource) body);
// } else if (isFormData(requestBodyType)) {
// return BodyInserters.fromFormData((MultiValueMap<String, String>) body);
// } else {
// return BodyInserters.fromObject(body);
// }
// }
//
// private Map<String, Object> nameToVariable(Object[] args) {
// Map<String, Object> nameToVariable = new HashMap<>();
// variableIndexToName.forEach((variableIndex, variableNames) -> {
// variableNames
// .forEach(variableName -> nameToVariable.put(variableName, args[variableIndex]));
// });
// return nameToVariable;
// }
// }
| import com.webfluxclient.metadata.request.RequestHeader;
import com.webfluxclient.metadata.request.RequestHeaders;
import com.webfluxclient.metadata.request.RequestTemplate;
import lombok.Getter;
import org.springframework.core.ResolvableType;
import org.springframework.http.HttpMethod;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.DefaultUriBuilderFactory;
import org.springframework.web.util.UriBuilder;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.net.URI;
import java.util.HashMap;
import java.util.Map; | package com.webfluxclient.metadata;
@Getter
public class MethodMetadata {
private Method targetMethod;
private ResolvableType responseBodyType;
private RequestTemplate requestTemplate;
private MethodMetadata(Builder builder) {
targetMethod = builder.targetMethod;
responseBodyType = builder.returnType;
requestTemplate = new RequestTemplate(
builder.uriBuilder,
builder.httpMethod, | // Path: src/main/java/com/webfluxclient/metadata/request/RequestHeader.java
// public interface RequestHeader {
// String getName();
//
// List<String> getValues(Map<String, List<String>> parameterValues);
//
// @EqualsAndHashCode
// class BasicRequestHeader implements RequestHeader {
//
// private String name;
// private String value;
//
// public BasicRequestHeader(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return Collections.singletonList(value);
// }
// }
//
// @EqualsAndHashCode
// class DynamicRequestHeader implements RequestHeader {
//
// private String name;
//
// public DynamicRequestHeader(String name) {
// this.name = name;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return parameterValues.getOrDefault(name, Collections.emptyList());
// }
//
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestHeaders.java
// public class RequestHeaders {
// private ParameterEncoder parameterEncoder;
// private Map<String, RequestHeader> headers;
// private Map<Integer, String> indexToName;
//
// public RequestHeaders(Map<String, RequestHeader> headers, Map<Integer, String> indexToName) {
// this.parameterEncoder = ParameterEncoder.create(false);
// this.headers = unmodifiableMap(headers);
// this.indexToName = unmodifiableMap(indexToName);
// }
//
// public Map<String, RequestHeader> getHeaders() {
// return headers;
// }
//
// public Map<Integer, String> getIndexToName() {
// return indexToName;
// }
//
// public HttpHeaders encode(Object[] parameterValues) {
// Map<String, List<String>> headerDynamicValue = parameterEncoder.convertToListOfString(indexToName, parameterValues);
// HttpHeaders httpHeaders = new HttpHeaders();
// for (RequestHeader header : headers.values()) {
// List<String> headerValues = header.getValues(headerDynamicValue);
// if (!headerValues.isEmpty()) {
// httpHeaders.put(header.getName(), headerValues);
// }
// }
// return httpHeaders;
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestTemplate.java
// @Getter
// @AllArgsConstructor
// public class RequestTemplate {
// private UriBuilder uriBuilder;
// private HttpMethod httpMethod;
// private RequestHeaders requestHeaders;
// private Integer bodyIndex;
// private ResolvableType requestBodyType;
// private MultiValueMap<Integer, String> variableIndexToName;
//
// public Request apply(Object[] args) {
// return new DefaultRequest(uriBuilder,
// httpMethod,
// requestHeaders.encode(args),
// nameToVariable(args),
// buildBody(args));
// }
//
// private BodyInserter<?, ? super ClientHttpRequest> buildBody(Object[] args) {
// if (bodyIndex == null) {
// return BodyInserters.empty();
// }
//
// Object body = args[bodyIndex];
// if (isDataBufferPublisher(requestBodyType)) {
// return BodyInserters.fromDataBuffers((Publisher<DataBuffer>) body);
// } else if (isPublisher(requestBodyType)) {
// return BodyInserters.fromPublisher((Publisher) body, requestBodyType.getGeneric(0).getRawClass());
// } else if (isResource(requestBodyType)) {
// return BodyInserters.fromResource((Resource) body);
// } else if (isFormData(requestBodyType)) {
// return BodyInserters.fromFormData((MultiValueMap<String, String>) body);
// } else {
// return BodyInserters.fromObject(body);
// }
// }
//
// private Map<String, Object> nameToVariable(Object[] args) {
// Map<String, Object> nameToVariable = new HashMap<>();
// variableIndexToName.forEach((variableIndex, variableNames) -> {
// variableNames
// .forEach(variableName -> nameToVariable.put(variableName, args[variableIndex]));
// });
// return nameToVariable;
// }
// }
// Path: src/main/java/com/webfluxclient/metadata/MethodMetadata.java
import com.webfluxclient.metadata.request.RequestHeader;
import com.webfluxclient.metadata.request.RequestHeaders;
import com.webfluxclient.metadata.request.RequestTemplate;
import lombok.Getter;
import org.springframework.core.ResolvableType;
import org.springframework.http.HttpMethod;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.DefaultUriBuilderFactory;
import org.springframework.web.util.UriBuilder;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
package com.webfluxclient.metadata;
@Getter
public class MethodMetadata {
private Method targetMethod;
private ResolvableType responseBodyType;
private RequestTemplate requestTemplate;
private MethodMetadata(Builder builder) {
targetMethod = builder.targetMethod;
responseBodyType = builder.returnType;
requestTemplate = new RequestTemplate(
builder.uriBuilder,
builder.httpMethod, | new RequestHeaders(builder.headers, builder.headerIndexToName), |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/metadata/MethodMetadata.java | // Path: src/main/java/com/webfluxclient/metadata/request/RequestHeader.java
// public interface RequestHeader {
// String getName();
//
// List<String> getValues(Map<String, List<String>> parameterValues);
//
// @EqualsAndHashCode
// class BasicRequestHeader implements RequestHeader {
//
// private String name;
// private String value;
//
// public BasicRequestHeader(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return Collections.singletonList(value);
// }
// }
//
// @EqualsAndHashCode
// class DynamicRequestHeader implements RequestHeader {
//
// private String name;
//
// public DynamicRequestHeader(String name) {
// this.name = name;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return parameterValues.getOrDefault(name, Collections.emptyList());
// }
//
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestHeaders.java
// public class RequestHeaders {
// private ParameterEncoder parameterEncoder;
// private Map<String, RequestHeader> headers;
// private Map<Integer, String> indexToName;
//
// public RequestHeaders(Map<String, RequestHeader> headers, Map<Integer, String> indexToName) {
// this.parameterEncoder = ParameterEncoder.create(false);
// this.headers = unmodifiableMap(headers);
// this.indexToName = unmodifiableMap(indexToName);
// }
//
// public Map<String, RequestHeader> getHeaders() {
// return headers;
// }
//
// public Map<Integer, String> getIndexToName() {
// return indexToName;
// }
//
// public HttpHeaders encode(Object[] parameterValues) {
// Map<String, List<String>> headerDynamicValue = parameterEncoder.convertToListOfString(indexToName, parameterValues);
// HttpHeaders httpHeaders = new HttpHeaders();
// for (RequestHeader header : headers.values()) {
// List<String> headerValues = header.getValues(headerDynamicValue);
// if (!headerValues.isEmpty()) {
// httpHeaders.put(header.getName(), headerValues);
// }
// }
// return httpHeaders;
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestTemplate.java
// @Getter
// @AllArgsConstructor
// public class RequestTemplate {
// private UriBuilder uriBuilder;
// private HttpMethod httpMethod;
// private RequestHeaders requestHeaders;
// private Integer bodyIndex;
// private ResolvableType requestBodyType;
// private MultiValueMap<Integer, String> variableIndexToName;
//
// public Request apply(Object[] args) {
// return new DefaultRequest(uriBuilder,
// httpMethod,
// requestHeaders.encode(args),
// nameToVariable(args),
// buildBody(args));
// }
//
// private BodyInserter<?, ? super ClientHttpRequest> buildBody(Object[] args) {
// if (bodyIndex == null) {
// return BodyInserters.empty();
// }
//
// Object body = args[bodyIndex];
// if (isDataBufferPublisher(requestBodyType)) {
// return BodyInserters.fromDataBuffers((Publisher<DataBuffer>) body);
// } else if (isPublisher(requestBodyType)) {
// return BodyInserters.fromPublisher((Publisher) body, requestBodyType.getGeneric(0).getRawClass());
// } else if (isResource(requestBodyType)) {
// return BodyInserters.fromResource((Resource) body);
// } else if (isFormData(requestBodyType)) {
// return BodyInserters.fromFormData((MultiValueMap<String, String>) body);
// } else {
// return BodyInserters.fromObject(body);
// }
// }
//
// private Map<String, Object> nameToVariable(Object[] args) {
// Map<String, Object> nameToVariable = new HashMap<>();
// variableIndexToName.forEach((variableIndex, variableNames) -> {
// variableNames
// .forEach(variableName -> nameToVariable.put(variableName, args[variableIndex]));
// });
// return nameToVariable;
// }
// }
| import com.webfluxclient.metadata.request.RequestHeader;
import com.webfluxclient.metadata.request.RequestHeaders;
import com.webfluxclient.metadata.request.RequestTemplate;
import lombok.Getter;
import org.springframework.core.ResolvableType;
import org.springframework.http.HttpMethod;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.DefaultUriBuilderFactory;
import org.springframework.web.util.UriBuilder;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.net.URI;
import java.util.HashMap;
import java.util.Map; | package com.webfluxclient.metadata;
@Getter
public class MethodMetadata {
private Method targetMethod;
private ResolvableType responseBodyType;
private RequestTemplate requestTemplate;
private MethodMetadata(Builder builder) {
targetMethod = builder.targetMethod;
responseBodyType = builder.returnType;
requestTemplate = new RequestTemplate(
builder.uriBuilder,
builder.httpMethod,
new RequestHeaders(builder.headers, builder.headerIndexToName),
builder.bodyIndex,
builder.bodyType,
builder.variableIndexToName);
}
public static Builder newBuilder(URI baseUri) {
return new Builder(baseUri.getScheme(), baseUri.getAuthority());
}
public static Builder newBuilder(MethodMetadata other) {
return new Builder(other);
}
public static class Builder {
private UriBuilder uriBuilder;
private MultiValueMap<Integer, String> variableIndexToName; | // Path: src/main/java/com/webfluxclient/metadata/request/RequestHeader.java
// public interface RequestHeader {
// String getName();
//
// List<String> getValues(Map<String, List<String>> parameterValues);
//
// @EqualsAndHashCode
// class BasicRequestHeader implements RequestHeader {
//
// private String name;
// private String value;
//
// public BasicRequestHeader(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return Collections.singletonList(value);
// }
// }
//
// @EqualsAndHashCode
// class DynamicRequestHeader implements RequestHeader {
//
// private String name;
//
// public DynamicRequestHeader(String name) {
// this.name = name;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public List<String> getValues(Map<String, List<String>> parameterValues) {
// return parameterValues.getOrDefault(name, Collections.emptyList());
// }
//
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestHeaders.java
// public class RequestHeaders {
// private ParameterEncoder parameterEncoder;
// private Map<String, RequestHeader> headers;
// private Map<Integer, String> indexToName;
//
// public RequestHeaders(Map<String, RequestHeader> headers, Map<Integer, String> indexToName) {
// this.parameterEncoder = ParameterEncoder.create(false);
// this.headers = unmodifiableMap(headers);
// this.indexToName = unmodifiableMap(indexToName);
// }
//
// public Map<String, RequestHeader> getHeaders() {
// return headers;
// }
//
// public Map<Integer, String> getIndexToName() {
// return indexToName;
// }
//
// public HttpHeaders encode(Object[] parameterValues) {
// Map<String, List<String>> headerDynamicValue = parameterEncoder.convertToListOfString(indexToName, parameterValues);
// HttpHeaders httpHeaders = new HttpHeaders();
// for (RequestHeader header : headers.values()) {
// List<String> headerValues = header.getValues(headerDynamicValue);
// if (!headerValues.isEmpty()) {
// httpHeaders.put(header.getName(), headerValues);
// }
// }
// return httpHeaders;
// }
// }
//
// Path: src/main/java/com/webfluxclient/metadata/request/RequestTemplate.java
// @Getter
// @AllArgsConstructor
// public class RequestTemplate {
// private UriBuilder uriBuilder;
// private HttpMethod httpMethod;
// private RequestHeaders requestHeaders;
// private Integer bodyIndex;
// private ResolvableType requestBodyType;
// private MultiValueMap<Integer, String> variableIndexToName;
//
// public Request apply(Object[] args) {
// return new DefaultRequest(uriBuilder,
// httpMethod,
// requestHeaders.encode(args),
// nameToVariable(args),
// buildBody(args));
// }
//
// private BodyInserter<?, ? super ClientHttpRequest> buildBody(Object[] args) {
// if (bodyIndex == null) {
// return BodyInserters.empty();
// }
//
// Object body = args[bodyIndex];
// if (isDataBufferPublisher(requestBodyType)) {
// return BodyInserters.fromDataBuffers((Publisher<DataBuffer>) body);
// } else if (isPublisher(requestBodyType)) {
// return BodyInserters.fromPublisher((Publisher) body, requestBodyType.getGeneric(0).getRawClass());
// } else if (isResource(requestBodyType)) {
// return BodyInserters.fromResource((Resource) body);
// } else if (isFormData(requestBodyType)) {
// return BodyInserters.fromFormData((MultiValueMap<String, String>) body);
// } else {
// return BodyInserters.fromObject(body);
// }
// }
//
// private Map<String, Object> nameToVariable(Object[] args) {
// Map<String, Object> nameToVariable = new HashMap<>();
// variableIndexToName.forEach((variableIndex, variableNames) -> {
// variableNames
// .forEach(variableName -> nameToVariable.put(variableName, args[variableIndex]));
// });
// return nameToVariable;
// }
// }
// Path: src/main/java/com/webfluxclient/metadata/MethodMetadata.java
import com.webfluxclient.metadata.request.RequestHeader;
import com.webfluxclient.metadata.request.RequestHeaders;
import com.webfluxclient.metadata.request.RequestTemplate;
import lombok.Getter;
import org.springframework.core.ResolvableType;
import org.springframework.http.HttpMethod;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.DefaultUriBuilderFactory;
import org.springframework.web.util.UriBuilder;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
package com.webfluxclient.metadata;
@Getter
public class MethodMetadata {
private Method targetMethod;
private ResolvableType responseBodyType;
private RequestTemplate requestTemplate;
private MethodMetadata(Builder builder) {
targetMethod = builder.targetMethod;
responseBodyType = builder.returnType;
requestTemplate = new RequestTemplate(
builder.uriBuilder,
builder.httpMethod,
new RequestHeaders(builder.headers, builder.headerIndexToName),
builder.bodyIndex,
builder.bodyType,
builder.variableIndexToName);
}
public static Builder newBuilder(URI baseUri) {
return new Builder(baseUri.getScheme(), baseUri.getAuthority());
}
public static Builder newBuilder(MethodMetadata other) {
return new Builder(other);
}
public static class Builder {
private UriBuilder uriBuilder;
private MultiValueMap<Integer, String> variableIndexToName; | private Map<String, RequestHeader> headers; |
jbrixhe/spring-webflux-client | src/test/java/com/webfluxclient/DefaultClientBuilderTest.java | // Path: src/main/java/com/webfluxclient/codec/ErrorDecoder.java
// public interface ErrorDecoder<T extends RuntimeException> {
//
// /**
// * Whether the decoder supports the given target status code of the response.
// *
// * @param httpStatus the status code received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canDecode(HttpStatus httpStatus);
//
// /**
// * @param httpStatus the status code received by the client
// * @param inputStream the {@code InputStream} input stream to decode
// * @return the decoded exception
// */
// T decode(HttpStatus httpStatus, DataBuffer inputStream);
//
// /**
// * Return a new {@code ErrorDecoder} described by the given predicate and bifunction functions.
// * All provided functions has to be initialized.
// *
// * @param statusPredicate the predicate function for accepted {@link HttpStatus}
// * @param errorDecoder the bifunction function to decode {@code InputStream}
// * @return the new {@code ErrorDecoder}
// */
// static <T extends RuntimeException> ErrorDecoder<T> of(Predicate<HttpStatus> statusPredicate,
// BiFunction<HttpStatus, DataBuffer, T> errorDecoder) {
// return new ErrorDecoder<T>() {
// @Override
// public boolean canDecode(HttpStatus httpStatus) {
// return statusPredicate.test(httpStatus);
// }
//
// @Override
// public T decode(HttpStatus httpStatus, DataBuffer inputMessage) {
// return errorDecoder.apply(httpStatus, inputMessage);
// }
// };
// }
// }
//
// Path: src/main/java/com/webfluxclient/codec/ExtendedClientCodecConfigurer.java
// public interface ExtendedClientCodecConfigurer extends ClientCodecConfigurer {
//
// List<HttpErrorReader> getErrorReaders();
//
// ExtendedCustomCodecs customCodecs();
//
// ExtendedClientDefaultCodecs defaultCodecs();
//
// static ExtendedClientCodecConfigurer create(){
// return new DefaultExtendedClientCodecConfigurer();
// }
//
// interface ExtendedClientDefaultCodecs extends ClientDefaultCodecs {
// void httpClientErrorDecoder(HttpClientErrorDecoder clientErrorDecoder);
// void httpServerErrorDecoder(HttpServerErrorDecoder serverErrorDecoder);
// }
//
// interface ExtendedCustomCodecs extends CustomCodecs{
// void errorReader(HttpErrorReader errorReader);
// void errorDecoder(ErrorDecoder errorDecoder);
// }
// }
//
// Path: src/main/java/com/webfluxclient/codec/HttpClientErrorDecoder.java
// public class HttpClientErrorDecoder implements ErrorDecoder<HttpClientException> {
// @Override
// public boolean canDecode(HttpStatus httpStatus) {
// return httpStatus.is4xxClientError();
// }
//
// @Override
// public HttpClientException decode(HttpStatus httpStatus, DataBuffer inputMessage) {
// return new HttpClientException(httpStatus, DataBuffers.readToString(inputMessage));
// }
// }
//
// Path: src/main/java/com/webfluxclient/codec/HttpErrorReader.java
// public interface HttpErrorReader {
//
// /**
// * Whether the given {@link HttpStatus} is supported by this reader.
// * @param httpStatus received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canRead(HttpStatus httpStatus);
//
// /**
// * Read from the input message and return a error {@link Flux}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Flux} with the decoded exception
// * */
// <T> Flux<T> read(ClientHttpResponse inputMessage);
//
// /**
// * Read from the input message and return a error {@link Mono}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Mono} with the decoded exception
// * */
// <T> Mono<T> readMono(ClientHttpResponse inputMessage);
//
// }
//
// Path: src/main/java/com/webfluxclient/codec/HttpServerErrorDecoder.java
// public class HttpServerErrorDecoder implements ErrorDecoder<HttpServerException> {
// @Override
// public boolean canDecode(HttpStatus httpStatus) {
// return httpStatus.is5xxServerError();
// }
//
// @Override
// public HttpServerException decode(HttpStatus httpStatus, DataBuffer inputMessage) {
// return new HttpServerException(httpStatus, DataBuffers.readToString(inputMessage));
// }
// }
//
// Path: src/main/java/com/webfluxclient/handler/ReactiveInvocationHandlerFactory.java
// public interface ReactiveInvocationHandlerFactory {
// InvocationHandler build(
// ExtendedClientCodecConfigurer codecConfigurer,
// List<RequestProcessor> requestProcessors,
// List<ResponseProcessor> responseProcessors,
// Logger logger,
// LogLevel logLevel,
// Class<?> target,
// URI uri);
// }
| import com.webfluxclient.codec.ErrorDecoder;
import com.webfluxclient.codec.ExtendedClientCodecConfigurer;
import com.webfluxclient.codec.HttpClientErrorDecoder;
import com.webfluxclient.codec.HttpErrorReader;
import com.webfluxclient.codec.HttpServerErrorDecoder;
import com.webfluxclient.handler.ReactiveInvocationHandlerFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.http.HttpStatus;
import java.net.URI;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when; | package com.webfluxclient;
@RunWith(MockitoJUnitRunner.class)
public class DefaultClientBuilderTest {
@Mock | // Path: src/main/java/com/webfluxclient/codec/ErrorDecoder.java
// public interface ErrorDecoder<T extends RuntimeException> {
//
// /**
// * Whether the decoder supports the given target status code of the response.
// *
// * @param httpStatus the status code received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canDecode(HttpStatus httpStatus);
//
// /**
// * @param httpStatus the status code received by the client
// * @param inputStream the {@code InputStream} input stream to decode
// * @return the decoded exception
// */
// T decode(HttpStatus httpStatus, DataBuffer inputStream);
//
// /**
// * Return a new {@code ErrorDecoder} described by the given predicate and bifunction functions.
// * All provided functions has to be initialized.
// *
// * @param statusPredicate the predicate function for accepted {@link HttpStatus}
// * @param errorDecoder the bifunction function to decode {@code InputStream}
// * @return the new {@code ErrorDecoder}
// */
// static <T extends RuntimeException> ErrorDecoder<T> of(Predicate<HttpStatus> statusPredicate,
// BiFunction<HttpStatus, DataBuffer, T> errorDecoder) {
// return new ErrorDecoder<T>() {
// @Override
// public boolean canDecode(HttpStatus httpStatus) {
// return statusPredicate.test(httpStatus);
// }
//
// @Override
// public T decode(HttpStatus httpStatus, DataBuffer inputMessage) {
// return errorDecoder.apply(httpStatus, inputMessage);
// }
// };
// }
// }
//
// Path: src/main/java/com/webfluxclient/codec/ExtendedClientCodecConfigurer.java
// public interface ExtendedClientCodecConfigurer extends ClientCodecConfigurer {
//
// List<HttpErrorReader> getErrorReaders();
//
// ExtendedCustomCodecs customCodecs();
//
// ExtendedClientDefaultCodecs defaultCodecs();
//
// static ExtendedClientCodecConfigurer create(){
// return new DefaultExtendedClientCodecConfigurer();
// }
//
// interface ExtendedClientDefaultCodecs extends ClientDefaultCodecs {
// void httpClientErrorDecoder(HttpClientErrorDecoder clientErrorDecoder);
// void httpServerErrorDecoder(HttpServerErrorDecoder serverErrorDecoder);
// }
//
// interface ExtendedCustomCodecs extends CustomCodecs{
// void errorReader(HttpErrorReader errorReader);
// void errorDecoder(ErrorDecoder errorDecoder);
// }
// }
//
// Path: src/main/java/com/webfluxclient/codec/HttpClientErrorDecoder.java
// public class HttpClientErrorDecoder implements ErrorDecoder<HttpClientException> {
// @Override
// public boolean canDecode(HttpStatus httpStatus) {
// return httpStatus.is4xxClientError();
// }
//
// @Override
// public HttpClientException decode(HttpStatus httpStatus, DataBuffer inputMessage) {
// return new HttpClientException(httpStatus, DataBuffers.readToString(inputMessage));
// }
// }
//
// Path: src/main/java/com/webfluxclient/codec/HttpErrorReader.java
// public interface HttpErrorReader {
//
// /**
// * Whether the given {@link HttpStatus} is supported by this reader.
// * @param httpStatus received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canRead(HttpStatus httpStatus);
//
// /**
// * Read from the input message and return a error {@link Flux}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Flux} with the decoded exception
// * */
// <T> Flux<T> read(ClientHttpResponse inputMessage);
//
// /**
// * Read from the input message and return a error {@link Mono}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Mono} with the decoded exception
// * */
// <T> Mono<T> readMono(ClientHttpResponse inputMessage);
//
// }
//
// Path: src/main/java/com/webfluxclient/codec/HttpServerErrorDecoder.java
// public class HttpServerErrorDecoder implements ErrorDecoder<HttpServerException> {
// @Override
// public boolean canDecode(HttpStatus httpStatus) {
// return httpStatus.is5xxServerError();
// }
//
// @Override
// public HttpServerException decode(HttpStatus httpStatus, DataBuffer inputMessage) {
// return new HttpServerException(httpStatus, DataBuffers.readToString(inputMessage));
// }
// }
//
// Path: src/main/java/com/webfluxclient/handler/ReactiveInvocationHandlerFactory.java
// public interface ReactiveInvocationHandlerFactory {
// InvocationHandler build(
// ExtendedClientCodecConfigurer codecConfigurer,
// List<RequestProcessor> requestProcessors,
// List<ResponseProcessor> responseProcessors,
// Logger logger,
// LogLevel logLevel,
// Class<?> target,
// URI uri);
// }
// Path: src/test/java/com/webfluxclient/DefaultClientBuilderTest.java
import com.webfluxclient.codec.ErrorDecoder;
import com.webfluxclient.codec.ExtendedClientCodecConfigurer;
import com.webfluxclient.codec.HttpClientErrorDecoder;
import com.webfluxclient.codec.HttpErrorReader;
import com.webfluxclient.codec.HttpServerErrorDecoder;
import com.webfluxclient.handler.ReactiveInvocationHandlerFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.http.HttpStatus;
import java.net.URI;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
package com.webfluxclient;
@RunWith(MockitoJUnitRunner.class)
public class DefaultClientBuilderTest {
@Mock | private ReactiveInvocationHandlerFactory reactiveInvocationHandlerFactory; |
jbrixhe/spring-webflux-client | src/test/java/com/webfluxclient/DefaultClientBuilderTest.java | // Path: src/main/java/com/webfluxclient/codec/ErrorDecoder.java
// public interface ErrorDecoder<T extends RuntimeException> {
//
// /**
// * Whether the decoder supports the given target status code of the response.
// *
// * @param httpStatus the status code received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canDecode(HttpStatus httpStatus);
//
// /**
// * @param httpStatus the status code received by the client
// * @param inputStream the {@code InputStream} input stream to decode
// * @return the decoded exception
// */
// T decode(HttpStatus httpStatus, DataBuffer inputStream);
//
// /**
// * Return a new {@code ErrorDecoder} described by the given predicate and bifunction functions.
// * All provided functions has to be initialized.
// *
// * @param statusPredicate the predicate function for accepted {@link HttpStatus}
// * @param errorDecoder the bifunction function to decode {@code InputStream}
// * @return the new {@code ErrorDecoder}
// */
// static <T extends RuntimeException> ErrorDecoder<T> of(Predicate<HttpStatus> statusPredicate,
// BiFunction<HttpStatus, DataBuffer, T> errorDecoder) {
// return new ErrorDecoder<T>() {
// @Override
// public boolean canDecode(HttpStatus httpStatus) {
// return statusPredicate.test(httpStatus);
// }
//
// @Override
// public T decode(HttpStatus httpStatus, DataBuffer inputMessage) {
// return errorDecoder.apply(httpStatus, inputMessage);
// }
// };
// }
// }
//
// Path: src/main/java/com/webfluxclient/codec/ExtendedClientCodecConfigurer.java
// public interface ExtendedClientCodecConfigurer extends ClientCodecConfigurer {
//
// List<HttpErrorReader> getErrorReaders();
//
// ExtendedCustomCodecs customCodecs();
//
// ExtendedClientDefaultCodecs defaultCodecs();
//
// static ExtendedClientCodecConfigurer create(){
// return new DefaultExtendedClientCodecConfigurer();
// }
//
// interface ExtendedClientDefaultCodecs extends ClientDefaultCodecs {
// void httpClientErrorDecoder(HttpClientErrorDecoder clientErrorDecoder);
// void httpServerErrorDecoder(HttpServerErrorDecoder serverErrorDecoder);
// }
//
// interface ExtendedCustomCodecs extends CustomCodecs{
// void errorReader(HttpErrorReader errorReader);
// void errorDecoder(ErrorDecoder errorDecoder);
// }
// }
//
// Path: src/main/java/com/webfluxclient/codec/HttpClientErrorDecoder.java
// public class HttpClientErrorDecoder implements ErrorDecoder<HttpClientException> {
// @Override
// public boolean canDecode(HttpStatus httpStatus) {
// return httpStatus.is4xxClientError();
// }
//
// @Override
// public HttpClientException decode(HttpStatus httpStatus, DataBuffer inputMessage) {
// return new HttpClientException(httpStatus, DataBuffers.readToString(inputMessage));
// }
// }
//
// Path: src/main/java/com/webfluxclient/codec/HttpErrorReader.java
// public interface HttpErrorReader {
//
// /**
// * Whether the given {@link HttpStatus} is supported by this reader.
// * @param httpStatus received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canRead(HttpStatus httpStatus);
//
// /**
// * Read from the input message and return a error {@link Flux}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Flux} with the decoded exception
// * */
// <T> Flux<T> read(ClientHttpResponse inputMessage);
//
// /**
// * Read from the input message and return a error {@link Mono}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Mono} with the decoded exception
// * */
// <T> Mono<T> readMono(ClientHttpResponse inputMessage);
//
// }
//
// Path: src/main/java/com/webfluxclient/codec/HttpServerErrorDecoder.java
// public class HttpServerErrorDecoder implements ErrorDecoder<HttpServerException> {
// @Override
// public boolean canDecode(HttpStatus httpStatus) {
// return httpStatus.is5xxServerError();
// }
//
// @Override
// public HttpServerException decode(HttpStatus httpStatus, DataBuffer inputMessage) {
// return new HttpServerException(httpStatus, DataBuffers.readToString(inputMessage));
// }
// }
//
// Path: src/main/java/com/webfluxclient/handler/ReactiveInvocationHandlerFactory.java
// public interface ReactiveInvocationHandlerFactory {
// InvocationHandler build(
// ExtendedClientCodecConfigurer codecConfigurer,
// List<RequestProcessor> requestProcessors,
// List<ResponseProcessor> responseProcessors,
// Logger logger,
// LogLevel logLevel,
// Class<?> target,
// URI uri);
// }
| import com.webfluxclient.codec.ErrorDecoder;
import com.webfluxclient.codec.ExtendedClientCodecConfigurer;
import com.webfluxclient.codec.HttpClientErrorDecoder;
import com.webfluxclient.codec.HttpErrorReader;
import com.webfluxclient.codec.HttpServerErrorDecoder;
import com.webfluxclient.handler.ReactiveInvocationHandlerFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.http.HttpStatus;
import java.net.URI;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when; | package com.webfluxclient;
@RunWith(MockitoJUnitRunner.class)
public class DefaultClientBuilderTest {
@Mock
private ReactiveInvocationHandlerFactory reactiveInvocationHandlerFactory;
@Captor | // Path: src/main/java/com/webfluxclient/codec/ErrorDecoder.java
// public interface ErrorDecoder<T extends RuntimeException> {
//
// /**
// * Whether the decoder supports the given target status code of the response.
// *
// * @param httpStatus the status code received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canDecode(HttpStatus httpStatus);
//
// /**
// * @param httpStatus the status code received by the client
// * @param inputStream the {@code InputStream} input stream to decode
// * @return the decoded exception
// */
// T decode(HttpStatus httpStatus, DataBuffer inputStream);
//
// /**
// * Return a new {@code ErrorDecoder} described by the given predicate and bifunction functions.
// * All provided functions has to be initialized.
// *
// * @param statusPredicate the predicate function for accepted {@link HttpStatus}
// * @param errorDecoder the bifunction function to decode {@code InputStream}
// * @return the new {@code ErrorDecoder}
// */
// static <T extends RuntimeException> ErrorDecoder<T> of(Predicate<HttpStatus> statusPredicate,
// BiFunction<HttpStatus, DataBuffer, T> errorDecoder) {
// return new ErrorDecoder<T>() {
// @Override
// public boolean canDecode(HttpStatus httpStatus) {
// return statusPredicate.test(httpStatus);
// }
//
// @Override
// public T decode(HttpStatus httpStatus, DataBuffer inputMessage) {
// return errorDecoder.apply(httpStatus, inputMessage);
// }
// };
// }
// }
//
// Path: src/main/java/com/webfluxclient/codec/ExtendedClientCodecConfigurer.java
// public interface ExtendedClientCodecConfigurer extends ClientCodecConfigurer {
//
// List<HttpErrorReader> getErrorReaders();
//
// ExtendedCustomCodecs customCodecs();
//
// ExtendedClientDefaultCodecs defaultCodecs();
//
// static ExtendedClientCodecConfigurer create(){
// return new DefaultExtendedClientCodecConfigurer();
// }
//
// interface ExtendedClientDefaultCodecs extends ClientDefaultCodecs {
// void httpClientErrorDecoder(HttpClientErrorDecoder clientErrorDecoder);
// void httpServerErrorDecoder(HttpServerErrorDecoder serverErrorDecoder);
// }
//
// interface ExtendedCustomCodecs extends CustomCodecs{
// void errorReader(HttpErrorReader errorReader);
// void errorDecoder(ErrorDecoder errorDecoder);
// }
// }
//
// Path: src/main/java/com/webfluxclient/codec/HttpClientErrorDecoder.java
// public class HttpClientErrorDecoder implements ErrorDecoder<HttpClientException> {
// @Override
// public boolean canDecode(HttpStatus httpStatus) {
// return httpStatus.is4xxClientError();
// }
//
// @Override
// public HttpClientException decode(HttpStatus httpStatus, DataBuffer inputMessage) {
// return new HttpClientException(httpStatus, DataBuffers.readToString(inputMessage));
// }
// }
//
// Path: src/main/java/com/webfluxclient/codec/HttpErrorReader.java
// public interface HttpErrorReader {
//
// /**
// * Whether the given {@link HttpStatus} is supported by this reader.
// * @param httpStatus received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canRead(HttpStatus httpStatus);
//
// /**
// * Read from the input message and return a error {@link Flux}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Flux} with the decoded exception
// * */
// <T> Flux<T> read(ClientHttpResponse inputMessage);
//
// /**
// * Read from the input message and return a error {@link Mono}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Mono} with the decoded exception
// * */
// <T> Mono<T> readMono(ClientHttpResponse inputMessage);
//
// }
//
// Path: src/main/java/com/webfluxclient/codec/HttpServerErrorDecoder.java
// public class HttpServerErrorDecoder implements ErrorDecoder<HttpServerException> {
// @Override
// public boolean canDecode(HttpStatus httpStatus) {
// return httpStatus.is5xxServerError();
// }
//
// @Override
// public HttpServerException decode(HttpStatus httpStatus, DataBuffer inputMessage) {
// return new HttpServerException(httpStatus, DataBuffers.readToString(inputMessage));
// }
// }
//
// Path: src/main/java/com/webfluxclient/handler/ReactiveInvocationHandlerFactory.java
// public interface ReactiveInvocationHandlerFactory {
// InvocationHandler build(
// ExtendedClientCodecConfigurer codecConfigurer,
// List<RequestProcessor> requestProcessors,
// List<ResponseProcessor> responseProcessors,
// Logger logger,
// LogLevel logLevel,
// Class<?> target,
// URI uri);
// }
// Path: src/test/java/com/webfluxclient/DefaultClientBuilderTest.java
import com.webfluxclient.codec.ErrorDecoder;
import com.webfluxclient.codec.ExtendedClientCodecConfigurer;
import com.webfluxclient.codec.HttpClientErrorDecoder;
import com.webfluxclient.codec.HttpErrorReader;
import com.webfluxclient.codec.HttpServerErrorDecoder;
import com.webfluxclient.handler.ReactiveInvocationHandlerFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.http.HttpStatus;
import java.net.URI;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
package com.webfluxclient;
@RunWith(MockitoJUnitRunner.class)
public class DefaultClientBuilderTest {
@Mock
private ReactiveInvocationHandlerFactory reactiveInvocationHandlerFactory;
@Captor | private ArgumentCaptor<ExtendedClientCodecConfigurer> codecConfigurerArgumentCaptor; |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/client/DefaultResponseBodyProcessor.java | // Path: src/main/java/com/webfluxclient/codec/HttpErrorReader.java
// public interface HttpErrorReader {
//
// /**
// * Whether the given {@link HttpStatus} is supported by this reader.
// * @param httpStatus received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canRead(HttpStatus httpStatus);
//
// /**
// * Read from the input message and return a error {@link Flux}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Flux} with the decoded exception
// * */
// <T> Flux<T> read(ClientHttpResponse inputMessage);
//
// /**
// * Read from the input message and return a error {@link Mono}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Mono} with the decoded exception
// * */
// <T> Mono<T> readMono(ClientHttpResponse inputMessage);
//
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isFlux(ResolvableType bodyType){
// return FLUX_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isMono(ResolvableType bodyType){
// return MONO_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isVoid(ResolvableType bodyType) {
// return VOID_TYPE.isAssignableFrom(bodyType);
// }
| import com.webfluxclient.codec.HttpErrorReader;
import lombok.AllArgsConstructor;
import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.http.client.reactive.ClientHttpResponse;
import org.springframework.web.reactive.function.BodyExtractor;
import org.springframework.web.reactive.function.BodyExtractors;
import org.springframework.web.reactive.function.client.ClientResponse;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.List;
import static com.webfluxclient.utils.Types.isFlux;
import static com.webfluxclient.utils.Types.isMono;
import static com.webfluxclient.utils.Types.isVoid; | package com.webfluxclient.client;
@AllArgsConstructor
public class DefaultResponseBodyProcessor implements ResponseBodyProcessor { | // Path: src/main/java/com/webfluxclient/codec/HttpErrorReader.java
// public interface HttpErrorReader {
//
// /**
// * Whether the given {@link HttpStatus} is supported by this reader.
// * @param httpStatus received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canRead(HttpStatus httpStatus);
//
// /**
// * Read from the input message and return a error {@link Flux}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Flux} with the decoded exception
// * */
// <T> Flux<T> read(ClientHttpResponse inputMessage);
//
// /**
// * Read from the input message and return a error {@link Mono}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Mono} with the decoded exception
// * */
// <T> Mono<T> readMono(ClientHttpResponse inputMessage);
//
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isFlux(ResolvableType bodyType){
// return FLUX_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isMono(ResolvableType bodyType){
// return MONO_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isVoid(ResolvableType bodyType) {
// return VOID_TYPE.isAssignableFrom(bodyType);
// }
// Path: src/main/java/com/webfluxclient/client/DefaultResponseBodyProcessor.java
import com.webfluxclient.codec.HttpErrorReader;
import lombok.AllArgsConstructor;
import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.http.client.reactive.ClientHttpResponse;
import org.springframework.web.reactive.function.BodyExtractor;
import org.springframework.web.reactive.function.BodyExtractors;
import org.springframework.web.reactive.function.client.ClientResponse;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.List;
import static com.webfluxclient.utils.Types.isFlux;
import static com.webfluxclient.utils.Types.isMono;
import static com.webfluxclient.utils.Types.isVoid;
package com.webfluxclient.client;
@AllArgsConstructor
public class DefaultResponseBodyProcessor implements ResponseBodyProcessor { | private List<HttpErrorReader> httpErrorReaders; |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/client/DefaultResponseBodyProcessor.java | // Path: src/main/java/com/webfluxclient/codec/HttpErrorReader.java
// public interface HttpErrorReader {
//
// /**
// * Whether the given {@link HttpStatus} is supported by this reader.
// * @param httpStatus received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canRead(HttpStatus httpStatus);
//
// /**
// * Read from the input message and return a error {@link Flux}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Flux} with the decoded exception
// * */
// <T> Flux<T> read(ClientHttpResponse inputMessage);
//
// /**
// * Read from the input message and return a error {@link Mono}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Mono} with the decoded exception
// * */
// <T> Mono<T> readMono(ClientHttpResponse inputMessage);
//
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isFlux(ResolvableType bodyType){
// return FLUX_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isMono(ResolvableType bodyType){
// return MONO_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isVoid(ResolvableType bodyType) {
// return VOID_TYPE.isAssignableFrom(bodyType);
// }
| import com.webfluxclient.codec.HttpErrorReader;
import lombok.AllArgsConstructor;
import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.http.client.reactive.ClientHttpResponse;
import org.springframework.web.reactive.function.BodyExtractor;
import org.springframework.web.reactive.function.BodyExtractors;
import org.springframework.web.reactive.function.client.ClientResponse;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.List;
import static com.webfluxclient.utils.Types.isFlux;
import static com.webfluxclient.utils.Types.isMono;
import static com.webfluxclient.utils.Types.isVoid; | package com.webfluxclient.client;
@AllArgsConstructor
public class DefaultResponseBodyProcessor implements ResponseBodyProcessor {
private List<HttpErrorReader> httpErrorReaders;
@Override
public Object process(Mono<ClientResponse> monoResponse, ResolvableType bodyType) { | // Path: src/main/java/com/webfluxclient/codec/HttpErrorReader.java
// public interface HttpErrorReader {
//
// /**
// * Whether the given {@link HttpStatus} is supported by this reader.
// * @param httpStatus received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canRead(HttpStatus httpStatus);
//
// /**
// * Read from the input message and return a error {@link Flux}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Flux} with the decoded exception
// * */
// <T> Flux<T> read(ClientHttpResponse inputMessage);
//
// /**
// * Read from the input message and return a error {@link Mono}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Mono} with the decoded exception
// * */
// <T> Mono<T> readMono(ClientHttpResponse inputMessage);
//
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isFlux(ResolvableType bodyType){
// return FLUX_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isMono(ResolvableType bodyType){
// return MONO_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isVoid(ResolvableType bodyType) {
// return VOID_TYPE.isAssignableFrom(bodyType);
// }
// Path: src/main/java/com/webfluxclient/client/DefaultResponseBodyProcessor.java
import com.webfluxclient.codec.HttpErrorReader;
import lombok.AllArgsConstructor;
import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.http.client.reactive.ClientHttpResponse;
import org.springframework.web.reactive.function.BodyExtractor;
import org.springframework.web.reactive.function.BodyExtractors;
import org.springframework.web.reactive.function.client.ClientResponse;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.List;
import static com.webfluxclient.utils.Types.isFlux;
import static com.webfluxclient.utils.Types.isMono;
import static com.webfluxclient.utils.Types.isVoid;
package com.webfluxclient.client;
@AllArgsConstructor
public class DefaultResponseBodyProcessor implements ResponseBodyProcessor {
private List<HttpErrorReader> httpErrorReaders;
@Override
public Object process(Mono<ClientResponse> monoResponse, ResolvableType bodyType) { | if (isMono(bodyType)) { |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/client/DefaultResponseBodyProcessor.java | // Path: src/main/java/com/webfluxclient/codec/HttpErrorReader.java
// public interface HttpErrorReader {
//
// /**
// * Whether the given {@link HttpStatus} is supported by this reader.
// * @param httpStatus received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canRead(HttpStatus httpStatus);
//
// /**
// * Read from the input message and return a error {@link Flux}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Flux} with the decoded exception
// * */
// <T> Flux<T> read(ClientHttpResponse inputMessage);
//
// /**
// * Read from the input message and return a error {@link Mono}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Mono} with the decoded exception
// * */
// <T> Mono<T> readMono(ClientHttpResponse inputMessage);
//
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isFlux(ResolvableType bodyType){
// return FLUX_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isMono(ResolvableType bodyType){
// return MONO_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isVoid(ResolvableType bodyType) {
// return VOID_TYPE.isAssignableFrom(bodyType);
// }
| import com.webfluxclient.codec.HttpErrorReader;
import lombok.AllArgsConstructor;
import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.http.client.reactive.ClientHttpResponse;
import org.springframework.web.reactive.function.BodyExtractor;
import org.springframework.web.reactive.function.BodyExtractors;
import org.springframework.web.reactive.function.client.ClientResponse;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.List;
import static com.webfluxclient.utils.Types.isFlux;
import static com.webfluxclient.utils.Types.isMono;
import static com.webfluxclient.utils.Types.isVoid; | package com.webfluxclient.client;
@AllArgsConstructor
public class DefaultResponseBodyProcessor implements ResponseBodyProcessor {
private List<HttpErrorReader> httpErrorReaders;
@Override
public Object process(Mono<ClientResponse> monoResponse, ResolvableType bodyType) {
if (isMono(bodyType)) {
return toMono(monoResponse, bodyType.getGeneric(0).getRawClass());
} | // Path: src/main/java/com/webfluxclient/codec/HttpErrorReader.java
// public interface HttpErrorReader {
//
// /**
// * Whether the given {@link HttpStatus} is supported by this reader.
// * @param httpStatus received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canRead(HttpStatus httpStatus);
//
// /**
// * Read from the input message and return a error {@link Flux}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Flux} with the decoded exception
// * */
// <T> Flux<T> read(ClientHttpResponse inputMessage);
//
// /**
// * Read from the input message and return a error {@link Mono}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Mono} with the decoded exception
// * */
// <T> Mono<T> readMono(ClientHttpResponse inputMessage);
//
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isFlux(ResolvableType bodyType){
// return FLUX_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isMono(ResolvableType bodyType){
// return MONO_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isVoid(ResolvableType bodyType) {
// return VOID_TYPE.isAssignableFrom(bodyType);
// }
// Path: src/main/java/com/webfluxclient/client/DefaultResponseBodyProcessor.java
import com.webfluxclient.codec.HttpErrorReader;
import lombok.AllArgsConstructor;
import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.http.client.reactive.ClientHttpResponse;
import org.springframework.web.reactive.function.BodyExtractor;
import org.springframework.web.reactive.function.BodyExtractors;
import org.springframework.web.reactive.function.client.ClientResponse;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.List;
import static com.webfluxclient.utils.Types.isFlux;
import static com.webfluxclient.utils.Types.isMono;
import static com.webfluxclient.utils.Types.isVoid;
package com.webfluxclient.client;
@AllArgsConstructor
public class DefaultResponseBodyProcessor implements ResponseBodyProcessor {
private List<HttpErrorReader> httpErrorReaders;
@Override
public Object process(Mono<ClientResponse> monoResponse, ResolvableType bodyType) {
if (isMono(bodyType)) {
return toMono(monoResponse, bodyType.getGeneric(0).getRawClass());
} | else if (isFlux(bodyType)) { |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/client/DefaultResponseBodyProcessor.java | // Path: src/main/java/com/webfluxclient/codec/HttpErrorReader.java
// public interface HttpErrorReader {
//
// /**
// * Whether the given {@link HttpStatus} is supported by this reader.
// * @param httpStatus received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canRead(HttpStatus httpStatus);
//
// /**
// * Read from the input message and return a error {@link Flux}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Flux} with the decoded exception
// * */
// <T> Flux<T> read(ClientHttpResponse inputMessage);
//
// /**
// * Read from the input message and return a error {@link Mono}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Mono} with the decoded exception
// * */
// <T> Mono<T> readMono(ClientHttpResponse inputMessage);
//
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isFlux(ResolvableType bodyType){
// return FLUX_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isMono(ResolvableType bodyType){
// return MONO_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isVoid(ResolvableType bodyType) {
// return VOID_TYPE.isAssignableFrom(bodyType);
// }
| import com.webfluxclient.codec.HttpErrorReader;
import lombok.AllArgsConstructor;
import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.http.client.reactive.ClientHttpResponse;
import org.springframework.web.reactive.function.BodyExtractor;
import org.springframework.web.reactive.function.BodyExtractors;
import org.springframework.web.reactive.function.client.ClientResponse;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.List;
import static com.webfluxclient.utils.Types.isFlux;
import static com.webfluxclient.utils.Types.isMono;
import static com.webfluxclient.utils.Types.isVoid; | package com.webfluxclient.client;
@AllArgsConstructor
public class DefaultResponseBodyProcessor implements ResponseBodyProcessor {
private List<HttpErrorReader> httpErrorReaders;
@Override
public Object process(Mono<ClientResponse> monoResponse, ResolvableType bodyType) {
if (isMono(bodyType)) {
return toMono(monoResponse, bodyType.getGeneric(0).getRawClass());
}
else if (isFlux(bodyType)) {
return toFlux(monoResponse, bodyType.getGeneric(0).getRawClass());
} | // Path: src/main/java/com/webfluxclient/codec/HttpErrorReader.java
// public interface HttpErrorReader {
//
// /**
// * Whether the given {@link HttpStatus} is supported by this reader.
// * @param httpStatus received by the client
// * @return {@code true} if supported, {@code false} otherwise
// */
// boolean canRead(HttpStatus httpStatus);
//
// /**
// * Read from the input message and return a error {@link Flux}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Flux} with the decoded exception
// * */
// <T> Flux<T> read(ClientHttpResponse inputMessage);
//
// /**
// * Read from the input message and return a error {@link Mono}
// *
// * @param inputMessage the message to read from
// * @return the error {@link Mono} with the decoded exception
// * */
// <T> Mono<T> readMono(ClientHttpResponse inputMessage);
//
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isFlux(ResolvableType bodyType){
// return FLUX_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isMono(ResolvableType bodyType){
// return MONO_TYPE.isAssignableFrom(bodyType);
// }
//
// Path: src/main/java/com/webfluxclient/utils/Types.java
// public static boolean isVoid(ResolvableType bodyType) {
// return VOID_TYPE.isAssignableFrom(bodyType);
// }
// Path: src/main/java/com/webfluxclient/client/DefaultResponseBodyProcessor.java
import com.webfluxclient.codec.HttpErrorReader;
import lombok.AllArgsConstructor;
import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.http.client.reactive.ClientHttpResponse;
import org.springframework.web.reactive.function.BodyExtractor;
import org.springframework.web.reactive.function.BodyExtractors;
import org.springframework.web.reactive.function.client.ClientResponse;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.List;
import static com.webfluxclient.utils.Types.isFlux;
import static com.webfluxclient.utils.Types.isMono;
import static com.webfluxclient.utils.Types.isVoid;
package com.webfluxclient.client;
@AllArgsConstructor
public class DefaultResponseBodyProcessor implements ResponseBodyProcessor {
private List<HttpErrorReader> httpErrorReaders;
@Override
public Object process(Mono<ClientResponse> monoResponse, ResolvableType bodyType) {
if (isMono(bodyType)) {
return toMono(monoResponse, bodyType.getGeneric(0).getRawClass());
}
else if (isFlux(bodyType)) {
return toFlux(monoResponse, bodyType.getGeneric(0).getRawClass());
} | else if (isVoid(bodyType)) { |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/ClientBuilder.java | // Path: src/main/java/com/webfluxclient/codec/ExtendedClientCodecConfigurer.java
// public interface ExtendedClientCodecConfigurer extends ClientCodecConfigurer {
//
// List<HttpErrorReader> getErrorReaders();
//
// ExtendedCustomCodecs customCodecs();
//
// ExtendedClientDefaultCodecs defaultCodecs();
//
// static ExtendedClientCodecConfigurer create(){
// return new DefaultExtendedClientCodecConfigurer();
// }
//
// interface ExtendedClientDefaultCodecs extends ClientDefaultCodecs {
// void httpClientErrorDecoder(HttpClientErrorDecoder clientErrorDecoder);
// void httpServerErrorDecoder(HttpServerErrorDecoder serverErrorDecoder);
// }
//
// interface ExtendedCustomCodecs extends CustomCodecs{
// void errorReader(HttpErrorReader errorReader);
// void errorDecoder(ErrorDecoder errorDecoder);
// }
// }
//
// Path: src/main/java/com/webfluxclient/handler/DefaultReactiveInvocationHandlerFactory.java
// public class DefaultReactiveInvocationHandlerFactory implements ReactiveInvocationHandlerFactory {
//
// private MethodMetadataFactory methodMetadataFactory;
// private RequestExecutorFactory requestExecutorFactory;
// private ExchangeFilterFunctionFactory exchangeFilterFunctionFactory;
//
// public DefaultReactiveInvocationHandlerFactory() {
// this.methodMetadataFactory = new MethodMetadataFactory();
// this.requestExecutorFactory = new DefaultRequestExecutorFactory();
// this.exchangeFilterFunctionFactory = new DefaultExchangeFilterFunctionFactory();
// }
//
// @Override
// public InvocationHandler build(ExtendedClientCodecConfigurer codecConfigurer, List<RequestProcessor> requestProcessors, List<ResponseProcessor> responseProcessors, Logger logger, LogLevel logLevel, Class<?> target, URI uri) {
// ExchangeFilterFunction exchangeFilterFunction = exchangeFilterFunctionFactory.build(requestProcessors, responseProcessors, logger, logLevel);
// RequestExecutor requestExecutor = requestExecutorFactory.build(codecConfigurer, exchangeFilterFunction);
// ResponseBodyProcessor responseBodyProcessor = new DefaultResponseBodyProcessor(codecConfigurer.getErrorReaders());
//
// Map<Method, ClientMethodHandler> invocationDispatcher = methodMetadataFactory.build(target, uri)
// .stream()
// .collect(toMap(MethodMetadata::getTargetMethod, methodMetadata -> new DefaultClientMethodHandler(methodMetadata, requestExecutor, responseBodyProcessor)));
//
// return new DefaultReactiveInvocationHandler(invocationDispatcher);
// }
// }
| import com.webfluxclient.codec.ExtendedClientCodecConfigurer;
import com.webfluxclient.handler.DefaultReactiveInvocationHandlerFactory;
import java.net.URI;
import java.util.List;
import java.util.function.Consumer; | package com.webfluxclient;
/**
* A mutable builder to configure a Proxy
*
* @author Jérémy Brixhe
* */
public interface ClientBuilder {
ClientBuilder registerDefaultCodecs(boolean registerDefaults);
| // Path: src/main/java/com/webfluxclient/codec/ExtendedClientCodecConfigurer.java
// public interface ExtendedClientCodecConfigurer extends ClientCodecConfigurer {
//
// List<HttpErrorReader> getErrorReaders();
//
// ExtendedCustomCodecs customCodecs();
//
// ExtendedClientDefaultCodecs defaultCodecs();
//
// static ExtendedClientCodecConfigurer create(){
// return new DefaultExtendedClientCodecConfigurer();
// }
//
// interface ExtendedClientDefaultCodecs extends ClientDefaultCodecs {
// void httpClientErrorDecoder(HttpClientErrorDecoder clientErrorDecoder);
// void httpServerErrorDecoder(HttpServerErrorDecoder serverErrorDecoder);
// }
//
// interface ExtendedCustomCodecs extends CustomCodecs{
// void errorReader(HttpErrorReader errorReader);
// void errorDecoder(ErrorDecoder errorDecoder);
// }
// }
//
// Path: src/main/java/com/webfluxclient/handler/DefaultReactiveInvocationHandlerFactory.java
// public class DefaultReactiveInvocationHandlerFactory implements ReactiveInvocationHandlerFactory {
//
// private MethodMetadataFactory methodMetadataFactory;
// private RequestExecutorFactory requestExecutorFactory;
// private ExchangeFilterFunctionFactory exchangeFilterFunctionFactory;
//
// public DefaultReactiveInvocationHandlerFactory() {
// this.methodMetadataFactory = new MethodMetadataFactory();
// this.requestExecutorFactory = new DefaultRequestExecutorFactory();
// this.exchangeFilterFunctionFactory = new DefaultExchangeFilterFunctionFactory();
// }
//
// @Override
// public InvocationHandler build(ExtendedClientCodecConfigurer codecConfigurer, List<RequestProcessor> requestProcessors, List<ResponseProcessor> responseProcessors, Logger logger, LogLevel logLevel, Class<?> target, URI uri) {
// ExchangeFilterFunction exchangeFilterFunction = exchangeFilterFunctionFactory.build(requestProcessors, responseProcessors, logger, logLevel);
// RequestExecutor requestExecutor = requestExecutorFactory.build(codecConfigurer, exchangeFilterFunction);
// ResponseBodyProcessor responseBodyProcessor = new DefaultResponseBodyProcessor(codecConfigurer.getErrorReaders());
//
// Map<Method, ClientMethodHandler> invocationDispatcher = methodMetadataFactory.build(target, uri)
// .stream()
// .collect(toMap(MethodMetadata::getTargetMethod, methodMetadata -> new DefaultClientMethodHandler(methodMetadata, requestExecutor, responseBodyProcessor)));
//
// return new DefaultReactiveInvocationHandler(invocationDispatcher);
// }
// }
// Path: src/main/java/com/webfluxclient/ClientBuilder.java
import com.webfluxclient.codec.ExtendedClientCodecConfigurer;
import com.webfluxclient.handler.DefaultReactiveInvocationHandlerFactory;
import java.net.URI;
import java.util.List;
import java.util.function.Consumer;
package com.webfluxclient;
/**
* A mutable builder to configure a Proxy
*
* @author Jérémy Brixhe
* */
public interface ClientBuilder {
ClientBuilder registerDefaultCodecs(boolean registerDefaults);
| ClientBuilder defaultCodecs(Consumer<ExtendedClientCodecConfigurer.ExtendedClientDefaultCodecs> defaultCodecsConfigurerConsumer); |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/ClientBuilder.java | // Path: src/main/java/com/webfluxclient/codec/ExtendedClientCodecConfigurer.java
// public interface ExtendedClientCodecConfigurer extends ClientCodecConfigurer {
//
// List<HttpErrorReader> getErrorReaders();
//
// ExtendedCustomCodecs customCodecs();
//
// ExtendedClientDefaultCodecs defaultCodecs();
//
// static ExtendedClientCodecConfigurer create(){
// return new DefaultExtendedClientCodecConfigurer();
// }
//
// interface ExtendedClientDefaultCodecs extends ClientDefaultCodecs {
// void httpClientErrorDecoder(HttpClientErrorDecoder clientErrorDecoder);
// void httpServerErrorDecoder(HttpServerErrorDecoder serverErrorDecoder);
// }
//
// interface ExtendedCustomCodecs extends CustomCodecs{
// void errorReader(HttpErrorReader errorReader);
// void errorDecoder(ErrorDecoder errorDecoder);
// }
// }
//
// Path: src/main/java/com/webfluxclient/handler/DefaultReactiveInvocationHandlerFactory.java
// public class DefaultReactiveInvocationHandlerFactory implements ReactiveInvocationHandlerFactory {
//
// private MethodMetadataFactory methodMetadataFactory;
// private RequestExecutorFactory requestExecutorFactory;
// private ExchangeFilterFunctionFactory exchangeFilterFunctionFactory;
//
// public DefaultReactiveInvocationHandlerFactory() {
// this.methodMetadataFactory = new MethodMetadataFactory();
// this.requestExecutorFactory = new DefaultRequestExecutorFactory();
// this.exchangeFilterFunctionFactory = new DefaultExchangeFilterFunctionFactory();
// }
//
// @Override
// public InvocationHandler build(ExtendedClientCodecConfigurer codecConfigurer, List<RequestProcessor> requestProcessors, List<ResponseProcessor> responseProcessors, Logger logger, LogLevel logLevel, Class<?> target, URI uri) {
// ExchangeFilterFunction exchangeFilterFunction = exchangeFilterFunctionFactory.build(requestProcessors, responseProcessors, logger, logLevel);
// RequestExecutor requestExecutor = requestExecutorFactory.build(codecConfigurer, exchangeFilterFunction);
// ResponseBodyProcessor responseBodyProcessor = new DefaultResponseBodyProcessor(codecConfigurer.getErrorReaders());
//
// Map<Method, ClientMethodHandler> invocationDispatcher = methodMetadataFactory.build(target, uri)
// .stream()
// .collect(toMap(MethodMetadata::getTargetMethod, methodMetadata -> new DefaultClientMethodHandler(methodMetadata, requestExecutor, responseBodyProcessor)));
//
// return new DefaultReactiveInvocationHandler(invocationDispatcher);
// }
// }
| import com.webfluxclient.codec.ExtendedClientCodecConfigurer;
import com.webfluxclient.handler.DefaultReactiveInvocationHandlerFactory;
import java.net.URI;
import java.util.List;
import java.util.function.Consumer; | package com.webfluxclient;
/**
* A mutable builder to configure a Proxy
*
* @author Jérémy Brixhe
* */
public interface ClientBuilder {
ClientBuilder registerDefaultCodecs(boolean registerDefaults);
ClientBuilder defaultCodecs(Consumer<ExtendedClientCodecConfigurer.ExtendedClientDefaultCodecs> defaultCodecsConfigurerConsumer);
ClientBuilder customCodecs(Consumer<ExtendedClientCodecConfigurer.ExtendedCustomCodecs> customCodecsConfigurerConsumer);
/**
* Add a {@link Logger} to the builder.
*
* @param logger The logger to use.
* @return this builder
* */
ClientBuilder logger(Logger logger);
/**
* Add a {@link LogLevel} to the builder.
*
* @param logLevel The logLevel to use.
* @return this builder
* */
ClientBuilder logLevel(LogLevel logLevel);
/**
* Add a {@link RequestProcessor} to the builder.
*
* @param requestProcessor The request consumer to use.
* @return this builder
* */
ClientBuilder requestProcessor(RequestProcessor requestProcessor);
ClientBuilder requestProcessors(Consumer<List<RequestProcessor>> requestInterceptorConsumer);
ClientBuilder responseProcessor(ResponseProcessor requestInterceptor);
ClientBuilder responseProcessors(Consumer<List<ResponseProcessor>> responseInterceptorConsumer);
/**
* Build the proxy instance
*
* @param target The interface class to initialize the new proxy.
* @param uri The base Uri for all request
* @return a configured Porxy for the target class
* */
<T> T build(Class<T> target, URI uri);
/**
* Return a mutable builder with the default initialization.
*/
static ClientBuilder builder(){ | // Path: src/main/java/com/webfluxclient/codec/ExtendedClientCodecConfigurer.java
// public interface ExtendedClientCodecConfigurer extends ClientCodecConfigurer {
//
// List<HttpErrorReader> getErrorReaders();
//
// ExtendedCustomCodecs customCodecs();
//
// ExtendedClientDefaultCodecs defaultCodecs();
//
// static ExtendedClientCodecConfigurer create(){
// return new DefaultExtendedClientCodecConfigurer();
// }
//
// interface ExtendedClientDefaultCodecs extends ClientDefaultCodecs {
// void httpClientErrorDecoder(HttpClientErrorDecoder clientErrorDecoder);
// void httpServerErrorDecoder(HttpServerErrorDecoder serverErrorDecoder);
// }
//
// interface ExtendedCustomCodecs extends CustomCodecs{
// void errorReader(HttpErrorReader errorReader);
// void errorDecoder(ErrorDecoder errorDecoder);
// }
// }
//
// Path: src/main/java/com/webfluxclient/handler/DefaultReactiveInvocationHandlerFactory.java
// public class DefaultReactiveInvocationHandlerFactory implements ReactiveInvocationHandlerFactory {
//
// private MethodMetadataFactory methodMetadataFactory;
// private RequestExecutorFactory requestExecutorFactory;
// private ExchangeFilterFunctionFactory exchangeFilterFunctionFactory;
//
// public DefaultReactiveInvocationHandlerFactory() {
// this.methodMetadataFactory = new MethodMetadataFactory();
// this.requestExecutorFactory = new DefaultRequestExecutorFactory();
// this.exchangeFilterFunctionFactory = new DefaultExchangeFilterFunctionFactory();
// }
//
// @Override
// public InvocationHandler build(ExtendedClientCodecConfigurer codecConfigurer, List<RequestProcessor> requestProcessors, List<ResponseProcessor> responseProcessors, Logger logger, LogLevel logLevel, Class<?> target, URI uri) {
// ExchangeFilterFunction exchangeFilterFunction = exchangeFilterFunctionFactory.build(requestProcessors, responseProcessors, logger, logLevel);
// RequestExecutor requestExecutor = requestExecutorFactory.build(codecConfigurer, exchangeFilterFunction);
// ResponseBodyProcessor responseBodyProcessor = new DefaultResponseBodyProcessor(codecConfigurer.getErrorReaders());
//
// Map<Method, ClientMethodHandler> invocationDispatcher = methodMetadataFactory.build(target, uri)
// .stream()
// .collect(toMap(MethodMetadata::getTargetMethod, methodMetadata -> new DefaultClientMethodHandler(methodMetadata, requestExecutor, responseBodyProcessor)));
//
// return new DefaultReactiveInvocationHandler(invocationDispatcher);
// }
// }
// Path: src/main/java/com/webfluxclient/ClientBuilder.java
import com.webfluxclient.codec.ExtendedClientCodecConfigurer;
import com.webfluxclient.handler.DefaultReactiveInvocationHandlerFactory;
import java.net.URI;
import java.util.List;
import java.util.function.Consumer;
package com.webfluxclient;
/**
* A mutable builder to configure a Proxy
*
* @author Jérémy Brixhe
* */
public interface ClientBuilder {
ClientBuilder registerDefaultCodecs(boolean registerDefaults);
ClientBuilder defaultCodecs(Consumer<ExtendedClientCodecConfigurer.ExtendedClientDefaultCodecs> defaultCodecsConfigurerConsumer);
ClientBuilder customCodecs(Consumer<ExtendedClientCodecConfigurer.ExtendedCustomCodecs> customCodecsConfigurerConsumer);
/**
* Add a {@link Logger} to the builder.
*
* @param logger The logger to use.
* @return this builder
* */
ClientBuilder logger(Logger logger);
/**
* Add a {@link LogLevel} to the builder.
*
* @param logLevel The logLevel to use.
* @return this builder
* */
ClientBuilder logLevel(LogLevel logLevel);
/**
* Add a {@link RequestProcessor} to the builder.
*
* @param requestProcessor The request consumer to use.
* @return this builder
* */
ClientBuilder requestProcessor(RequestProcessor requestProcessor);
ClientBuilder requestProcessors(Consumer<List<RequestProcessor>> requestInterceptorConsumer);
ClientBuilder responseProcessor(ResponseProcessor requestInterceptor);
ClientBuilder responseProcessors(Consumer<List<ResponseProcessor>> responseInterceptorConsumer);
/**
* Build the proxy instance
*
* @param target The interface class to initialize the new proxy.
* @param uri The base Uri for all request
* @return a configured Porxy for the target class
* */
<T> T build(Class<T> target, URI uri);
/**
* Return a mutable builder with the default initialization.
*/
static ClientBuilder builder(){ | return new DefaultClientBuilder(new DefaultReactiveInvocationHandlerFactory()); |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/metadata/annotation/PathVariableParameterProcessor.java | // Path: src/main/java/com/webfluxclient/metadata/MethodMetadata.java
// @Getter
// public class MethodMetadata {
// private Method targetMethod;
// private ResolvableType responseBodyType;
// private RequestTemplate requestTemplate;
//
// private MethodMetadata(Builder builder) {
// targetMethod = builder.targetMethod;
// responseBodyType = builder.returnType;
// requestTemplate = new RequestTemplate(
// builder.uriBuilder,
// builder.httpMethod,
// new RequestHeaders(builder.headers, builder.headerIndexToName),
// builder.bodyIndex,
// builder.bodyType,
// builder.variableIndexToName);
// }
//
// public static Builder newBuilder(URI baseUri) {
// return new Builder(baseUri.getScheme(), baseUri.getAuthority());
// }
//
// public static Builder newBuilder(MethodMetadata other) {
// return new Builder(other);
// }
//
// public static class Builder {
// private UriBuilder uriBuilder;
// private MultiValueMap<Integer, String> variableIndexToName;
// private Map<String, RequestHeader> headers;
// private Map<Integer, String> headerIndexToName;
// private HttpMethod httpMethod;
// private Method targetMethod;
// private Integer bodyIndex;
// private ResolvableType returnType;
// private ResolvableType bodyType;
//
// private Builder() {
// variableIndexToName = new LinkedMultiValueMap<>();
// headers = new HashMap<>();
// headerIndexToName = new HashMap<>();
// }
//
// public Builder(String scheme, String authority) {
// this();
// if (scheme != null && authority != null) {
// uriBuilder = new DefaultUriBuilderFactory(scheme + "://" + authority).builder();
// }
// else {
// uriBuilder = new DefaultUriBuilderFactory().builder();
// }
// }
//
// public Builder(MethodMetadata other) {
// this();
// uriBuilder = new DefaultUriBuilderFactory(other.getRequestTemplate().getUriBuilder().build().toString()).builder();
// variableIndexToName.putAll(other.getRequestTemplate().getVariableIndexToName());
// headers.putAll(other.getRequestTemplate().getRequestHeaders().getHeaders());
// headerIndexToName.putAll(other.getRequestTemplate().getRequestHeaders().getIndexToName());
// httpMethod = other.getRequestTemplate().getHttpMethod();
// targetMethod = other.getTargetMethod();
// }
//
// public Builder addPath(String path) {
// uriBuilder.path(path);
// return this;
// }
//
// public Builder addPathIndex(Integer index, String pathVariable) {
// this.variableIndexToName.add(index, pathVariable);
// return this;
// }
//
// public Builder addHeader(String name, String value) {
// headers.put(name, new RequestHeader.BasicRequestHeader(name, value));
// return this;
// }
//
// public Builder addHeader(Integer index, String name) {
// headers.put(name, new RequestHeader.DynamicRequestHeader(name));
// headerIndexToName.put(index, name);
// return this;
// }
//
// public Builder addParameter(Integer index, String name) {
// variableIndexToName.add(index, name);
// uriBuilder.query(name + "={" + name + "}");
// return this;
// }
//
// public Builder httpMethod(HttpMethod httpMethod) {
// this.httpMethod = httpMethod;
// return this;
// }
//
// public Builder body(Integer bodyIndex, Type bodyType) {
// if (this.bodyType != null && this.bodyIndex != null) {
// throw new IllegalArgumentException();
// }
//
// this.bodyIndex = bodyIndex;
// this.bodyType = ResolvableType.forType(bodyType);
// return this;
// }
//
// public Builder targetMethod(Method targetMethod) {
// this.targetMethod = targetMethod;
// this.returnType = ResolvableType.forMethodReturnType(targetMethod);
// return this;
// }
//
// public MethodMetadata build() {
// return new MethodMetadata(this);
// }
// }
// }
| import com.webfluxclient.metadata.MethodMetadata;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type; | /*
* Copyright 2013-2015 the original author or authors.
*
* 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.webfluxclient.metadata.annotation;
public class PathVariableParameterProcessor implements AnnotatedParameterProcessor {
@Override
public Class<? extends Annotation> getAnnotationType() {
return PathVariable.class;
}
@Override | // Path: src/main/java/com/webfluxclient/metadata/MethodMetadata.java
// @Getter
// public class MethodMetadata {
// private Method targetMethod;
// private ResolvableType responseBodyType;
// private RequestTemplate requestTemplate;
//
// private MethodMetadata(Builder builder) {
// targetMethod = builder.targetMethod;
// responseBodyType = builder.returnType;
// requestTemplate = new RequestTemplate(
// builder.uriBuilder,
// builder.httpMethod,
// new RequestHeaders(builder.headers, builder.headerIndexToName),
// builder.bodyIndex,
// builder.bodyType,
// builder.variableIndexToName);
// }
//
// public static Builder newBuilder(URI baseUri) {
// return new Builder(baseUri.getScheme(), baseUri.getAuthority());
// }
//
// public static Builder newBuilder(MethodMetadata other) {
// return new Builder(other);
// }
//
// public static class Builder {
// private UriBuilder uriBuilder;
// private MultiValueMap<Integer, String> variableIndexToName;
// private Map<String, RequestHeader> headers;
// private Map<Integer, String> headerIndexToName;
// private HttpMethod httpMethod;
// private Method targetMethod;
// private Integer bodyIndex;
// private ResolvableType returnType;
// private ResolvableType bodyType;
//
// private Builder() {
// variableIndexToName = new LinkedMultiValueMap<>();
// headers = new HashMap<>();
// headerIndexToName = new HashMap<>();
// }
//
// public Builder(String scheme, String authority) {
// this();
// if (scheme != null && authority != null) {
// uriBuilder = new DefaultUriBuilderFactory(scheme + "://" + authority).builder();
// }
// else {
// uriBuilder = new DefaultUriBuilderFactory().builder();
// }
// }
//
// public Builder(MethodMetadata other) {
// this();
// uriBuilder = new DefaultUriBuilderFactory(other.getRequestTemplate().getUriBuilder().build().toString()).builder();
// variableIndexToName.putAll(other.getRequestTemplate().getVariableIndexToName());
// headers.putAll(other.getRequestTemplate().getRequestHeaders().getHeaders());
// headerIndexToName.putAll(other.getRequestTemplate().getRequestHeaders().getIndexToName());
// httpMethod = other.getRequestTemplate().getHttpMethod();
// targetMethod = other.getTargetMethod();
// }
//
// public Builder addPath(String path) {
// uriBuilder.path(path);
// return this;
// }
//
// public Builder addPathIndex(Integer index, String pathVariable) {
// this.variableIndexToName.add(index, pathVariable);
// return this;
// }
//
// public Builder addHeader(String name, String value) {
// headers.put(name, new RequestHeader.BasicRequestHeader(name, value));
// return this;
// }
//
// public Builder addHeader(Integer index, String name) {
// headers.put(name, new RequestHeader.DynamicRequestHeader(name));
// headerIndexToName.put(index, name);
// return this;
// }
//
// public Builder addParameter(Integer index, String name) {
// variableIndexToName.add(index, name);
// uriBuilder.query(name + "={" + name + "}");
// return this;
// }
//
// public Builder httpMethod(HttpMethod httpMethod) {
// this.httpMethod = httpMethod;
// return this;
// }
//
// public Builder body(Integer bodyIndex, Type bodyType) {
// if (this.bodyType != null && this.bodyIndex != null) {
// throw new IllegalArgumentException();
// }
//
// this.bodyIndex = bodyIndex;
// this.bodyType = ResolvableType.forType(bodyType);
// return this;
// }
//
// public Builder targetMethod(Method targetMethod) {
// this.targetMethod = targetMethod;
// this.returnType = ResolvableType.forMethodReturnType(targetMethod);
// return this;
// }
//
// public MethodMetadata build() {
// return new MethodMetadata(this);
// }
// }
// }
// Path: src/main/java/com/webfluxclient/metadata/annotation/PathVariableParameterProcessor.java
import com.webfluxclient.metadata.MethodMetadata;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
/*
* Copyright 2013-2015 the original author or authors.
*
* 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.webfluxclient.metadata.annotation;
public class PathVariableParameterProcessor implements AnnotatedParameterProcessor {
@Override
public Class<? extends Annotation> getAnnotationType() {
return PathVariable.class;
}
@Override | public void processAnnotation(MethodMetadata.Builder requestTemplateBuilder, Annotation annotation, Integer integer, Type parameterType) { |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/client/ExchangeFilterFunctions.java | // Path: src/main/java/com/webfluxclient/LogLevel.java
// public enum LogLevel {
// /** No logs. */
// NONE,
//
// /**
// * Logs request and response lines.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: application/json
// *
// * <-- 200 OK POST /hello (22ms)
// * }</pre>
// */
// BASIC,
//
// /**
// * Logs request and response lines and their respective headers.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: plain/text
// * Headers:
// * - Accept-Language: en
// * - Accept-Charset: UTF-8
// * --> END POST
// *
// * <-- 200 OK POST /hello (22ms)
// * Headers:
// * - Content-Type: plain/text
// * <-- END HTTP
// * }</pre>
// */
// HEADERS
// }
//
// Path: src/main/java/com/webfluxclient/Logger.java
// public interface Logger {
// void log(Supplier<String> messageSupplier);
// void log(String message);
// }
//
// Path: src/main/java/com/webfluxclient/RequestProcessor.java
// @FunctionalInterface
// public interface RequestProcessor {
//
// ClientRequest process(ClientRequest request);
//
// default RequestProcessor andThen(RequestProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
//
// Path: src/main/java/com/webfluxclient/ResponseProcessor.java
// @FunctionalInterface
// public interface ResponseProcessor {
//
// ClientResponse process(ClientResponse clientResponse);
//
// default ResponseProcessor andThen(ResponseProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
| import com.webfluxclient.LogLevel;
import com.webfluxclient.Logger;
import com.webfluxclient.RequestProcessor;
import com.webfluxclient.ResponseProcessor;
import org.springframework.http.HttpHeaders;
import org.springframework.util.Assert;
import org.springframework.web.reactive.function.client.ClientRequest;
import org.springframework.web.reactive.function.client.ClientResponse;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.ExchangeFunction;
import reactor.core.publisher.Mono;
import java.util.concurrent.TimeUnit;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunction.ofRequestProcessor;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunction.ofResponseProcessor; | package com.webfluxclient.client;
class ExchangeFilterFunctions {
static ExchangeFilterFunction requestProcessorFilter(RequestProcessor requestProcessor) {
return ofRequestProcessor(clientRequest -> Mono.just(requestProcessor.process(clientRequest)));
}
| // Path: src/main/java/com/webfluxclient/LogLevel.java
// public enum LogLevel {
// /** No logs. */
// NONE,
//
// /**
// * Logs request and response lines.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: application/json
// *
// * <-- 200 OK POST /hello (22ms)
// * }</pre>
// */
// BASIC,
//
// /**
// * Logs request and response lines and their respective headers.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: plain/text
// * Headers:
// * - Accept-Language: en
// * - Accept-Charset: UTF-8
// * --> END POST
// *
// * <-- 200 OK POST /hello (22ms)
// * Headers:
// * - Content-Type: plain/text
// * <-- END HTTP
// * }</pre>
// */
// HEADERS
// }
//
// Path: src/main/java/com/webfluxclient/Logger.java
// public interface Logger {
// void log(Supplier<String> messageSupplier);
// void log(String message);
// }
//
// Path: src/main/java/com/webfluxclient/RequestProcessor.java
// @FunctionalInterface
// public interface RequestProcessor {
//
// ClientRequest process(ClientRequest request);
//
// default RequestProcessor andThen(RequestProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
//
// Path: src/main/java/com/webfluxclient/ResponseProcessor.java
// @FunctionalInterface
// public interface ResponseProcessor {
//
// ClientResponse process(ClientResponse clientResponse);
//
// default ResponseProcessor andThen(ResponseProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
// Path: src/main/java/com/webfluxclient/client/ExchangeFilterFunctions.java
import com.webfluxclient.LogLevel;
import com.webfluxclient.Logger;
import com.webfluxclient.RequestProcessor;
import com.webfluxclient.ResponseProcessor;
import org.springframework.http.HttpHeaders;
import org.springframework.util.Assert;
import org.springframework.web.reactive.function.client.ClientRequest;
import org.springframework.web.reactive.function.client.ClientResponse;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.ExchangeFunction;
import reactor.core.publisher.Mono;
import java.util.concurrent.TimeUnit;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunction.ofRequestProcessor;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunction.ofResponseProcessor;
package com.webfluxclient.client;
class ExchangeFilterFunctions {
static ExchangeFilterFunction requestProcessorFilter(RequestProcessor requestProcessor) {
return ofRequestProcessor(clientRequest -> Mono.just(requestProcessor.process(clientRequest)));
}
| static ExchangeFilterFunction responseInterceptorFilter(ResponseProcessor responseProcessor) { |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/client/ExchangeFilterFunctions.java | // Path: src/main/java/com/webfluxclient/LogLevel.java
// public enum LogLevel {
// /** No logs. */
// NONE,
//
// /**
// * Logs request and response lines.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: application/json
// *
// * <-- 200 OK POST /hello (22ms)
// * }</pre>
// */
// BASIC,
//
// /**
// * Logs request and response lines and their respective headers.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: plain/text
// * Headers:
// * - Accept-Language: en
// * - Accept-Charset: UTF-8
// * --> END POST
// *
// * <-- 200 OK POST /hello (22ms)
// * Headers:
// * - Content-Type: plain/text
// * <-- END HTTP
// * }</pre>
// */
// HEADERS
// }
//
// Path: src/main/java/com/webfluxclient/Logger.java
// public interface Logger {
// void log(Supplier<String> messageSupplier);
// void log(String message);
// }
//
// Path: src/main/java/com/webfluxclient/RequestProcessor.java
// @FunctionalInterface
// public interface RequestProcessor {
//
// ClientRequest process(ClientRequest request);
//
// default RequestProcessor andThen(RequestProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
//
// Path: src/main/java/com/webfluxclient/ResponseProcessor.java
// @FunctionalInterface
// public interface ResponseProcessor {
//
// ClientResponse process(ClientResponse clientResponse);
//
// default ResponseProcessor andThen(ResponseProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
| import com.webfluxclient.LogLevel;
import com.webfluxclient.Logger;
import com.webfluxclient.RequestProcessor;
import com.webfluxclient.ResponseProcessor;
import org.springframework.http.HttpHeaders;
import org.springframework.util.Assert;
import org.springframework.web.reactive.function.client.ClientRequest;
import org.springframework.web.reactive.function.client.ClientResponse;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.ExchangeFunction;
import reactor.core.publisher.Mono;
import java.util.concurrent.TimeUnit;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunction.ofRequestProcessor;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunction.ofResponseProcessor; | package com.webfluxclient.client;
class ExchangeFilterFunctions {
static ExchangeFilterFunction requestProcessorFilter(RequestProcessor requestProcessor) {
return ofRequestProcessor(clientRequest -> Mono.just(requestProcessor.process(clientRequest)));
}
static ExchangeFilterFunction responseInterceptorFilter(ResponseProcessor responseProcessor) {
return ofResponseProcessor(clientResponse -> Mono.just(responseProcessor.process(clientResponse)));
}
| // Path: src/main/java/com/webfluxclient/LogLevel.java
// public enum LogLevel {
// /** No logs. */
// NONE,
//
// /**
// * Logs request and response lines.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: application/json
// *
// * <-- 200 OK POST /hello (22ms)
// * }</pre>
// */
// BASIC,
//
// /**
// * Logs request and response lines and their respective headers.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: plain/text
// * Headers:
// * - Accept-Language: en
// * - Accept-Charset: UTF-8
// * --> END POST
// *
// * <-- 200 OK POST /hello (22ms)
// * Headers:
// * - Content-Type: plain/text
// * <-- END HTTP
// * }</pre>
// */
// HEADERS
// }
//
// Path: src/main/java/com/webfluxclient/Logger.java
// public interface Logger {
// void log(Supplier<String> messageSupplier);
// void log(String message);
// }
//
// Path: src/main/java/com/webfluxclient/RequestProcessor.java
// @FunctionalInterface
// public interface RequestProcessor {
//
// ClientRequest process(ClientRequest request);
//
// default RequestProcessor andThen(RequestProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
//
// Path: src/main/java/com/webfluxclient/ResponseProcessor.java
// @FunctionalInterface
// public interface ResponseProcessor {
//
// ClientResponse process(ClientResponse clientResponse);
//
// default ResponseProcessor andThen(ResponseProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
// Path: src/main/java/com/webfluxclient/client/ExchangeFilterFunctions.java
import com.webfluxclient.LogLevel;
import com.webfluxclient.Logger;
import com.webfluxclient.RequestProcessor;
import com.webfluxclient.ResponseProcessor;
import org.springframework.http.HttpHeaders;
import org.springframework.util.Assert;
import org.springframework.web.reactive.function.client.ClientRequest;
import org.springframework.web.reactive.function.client.ClientResponse;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.ExchangeFunction;
import reactor.core.publisher.Mono;
import java.util.concurrent.TimeUnit;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunction.ofRequestProcessor;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunction.ofResponseProcessor;
package com.webfluxclient.client;
class ExchangeFilterFunctions {
static ExchangeFilterFunction requestProcessorFilter(RequestProcessor requestProcessor) {
return ofRequestProcessor(clientRequest -> Mono.just(requestProcessor.process(clientRequest)));
}
static ExchangeFilterFunction responseInterceptorFilter(ResponseProcessor responseProcessor) {
return ofResponseProcessor(clientResponse -> Mono.just(responseProcessor.process(clientResponse)));
}
| static ExchangeFilterFunction loggingFilter(Logger logger, LogLevel logLevel) { |
jbrixhe/spring-webflux-client | src/main/java/com/webfluxclient/client/ExchangeFilterFunctions.java | // Path: src/main/java/com/webfluxclient/LogLevel.java
// public enum LogLevel {
// /** No logs. */
// NONE,
//
// /**
// * Logs request and response lines.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: application/json
// *
// * <-- 200 OK POST /hello (22ms)
// * }</pre>
// */
// BASIC,
//
// /**
// * Logs request and response lines and their respective headers.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: plain/text
// * Headers:
// * - Accept-Language: en
// * - Accept-Charset: UTF-8
// * --> END POST
// *
// * <-- 200 OK POST /hello (22ms)
// * Headers:
// * - Content-Type: plain/text
// * <-- END HTTP
// * }</pre>
// */
// HEADERS
// }
//
// Path: src/main/java/com/webfluxclient/Logger.java
// public interface Logger {
// void log(Supplier<String> messageSupplier);
// void log(String message);
// }
//
// Path: src/main/java/com/webfluxclient/RequestProcessor.java
// @FunctionalInterface
// public interface RequestProcessor {
//
// ClientRequest process(ClientRequest request);
//
// default RequestProcessor andThen(RequestProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
//
// Path: src/main/java/com/webfluxclient/ResponseProcessor.java
// @FunctionalInterface
// public interface ResponseProcessor {
//
// ClientResponse process(ClientResponse clientResponse);
//
// default ResponseProcessor andThen(ResponseProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
| import com.webfluxclient.LogLevel;
import com.webfluxclient.Logger;
import com.webfluxclient.RequestProcessor;
import com.webfluxclient.ResponseProcessor;
import org.springframework.http.HttpHeaders;
import org.springframework.util.Assert;
import org.springframework.web.reactive.function.client.ClientRequest;
import org.springframework.web.reactive.function.client.ClientResponse;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.ExchangeFunction;
import reactor.core.publisher.Mono;
import java.util.concurrent.TimeUnit;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunction.ofRequestProcessor;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunction.ofResponseProcessor; | package com.webfluxclient.client;
class ExchangeFilterFunctions {
static ExchangeFilterFunction requestProcessorFilter(RequestProcessor requestProcessor) {
return ofRequestProcessor(clientRequest -> Mono.just(requestProcessor.process(clientRequest)));
}
static ExchangeFilterFunction responseInterceptorFilter(ResponseProcessor responseProcessor) {
return ofResponseProcessor(clientResponse -> Mono.just(responseProcessor.process(clientResponse)));
}
| // Path: src/main/java/com/webfluxclient/LogLevel.java
// public enum LogLevel {
// /** No logs. */
// NONE,
//
// /**
// * Logs request and response lines.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: application/json
// *
// * <-- 200 OK POST /hello (22ms)
// * }</pre>
// */
// BASIC,
//
// /**
// * Logs request and response lines and their respective headers.
// *
// * <p>Example:
// * <pre>{@code
// * --> POST /hello
// * Content-Type: plain/text
// * Headers:
// * - Accept-Language: en
// * - Accept-Charset: UTF-8
// * --> END POST
// *
// * <-- 200 OK POST /hello (22ms)
// * Headers:
// * - Content-Type: plain/text
// * <-- END HTTP
// * }</pre>
// */
// HEADERS
// }
//
// Path: src/main/java/com/webfluxclient/Logger.java
// public interface Logger {
// void log(Supplier<String> messageSupplier);
// void log(String message);
// }
//
// Path: src/main/java/com/webfluxclient/RequestProcessor.java
// @FunctionalInterface
// public interface RequestProcessor {
//
// ClientRequest process(ClientRequest request);
//
// default RequestProcessor andThen(RequestProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
//
// Path: src/main/java/com/webfluxclient/ResponseProcessor.java
// @FunctionalInterface
// public interface ResponseProcessor {
//
// ClientResponse process(ClientResponse clientResponse);
//
// default ResponseProcessor andThen(ResponseProcessor after) {
// Assert.notNull(after, "");
// return request -> after.process(process(request));
// }
// }
// Path: src/main/java/com/webfluxclient/client/ExchangeFilterFunctions.java
import com.webfluxclient.LogLevel;
import com.webfluxclient.Logger;
import com.webfluxclient.RequestProcessor;
import com.webfluxclient.ResponseProcessor;
import org.springframework.http.HttpHeaders;
import org.springframework.util.Assert;
import org.springframework.web.reactive.function.client.ClientRequest;
import org.springframework.web.reactive.function.client.ClientResponse;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.ExchangeFunction;
import reactor.core.publisher.Mono;
import java.util.concurrent.TimeUnit;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunction.ofRequestProcessor;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunction.ofResponseProcessor;
package com.webfluxclient.client;
class ExchangeFilterFunctions {
static ExchangeFilterFunction requestProcessorFilter(RequestProcessor requestProcessor) {
return ofRequestProcessor(clientRequest -> Mono.just(requestProcessor.process(clientRequest)));
}
static ExchangeFilterFunction responseInterceptorFilter(ResponseProcessor responseProcessor) {
return ofResponseProcessor(clientResponse -> Mono.just(responseProcessor.process(clientResponse)));
}
| static ExchangeFilterFunction loggingFilter(Logger logger, LogLevel logLevel) { |
oakes/libgdx-examples | Breakout/html/src/net/sekao/breakout/client/HtmlLauncher.java | // Path: Breakout/core/src/net/sekao/breakout/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen());
// }
// }
| import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import net.sekao.breakout.MyGdxGame;
| package net.sekao.breakout.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(800, 600);
}
@Override
public ApplicationListener createApplicationListener () {
| // Path: Breakout/core/src/net/sekao/breakout/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen());
// }
// }
// Path: Breakout/html/src/net/sekao/breakout/client/HtmlLauncher.java
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import net.sekao.breakout.MyGdxGame;
package net.sekao.breakout.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(800, 600);
}
@Override
public ApplicationListener createApplicationListener () {
| return new MyGdxGame();
|
oakes/libgdx-examples | Breakout/core/src/net/sekao/breakout/MyGdxGame.java | // Path: Breakout/core/src/net/sekao/breakout/MainScreen.java
// public class MainScreen implements Screen {
// Stage stage;
// World world;
// Image ball, paddle;
// Body ballBody, wallBody, floorBody, paddleBody;
// HashMap blocks;
// final int scale = 32;
//
// public void show() {
// stage = new Stage();
// blocks = new HashMap();
//
// Texture ballTexture = new Texture("ball.png");
// Texture blockTexture = new Texture("block.png");
//
// ball = new Image(ballTexture);
// stage.addActor(ball);
// paddle = new Image(blockTexture);
// stage.addActor(paddle);
//
// final float screenWidth = Gdx.graphics.getWidth();
// final float screenHeight = Gdx.graphics.getHeight();
// final float blockWidth = blockTexture.getWidth();
// final float blockHeight = blockTexture.getHeight();
//
// world = new World(new Vector2(0, 0), true);
//
// float col = screenWidth / blockWidth;
// while (col > 0) {
// col--;
//
// float row = screenHeight / blockHeight / 2;
// while (row > 0) {
// row--;
//
// float x = col * blockWidth;
// float y = row * blockHeight + screenHeight / 2;
//
// Image block = new Image(blockTexture);
// block.setPosition(x, y);
// stage.addActor(block);
// Body blockBody = createRectBody(x, y, blockWidth, blockHeight);
// blocks.put(blockBody, block);
// }
// }
//
// ballBody = createBallBody(100, 100, ballTexture.getWidth()/2);
// ballBody.setLinearVelocity(10, 10);
//
// wallBody = createRectBody(0, 0, screenWidth, screenHeight);
// floorBody = createRectBody(0, 0, screenWidth, 1);
// paddleBody = createRectBody(0, 0, blockWidth, blockHeight);
//
// Gdx.input.setInputProcessor(stage);
// stage.addListener(new InputListener() {
// public boolean handle(Event e) {
// float x = Gdx.input.getX() - blockWidth / 2;
// moveBody(paddleBody, x, 0);
// return true;
// }
// });
//
// world.setContactListener(new ContactListener() {
// public void beginContact(Contact c) {
// Body b = c.getFixtureA().getBody();
// Image i = (Image) blocks.get(b);
// if (i != null) {
// i.remove();
// } else if (b == floorBody) {
// show();
// }
// }
// public void endContact(Contact c) {}
// public void postSolve(Contact c, ContactImpulse ci) {}
// public void preSolve(Contact c, Manifold m) {}
// });
// }
//
// public void render(float delta) {
// Gdx.gl.glClearColor(0, 0, 0, 0);
// Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
//
// world.step(delta, 10, 10);
// paddle.setPosition(paddleBody.getPosition().x*scale, paddleBody.getPosition().y*scale);
// ball.setPosition(ballBody.getPosition().x*scale, ballBody.getPosition().y*scale);
//
// Iterator iter = blocks.keySet().iterator();
// while (iter.hasNext()) {
// Body b = (Body) iter.next();
// Image i = (Image) blocks.get(b);
// if (i.hasParent() == false) {
// world.destroyBody(b);
// iter.remove();
// }
// }
//
// stage.act(delta);
// stage.draw();
// }
//
// public void dispose() {
// }
//
// public void hide() {
// }
//
// public void pause() {
// }
//
// public void resize(int width, int height) {
// }
//
// public void resume() {
// }
//
// public Body createBallBody(float x, float y, float radius) {
// x = x/scale;
// y = y/scale;
// radius = radius/scale;
//
// BodyDef def = new BodyDef();
// def.type = BodyDef.BodyType.DynamicBody;
// def.position.set(x, y);
// Body body = world.createBody(def);
//
// CircleShape shape = new CircleShape();
// shape.setRadius(radius);
// shape.setPosition(new Vector2(radius, radius));
// Fixture fixture = body.createFixture(shape, 1);
// fixture.setFriction(0);
// fixture.setRestitution(1);
// shape.dispose();
//
// return body;
// }
//
// public Body createRectBody(float x, float y, float width, float height) {
// x = x/scale;
// y = y/scale;
// width = width/scale;
// height = height/scale;
//
// BodyDef def = new BodyDef();
// def.type = BodyDef.BodyType.StaticBody;
// def.position.set(x, y);
// Body body = world.createBody(def);
//
// ChainShape shape = new ChainShape();
// float[] vertices = {
// 0, 0,
// 0, height,
// width, height,
// width, 0,
// 0, 0
// };
// shape.createChain(vertices);
// body.createFixture(shape, 1);
// shape.dispose();
//
// return body;
// }
//
// public void moveBody(Body body, float x, float y) {
// x = x/scale;
// y = y/scale;
//
// body.setTransform(x, y, 0);
// }
// }
| import com.badlogic.gdx.Game;
import net.sekao.breakout.MainScreen; | package net.sekao.breakout;
public class MyGdxGame extends Game {
public void create() { | // Path: Breakout/core/src/net/sekao/breakout/MainScreen.java
// public class MainScreen implements Screen {
// Stage stage;
// World world;
// Image ball, paddle;
// Body ballBody, wallBody, floorBody, paddleBody;
// HashMap blocks;
// final int scale = 32;
//
// public void show() {
// stage = new Stage();
// blocks = new HashMap();
//
// Texture ballTexture = new Texture("ball.png");
// Texture blockTexture = new Texture("block.png");
//
// ball = new Image(ballTexture);
// stage.addActor(ball);
// paddle = new Image(blockTexture);
// stage.addActor(paddle);
//
// final float screenWidth = Gdx.graphics.getWidth();
// final float screenHeight = Gdx.graphics.getHeight();
// final float blockWidth = blockTexture.getWidth();
// final float blockHeight = blockTexture.getHeight();
//
// world = new World(new Vector2(0, 0), true);
//
// float col = screenWidth / blockWidth;
// while (col > 0) {
// col--;
//
// float row = screenHeight / blockHeight / 2;
// while (row > 0) {
// row--;
//
// float x = col * blockWidth;
// float y = row * blockHeight + screenHeight / 2;
//
// Image block = new Image(blockTexture);
// block.setPosition(x, y);
// stage.addActor(block);
// Body blockBody = createRectBody(x, y, blockWidth, blockHeight);
// blocks.put(blockBody, block);
// }
// }
//
// ballBody = createBallBody(100, 100, ballTexture.getWidth()/2);
// ballBody.setLinearVelocity(10, 10);
//
// wallBody = createRectBody(0, 0, screenWidth, screenHeight);
// floorBody = createRectBody(0, 0, screenWidth, 1);
// paddleBody = createRectBody(0, 0, blockWidth, blockHeight);
//
// Gdx.input.setInputProcessor(stage);
// stage.addListener(new InputListener() {
// public boolean handle(Event e) {
// float x = Gdx.input.getX() - blockWidth / 2;
// moveBody(paddleBody, x, 0);
// return true;
// }
// });
//
// world.setContactListener(new ContactListener() {
// public void beginContact(Contact c) {
// Body b = c.getFixtureA().getBody();
// Image i = (Image) blocks.get(b);
// if (i != null) {
// i.remove();
// } else if (b == floorBody) {
// show();
// }
// }
// public void endContact(Contact c) {}
// public void postSolve(Contact c, ContactImpulse ci) {}
// public void preSolve(Contact c, Manifold m) {}
// });
// }
//
// public void render(float delta) {
// Gdx.gl.glClearColor(0, 0, 0, 0);
// Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
//
// world.step(delta, 10, 10);
// paddle.setPosition(paddleBody.getPosition().x*scale, paddleBody.getPosition().y*scale);
// ball.setPosition(ballBody.getPosition().x*scale, ballBody.getPosition().y*scale);
//
// Iterator iter = blocks.keySet().iterator();
// while (iter.hasNext()) {
// Body b = (Body) iter.next();
// Image i = (Image) blocks.get(b);
// if (i.hasParent() == false) {
// world.destroyBody(b);
// iter.remove();
// }
// }
//
// stage.act(delta);
// stage.draw();
// }
//
// public void dispose() {
// }
//
// public void hide() {
// }
//
// public void pause() {
// }
//
// public void resize(int width, int height) {
// }
//
// public void resume() {
// }
//
// public Body createBallBody(float x, float y, float radius) {
// x = x/scale;
// y = y/scale;
// radius = radius/scale;
//
// BodyDef def = new BodyDef();
// def.type = BodyDef.BodyType.DynamicBody;
// def.position.set(x, y);
// Body body = world.createBody(def);
//
// CircleShape shape = new CircleShape();
// shape.setRadius(radius);
// shape.setPosition(new Vector2(radius, radius));
// Fixture fixture = body.createFixture(shape, 1);
// fixture.setFriction(0);
// fixture.setRestitution(1);
// shape.dispose();
//
// return body;
// }
//
// public Body createRectBody(float x, float y, float width, float height) {
// x = x/scale;
// y = y/scale;
// width = width/scale;
// height = height/scale;
//
// BodyDef def = new BodyDef();
// def.type = BodyDef.BodyType.StaticBody;
// def.position.set(x, y);
// Body body = world.createBody(def);
//
// ChainShape shape = new ChainShape();
// float[] vertices = {
// 0, 0,
// 0, height,
// width, height,
// width, 0,
// 0, 0
// };
// shape.createChain(vertices);
// body.createFixture(shape, 1);
// shape.dispose();
//
// return body;
// }
//
// public void moveBody(Body body, float x, float y) {
// x = x/scale;
// y = y/scale;
//
// body.setTransform(x, y, 0);
// }
// }
// Path: Breakout/core/src/net/sekao/breakout/MyGdxGame.java
import com.badlogic.gdx.Game;
import net.sekao.breakout.MainScreen;
package net.sekao.breakout;
public class MyGdxGame extends Game {
public void create() { | this.setScreen(new MainScreen()); |
oakes/libgdx-examples | Tetris/desktop/src/net/sekao/tetris/desktop/DesktopLauncher.java | // Path: Tetris/core/src/net/sekao/tetris/MyGdxGame.java
// public class MyGdxGame extends Game {
// @Override
// public void create () {
// this.setScreen(new MainScreen());
// }
// }
| import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import net.sekao.tetris.MyGdxGame; | package net.sekao.tetris.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | // Path: Tetris/core/src/net/sekao/tetris/MyGdxGame.java
// public class MyGdxGame extends Game {
// @Override
// public void create () {
// this.setScreen(new MainScreen());
// }
// }
// Path: Tetris/desktop/src/net/sekao/tetris/desktop/DesktopLauncher.java
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import net.sekao.tetris.MyGdxGame;
package net.sekao.tetris.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | new LwjglApplication(new MyGdxGame(), config); |
oakes/libgdx-examples | Minicraft/desktop/src/net/sekao/minicraft/desktop/DesktopLauncher.java | // Path: Minicraft/core/src/net/sekao/minicraft/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen());
// }
// }
| import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import net.sekao.minicraft.MyGdxGame; | package net.sekao.minicraft.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | // Path: Minicraft/core/src/net/sekao/minicraft/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen());
// }
// }
// Path: Minicraft/desktop/src/net/sekao/minicraft/desktop/DesktopLauncher.java
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import net.sekao.minicraft.MyGdxGame;
package net.sekao.minicraft.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | new LwjglApplication(new MyGdxGame(), config); |
oakes/libgdx-examples | SuperKoalio/core/src/net/sekao/superkoalio/MyGdxGame.java | // Path: SuperKoalio/core/src/net/sekao/superkoalio/MainScreen.java
// public class MainScreen implements Screen {
// Stage stage;
// TiledMap map;
// OrthogonalTiledMapRenderer renderer;
// OrthographicCamera camera;
// Koala koala;
//
// public void show() {
// map = new TmxMapLoader().load("level1.tmx");
// final float pixelsPerTile = 16;
// renderer = new OrthogonalTiledMapRenderer(map, 1 / pixelsPerTile);
// camera = new OrthographicCamera();
//
// stage = new Stage();
// stage.getViewport().setCamera(camera);
//
// koala = new Koala();
// koala.layer = (TiledMapTileLayer) map.getLayers().get("walls");
// koala.setPosition(20, 10);
// stage.addActor(koala);
// }
//
// public void render(float delta) {
// Gdx.gl.glClearColor(0.5f, 0.5f, 1, 1);
// Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
//
// camera.position.x = koala.getX();
// camera.update();
//
// renderer.setView(camera);
// renderer.render();
//
// stage.act(delta);
// stage.draw();
// }
//
// public void dispose() {
// }
//
// public void hide() {
// }
//
// public void pause() {
// }
//
// public void resize(int width, int height) {
// camera.setToOrtho(false, 20 * width / height, 20);
// }
//
// public void resume() {
// }
// }
| import com.badlogic.gdx.Game;
import net.sekao.superkoalio.MainScreen; | package net.sekao.superkoalio;
public class MyGdxGame extends Game {
public void create() { | // Path: SuperKoalio/core/src/net/sekao/superkoalio/MainScreen.java
// public class MainScreen implements Screen {
// Stage stage;
// TiledMap map;
// OrthogonalTiledMapRenderer renderer;
// OrthographicCamera camera;
// Koala koala;
//
// public void show() {
// map = new TmxMapLoader().load("level1.tmx");
// final float pixelsPerTile = 16;
// renderer = new OrthogonalTiledMapRenderer(map, 1 / pixelsPerTile);
// camera = new OrthographicCamera();
//
// stage = new Stage();
// stage.getViewport().setCamera(camera);
//
// koala = new Koala();
// koala.layer = (TiledMapTileLayer) map.getLayers().get("walls");
// koala.setPosition(20, 10);
// stage.addActor(koala);
// }
//
// public void render(float delta) {
// Gdx.gl.glClearColor(0.5f, 0.5f, 1, 1);
// Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
//
// camera.position.x = koala.getX();
// camera.update();
//
// renderer.setView(camera);
// renderer.render();
//
// stage.act(delta);
// stage.draw();
// }
//
// public void dispose() {
// }
//
// public void hide() {
// }
//
// public void pause() {
// }
//
// public void resize(int width, int height) {
// camera.setToOrtho(false, 20 * width / height, 20);
// }
//
// public void resume() {
// }
// }
// Path: SuperKoalio/core/src/net/sekao/superkoalio/MyGdxGame.java
import com.badlogic.gdx.Game;
import net.sekao.superkoalio.MainScreen;
package net.sekao.superkoalio;
public class MyGdxGame extends Game {
public void create() { | this.setScreen(new MainScreen()); |
oakes/libgdx-examples | Breakout/desktop/src/net/sekao/breakout/desktop/DesktopLauncher.java | // Path: Breakout/core/src/net/sekao/breakout/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen());
// }
// }
| import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import net.sekao.breakout.MyGdxGame; | package net.sekao.breakout.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | // Path: Breakout/core/src/net/sekao/breakout/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen());
// }
// }
// Path: Breakout/desktop/src/net/sekao/breakout/desktop/DesktopLauncher.java
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import net.sekao.breakout.MyGdxGame;
package net.sekao.breakout.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | new LwjglApplication(new MyGdxGame(), config); |
oakes/libgdx-examples | SuperKoalio/html/src/net/sekao/superkoalio/client/HtmlLauncher.java | // Path: SuperKoalio/core/src/net/sekao/superkoalio/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen());
// }
// }
| import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import net.sekao.superkoalio.MyGdxGame;
| package net.sekao.superkoalio.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(800, 600);
}
@Override
public ApplicationListener createApplicationListener () {
| // Path: SuperKoalio/core/src/net/sekao/superkoalio/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen());
// }
// }
// Path: SuperKoalio/html/src/net/sekao/superkoalio/client/HtmlLauncher.java
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import net.sekao.superkoalio.MyGdxGame;
package net.sekao.superkoalio.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(800, 600);
}
@Override
public ApplicationListener createApplicationListener () {
| return new MyGdxGame();
|
oakes/libgdx-examples | SuperKoalio/desktop/src/net/sekao/superkoalio/desktop/DesktopLauncher.java | // Path: SuperKoalio/core/src/net/sekao/superkoalio/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen());
// }
// }
| import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import net.sekao.superkoalio.MyGdxGame; | package net.sekao.superkoalio.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | // Path: SuperKoalio/core/src/net/sekao/superkoalio/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen());
// }
// }
// Path: SuperKoalio/desktop/src/net/sekao/superkoalio/desktop/DesktopLauncher.java
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import net.sekao.superkoalio.MyGdxGame;
package net.sekao.superkoalio.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | new LwjglApplication(new MyGdxGame(), config); |
oakes/libgdx-examples | DungeonCrawler/desktop/src/net/sekao/dungeoncrawler/desktop/DesktopLauncher.java | // Path: DungeonCrawler/core/src/net/sekao/dungeoncrawler/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen(this));
// }
// }
| import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import net.sekao.dungeoncrawler.MyGdxGame; | package net.sekao.dungeoncrawler.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | // Path: DungeonCrawler/core/src/net/sekao/dungeoncrawler/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen(this));
// }
// }
// Path: DungeonCrawler/desktop/src/net/sekao/dungeoncrawler/desktop/DesktopLauncher.java
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import net.sekao.dungeoncrawler.MyGdxGame;
package net.sekao.dungeoncrawler.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | new LwjglApplication(new MyGdxGame(), config); |
oakes/libgdx-examples | DungeonCrawler/html/src/net/sekao/dungeoncrawler/client/HtmlLauncher.java | // Path: DungeonCrawler/core/src/net/sekao/dungeoncrawler/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen(this));
// }
// }
| import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import net.sekao.dungeoncrawler.MyGdxGame;
| package net.sekao.dungeoncrawler.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(800, 600);
}
@Override
public ApplicationListener createApplicationListener () {
| // Path: DungeonCrawler/core/src/net/sekao/dungeoncrawler/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen(this));
// }
// }
// Path: DungeonCrawler/html/src/net/sekao/dungeoncrawler/client/HtmlLauncher.java
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import net.sekao.dungeoncrawler.MyGdxGame;
package net.sekao.dungeoncrawler.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(800, 600);
}
@Override
public ApplicationListener createApplicationListener () {
| return new MyGdxGame();
|
oakes/libgdx-examples | Minicraft/html/src/net/sekao/minicraft/client/HtmlLauncher.java | // Path: Minicraft/core/src/net/sekao/minicraft/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen());
// }
// }
| import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import net.sekao.minicraft.MyGdxGame;
| package net.sekao.minicraft.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(800, 600);
}
@Override
public ApplicationListener createApplicationListener () {
| // Path: Minicraft/core/src/net/sekao/minicraft/MyGdxGame.java
// public class MyGdxGame extends Game {
// public void create() {
// this.setScreen(new MainScreen());
// }
// }
// Path: Minicraft/html/src/net/sekao/minicraft/client/HtmlLauncher.java
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import net.sekao.minicraft.MyGdxGame;
package net.sekao.minicraft.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(800, 600);
}
@Override
public ApplicationListener createApplicationListener () {
| return new MyGdxGame();
|
oakes/libgdx-examples | Tetris/html/src/net/sekao/tetris/client/HtmlLauncher.java | // Path: Tetris/core/src/net/sekao/tetris/MyGdxGame.java
// public class MyGdxGame extends Game {
// @Override
// public void create () {
// this.setScreen(new MainScreen());
// }
// }
| import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import net.sekao.tetris.MyGdxGame;
| package net.sekao.tetris.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(800, 600);
}
@Override
public ApplicationListener createApplicationListener () {
| // Path: Tetris/core/src/net/sekao/tetris/MyGdxGame.java
// public class MyGdxGame extends Game {
// @Override
// public void create () {
// this.setScreen(new MainScreen());
// }
// }
// Path: Tetris/html/src/net/sekao/tetris/client/HtmlLauncher.java
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import net.sekao.tetris.MyGdxGame;
package net.sekao.tetris.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(800, 600);
}
@Override
public ApplicationListener createApplicationListener () {
| return new MyGdxGame();
|
sachin-handiekar/jInstagram | src/main/java/org/jinstagram/http/StreamUtils.java | // Path: src/main/java/org/jinstagram/utils/Preconditions.java
// public class Preconditions {
// private static final String DEFAULT_MESSAGE = "Received an invalid parameter";
//
// private static final Pattern URL_PATTERN = Pattern.compile("^[a-zA-Z][a-zA-Z0-9+.-]*://\\S+");
// private static final Pattern LAT_LONG_PATTERN = Pattern.compile("(-)?[0-9]+(\\.)?[0-9]*");
// private static final Pattern NUMERIC_PATTERN = Pattern.compile("[0-9]+");
//
// /**
// * Checks that an object is not null.
// *
// * @param object any object
// * @param errorMsg error message
// * @throws IllegalArgumentException if the object is null
// */
// public static void checkNotNull(Object object, String errorMsg) {
// check(object != null, errorMsg);
// }
//
// /**
// * Checks that at least one of object1 or object2 is not null
// *
// * @param object1 any object
// * @param object2 any object
// * @param errorMsg error message
// * @throws IllegalArgumentException if both object1 and object2 are null
// */
// public static void checkBothNotNull(Object object1, Object object2, String errorMsg) {
// check(!(object1 == null && object2 == null), errorMsg);
// }
//
// /**
// * Checks that a string is not null or empty
// * @param string any string
// * @param errorMsg error message
// * @throws IllegalArgumentException if the string is null or empty
// */
// public static void checkEmptyString(String string, String errorMsg) {
// check(StringUtils.isNotBlank(string), errorMsg);
// }
//
// /**
// * Checks that a URL is valid
// *
// * @param url any string
// * @param errorMsg error message
// */
// public static void checkValidUrl(String url, String errorMsg) {
// checkEmptyString(url, errorMsg);
// check(isUrl(url), errorMsg);
// }
//
// /**
// * Checks that a URL is a valid OAuth callback
// *
// * @param url any string
// * @param errorMsg error message
// */
// public static void checkValidOAuthCallback(String url, String errorMsg) {
// checkEmptyString(url, errorMsg);
//
// if (url.toLowerCase().compareToIgnoreCase(OAuthConstants.OUT_OF_BAND) != 0) {
// check(isUrl(url), errorMsg);
// }
// }
//
// /**
// * Checks that a string is a valid longitude or latitude value ('lat' and 'lng')
// * as shown in <a href="http://instagram.com/developer/realtime/">Instagram Developer real time section</a>
// *
// * @param latOrLong any string
// * @param errorMsg error message
// */
// public static void checkValidLatLong(String latOrLong, String errorMsg) {
// checkEmptyString(latOrLong, errorMsg);
// check(isLatLong(latOrLong), errorMsg);
// }
//
// /**
// * Check that a string is a valid radius value ('radius')
// * as shown in <a href="http://instagram.com/developer/realtime/">Instagram Developer real time section</a>
// *
// * @param radiusString any string that is supposed to be a radius
// * @param errorMsg error message
// */
// public static void checkValidRadius(String radiusString, String errorMsg) {
// checkEmptyString(radiusString, errorMsg);
// check(isNumeric(radiusString), errorMsg);
// }
//
// private static boolean isUrl(String url) {
// return URL_PATTERN.matcher(url).matches();
// }
//
// private static boolean isLatLong(String latOrLong) {
// return LAT_LONG_PATTERN.matcher(latOrLong).matches();
// }
//
// private static boolean isNumeric(String numericString) {
// return NUMERIC_PATTERN.matcher(numericString).matches();
// }
//
// private static void check(boolean requirements, String error) {
// String message = StringUtils.isBlank(error) ? DEFAULT_MESSAGE : error;
//
// if (!requirements) {
// throw new IllegalArgumentException(message);
// }
// }
// }
| import org.jinstagram.utils.Preconditions;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader; | package org.jinstagram.http;
/**
* An utility class to deal with the HttpStream
*/
public final class StreamUtils {
private StreamUtils() {}
/**
* Returns the stream contents as an UTF-8 encoded string
*
* @param is input stream
* @return string contents
*/
public static String getStreamContents(InputStream is) { | // Path: src/main/java/org/jinstagram/utils/Preconditions.java
// public class Preconditions {
// private static final String DEFAULT_MESSAGE = "Received an invalid parameter";
//
// private static final Pattern URL_PATTERN = Pattern.compile("^[a-zA-Z][a-zA-Z0-9+.-]*://\\S+");
// private static final Pattern LAT_LONG_PATTERN = Pattern.compile("(-)?[0-9]+(\\.)?[0-9]*");
// private static final Pattern NUMERIC_PATTERN = Pattern.compile("[0-9]+");
//
// /**
// * Checks that an object is not null.
// *
// * @param object any object
// * @param errorMsg error message
// * @throws IllegalArgumentException if the object is null
// */
// public static void checkNotNull(Object object, String errorMsg) {
// check(object != null, errorMsg);
// }
//
// /**
// * Checks that at least one of object1 or object2 is not null
// *
// * @param object1 any object
// * @param object2 any object
// * @param errorMsg error message
// * @throws IllegalArgumentException if both object1 and object2 are null
// */
// public static void checkBothNotNull(Object object1, Object object2, String errorMsg) {
// check(!(object1 == null && object2 == null), errorMsg);
// }
//
// /**
// * Checks that a string is not null or empty
// * @param string any string
// * @param errorMsg error message
// * @throws IllegalArgumentException if the string is null or empty
// */
// public static void checkEmptyString(String string, String errorMsg) {
// check(StringUtils.isNotBlank(string), errorMsg);
// }
//
// /**
// * Checks that a URL is valid
// *
// * @param url any string
// * @param errorMsg error message
// */
// public static void checkValidUrl(String url, String errorMsg) {
// checkEmptyString(url, errorMsg);
// check(isUrl(url), errorMsg);
// }
//
// /**
// * Checks that a URL is a valid OAuth callback
// *
// * @param url any string
// * @param errorMsg error message
// */
// public static void checkValidOAuthCallback(String url, String errorMsg) {
// checkEmptyString(url, errorMsg);
//
// if (url.toLowerCase().compareToIgnoreCase(OAuthConstants.OUT_OF_BAND) != 0) {
// check(isUrl(url), errorMsg);
// }
// }
//
// /**
// * Checks that a string is a valid longitude or latitude value ('lat' and 'lng')
// * as shown in <a href="http://instagram.com/developer/realtime/">Instagram Developer real time section</a>
// *
// * @param latOrLong any string
// * @param errorMsg error message
// */
// public static void checkValidLatLong(String latOrLong, String errorMsg) {
// checkEmptyString(latOrLong, errorMsg);
// check(isLatLong(latOrLong), errorMsg);
// }
//
// /**
// * Check that a string is a valid radius value ('radius')
// * as shown in <a href="http://instagram.com/developer/realtime/">Instagram Developer real time section</a>
// *
// * @param radiusString any string that is supposed to be a radius
// * @param errorMsg error message
// */
// public static void checkValidRadius(String radiusString, String errorMsg) {
// checkEmptyString(radiusString, errorMsg);
// check(isNumeric(radiusString), errorMsg);
// }
//
// private static boolean isUrl(String url) {
// return URL_PATTERN.matcher(url).matches();
// }
//
// private static boolean isLatLong(String latOrLong) {
// return LAT_LONG_PATTERN.matcher(latOrLong).matches();
// }
//
// private static boolean isNumeric(String numericString) {
// return NUMERIC_PATTERN.matcher(numericString).matches();
// }
//
// private static void check(boolean requirements, String error) {
// String message = StringUtils.isBlank(error) ? DEFAULT_MESSAGE : error;
//
// if (!requirements) {
// throw new IllegalArgumentException(message);
// }
// }
// }
// Path: src/main/java/org/jinstagram/http/StreamUtils.java
import org.jinstagram.utils.Preconditions;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
package org.jinstagram.http;
/**
* An utility class to deal with the HttpStream
*/
public final class StreamUtils {
private StreamUtils() {}
/**
* Returns the stream contents as an UTF-8 encoded string
*
* @param is input stream
* @return string contents
*/
public static String getStreamContents(InputStream is) { | Preconditions.checkNotNull(is, "Cannot get String from a null object"); |
sachin-handiekar/jInstagram | src/test/java/org/jinstagram/entity/users/feed/MediaFeedDataTest.java | // Path: src/main/java/org/jinstagram/entity/common/Likes.java
// public class Likes {
// @SerializedName("count")
// private int count;
//
// @SerializedName("data")
// private List<User> likesUserList;
//
// /**
// * @return the count
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @param count the count to set
// */
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<User> getLikesUserList() {
// return likesUserList;
// }
//
// public void setLikesUserList(List<User> likesUserList) {
// this.likesUserList = likesUserList;
// }
//
// @Override
// public String toString() {
// return String.format("Likes [count=%s, likesUserList=%s]", count, likesUserList);
// }
// }
//
// Path: src/main/java/org/jinstagram/entity/common/Location.java
// public class Location {
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("latitude")
// private double latitude;
//
// @SerializedName("longitude")
// private double longitude;
//
// /**
// * @return the latitude
// */
// public double getLatitude() {
// return latitude;
// }
//
// /**
// * @param latitude
// * the latitude to set
// */
// public void setLatitude(double latitude) {
// this.latitude = latitude;
// }
//
// /**
// * @return the longitude
// */
// public double getLongitude() {
// return longitude;
// }
//
// /**
// * @param longitude
// * the longitude to set
// */
// public void setLongitude(double longitude) {
// this.longitude = longitude;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return String.format("Location [id=%s, name=%s, latitude=%s, longitude=%s]", id, name, latitude, longitude);
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import java.util.List;
import org.jinstagram.entity.common.Caption;
import org.jinstagram.entity.common.Comments;
import org.jinstagram.entity.common.Images;
import org.jinstagram.entity.common.Likes;
import org.jinstagram.entity.common.Location;
import org.jinstagram.entity.common.User;
import org.jinstagram.entity.common.UsersInPhoto;
import org.jinstagram.entity.common.Videos;
import org.junit.Test; | package org.jinstagram.entity.users.feed;
/**
* The class <code>MediaFeedDataTest</code> contains tests for the class
* <code>{@link MediaFeedData}</code>.
*/
public class MediaFeedDataTest {
/**
* Run the MediaFeedData() constructor test.
*
*
*/
@Test
public void testMediaFeedData_1() throws Exception {
MediaFeedData result = new MediaFeedData();
assertNotNull(result);
// add additional test code here
}
/**
* Run the Caption getCaption() method test.
*
* @throws Exception
*
*
*/
@Test
public void testGetCaption_1() throws Exception {
MediaFeedData fixture = new MediaFeedData();
fixture.setId("");
fixture.setCreatedTime("");
fixture.setVideos(new Videos());
fixture.setCaption(new Caption());
fixture.setUser(new User());
fixture.setImageFilter("");
fixture.setImages(new Images());
fixture.setType("");
fixture.setTags(new ArrayList<String>());
fixture.setLink("");
fixture.setUserHasLiked(true);
fixture.setUsersInPhotoList(new ArrayList<UsersInPhoto>());
fixture.setComments(new Comments()); | // Path: src/main/java/org/jinstagram/entity/common/Likes.java
// public class Likes {
// @SerializedName("count")
// private int count;
//
// @SerializedName("data")
// private List<User> likesUserList;
//
// /**
// * @return the count
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @param count the count to set
// */
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<User> getLikesUserList() {
// return likesUserList;
// }
//
// public void setLikesUserList(List<User> likesUserList) {
// this.likesUserList = likesUserList;
// }
//
// @Override
// public String toString() {
// return String.format("Likes [count=%s, likesUserList=%s]", count, likesUserList);
// }
// }
//
// Path: src/main/java/org/jinstagram/entity/common/Location.java
// public class Location {
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("latitude")
// private double latitude;
//
// @SerializedName("longitude")
// private double longitude;
//
// /**
// * @return the latitude
// */
// public double getLatitude() {
// return latitude;
// }
//
// /**
// * @param latitude
// * the latitude to set
// */
// public void setLatitude(double latitude) {
// this.latitude = latitude;
// }
//
// /**
// * @return the longitude
// */
// public double getLongitude() {
// return longitude;
// }
//
// /**
// * @param longitude
// * the longitude to set
// */
// public void setLongitude(double longitude) {
// this.longitude = longitude;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return String.format("Location [id=%s, name=%s, latitude=%s, longitude=%s]", id, name, latitude, longitude);
// }
// }
// Path: src/test/java/org/jinstagram/entity/users/feed/MediaFeedDataTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import java.util.List;
import org.jinstagram.entity.common.Caption;
import org.jinstagram.entity.common.Comments;
import org.jinstagram.entity.common.Images;
import org.jinstagram.entity.common.Likes;
import org.jinstagram.entity.common.Location;
import org.jinstagram.entity.common.User;
import org.jinstagram.entity.common.UsersInPhoto;
import org.jinstagram.entity.common.Videos;
import org.junit.Test;
package org.jinstagram.entity.users.feed;
/**
* The class <code>MediaFeedDataTest</code> contains tests for the class
* <code>{@link MediaFeedData}</code>.
*/
public class MediaFeedDataTest {
/**
* Run the MediaFeedData() constructor test.
*
*
*/
@Test
public void testMediaFeedData_1() throws Exception {
MediaFeedData result = new MediaFeedData();
assertNotNull(result);
// add additional test code here
}
/**
* Run the Caption getCaption() method test.
*
* @throws Exception
*
*
*/
@Test
public void testGetCaption_1() throws Exception {
MediaFeedData fixture = new MediaFeedData();
fixture.setId("");
fixture.setCreatedTime("");
fixture.setVideos(new Videos());
fixture.setCaption(new Caption());
fixture.setUser(new User());
fixture.setImageFilter("");
fixture.setImages(new Images());
fixture.setType("");
fixture.setTags(new ArrayList<String>());
fixture.setLink("");
fixture.setUserHasLiked(true);
fixture.setUsersInPhotoList(new ArrayList<UsersInPhoto>());
fixture.setComments(new Comments()); | fixture.setLocation(new Location()); |
sachin-handiekar/jInstagram | src/test/java/org/jinstagram/entity/users/feed/MediaFeedDataTest.java | // Path: src/main/java/org/jinstagram/entity/common/Likes.java
// public class Likes {
// @SerializedName("count")
// private int count;
//
// @SerializedName("data")
// private List<User> likesUserList;
//
// /**
// * @return the count
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @param count the count to set
// */
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<User> getLikesUserList() {
// return likesUserList;
// }
//
// public void setLikesUserList(List<User> likesUserList) {
// this.likesUserList = likesUserList;
// }
//
// @Override
// public String toString() {
// return String.format("Likes [count=%s, likesUserList=%s]", count, likesUserList);
// }
// }
//
// Path: src/main/java/org/jinstagram/entity/common/Location.java
// public class Location {
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("latitude")
// private double latitude;
//
// @SerializedName("longitude")
// private double longitude;
//
// /**
// * @return the latitude
// */
// public double getLatitude() {
// return latitude;
// }
//
// /**
// * @param latitude
// * the latitude to set
// */
// public void setLatitude(double latitude) {
// this.latitude = latitude;
// }
//
// /**
// * @return the longitude
// */
// public double getLongitude() {
// return longitude;
// }
//
// /**
// * @param longitude
// * the longitude to set
// */
// public void setLongitude(double longitude) {
// this.longitude = longitude;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return String.format("Location [id=%s, name=%s, latitude=%s, longitude=%s]", id, name, latitude, longitude);
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import java.util.List;
import org.jinstagram.entity.common.Caption;
import org.jinstagram.entity.common.Comments;
import org.jinstagram.entity.common.Images;
import org.jinstagram.entity.common.Likes;
import org.jinstagram.entity.common.Location;
import org.jinstagram.entity.common.User;
import org.jinstagram.entity.common.UsersInPhoto;
import org.jinstagram.entity.common.Videos;
import org.junit.Test; | package org.jinstagram.entity.users.feed;
/**
* The class <code>MediaFeedDataTest</code> contains tests for the class
* <code>{@link MediaFeedData}</code>.
*/
public class MediaFeedDataTest {
/**
* Run the MediaFeedData() constructor test.
*
*
*/
@Test
public void testMediaFeedData_1() throws Exception {
MediaFeedData result = new MediaFeedData();
assertNotNull(result);
// add additional test code here
}
/**
* Run the Caption getCaption() method test.
*
* @throws Exception
*
*
*/
@Test
public void testGetCaption_1() throws Exception {
MediaFeedData fixture = new MediaFeedData();
fixture.setId("");
fixture.setCreatedTime("");
fixture.setVideos(new Videos());
fixture.setCaption(new Caption());
fixture.setUser(new User());
fixture.setImageFilter("");
fixture.setImages(new Images());
fixture.setType("");
fixture.setTags(new ArrayList<String>());
fixture.setLink("");
fixture.setUserHasLiked(true);
fixture.setUsersInPhotoList(new ArrayList<UsersInPhoto>());
fixture.setComments(new Comments());
fixture.setLocation(new Location()); | // Path: src/main/java/org/jinstagram/entity/common/Likes.java
// public class Likes {
// @SerializedName("count")
// private int count;
//
// @SerializedName("data")
// private List<User> likesUserList;
//
// /**
// * @return the count
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @param count the count to set
// */
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<User> getLikesUserList() {
// return likesUserList;
// }
//
// public void setLikesUserList(List<User> likesUserList) {
// this.likesUserList = likesUserList;
// }
//
// @Override
// public String toString() {
// return String.format("Likes [count=%s, likesUserList=%s]", count, likesUserList);
// }
// }
//
// Path: src/main/java/org/jinstagram/entity/common/Location.java
// public class Location {
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("latitude")
// private double latitude;
//
// @SerializedName("longitude")
// private double longitude;
//
// /**
// * @return the latitude
// */
// public double getLatitude() {
// return latitude;
// }
//
// /**
// * @param latitude
// * the latitude to set
// */
// public void setLatitude(double latitude) {
// this.latitude = latitude;
// }
//
// /**
// * @return the longitude
// */
// public double getLongitude() {
// return longitude;
// }
//
// /**
// * @param longitude
// * the longitude to set
// */
// public void setLongitude(double longitude) {
// this.longitude = longitude;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return String.format("Location [id=%s, name=%s, latitude=%s, longitude=%s]", id, name, latitude, longitude);
// }
// }
// Path: src/test/java/org/jinstagram/entity/users/feed/MediaFeedDataTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import java.util.List;
import org.jinstagram.entity.common.Caption;
import org.jinstagram.entity.common.Comments;
import org.jinstagram.entity.common.Images;
import org.jinstagram.entity.common.Likes;
import org.jinstagram.entity.common.Location;
import org.jinstagram.entity.common.User;
import org.jinstagram.entity.common.UsersInPhoto;
import org.jinstagram.entity.common.Videos;
import org.junit.Test;
package org.jinstagram.entity.users.feed;
/**
* The class <code>MediaFeedDataTest</code> contains tests for the class
* <code>{@link MediaFeedData}</code>.
*/
public class MediaFeedDataTest {
/**
* Run the MediaFeedData() constructor test.
*
*
*/
@Test
public void testMediaFeedData_1() throws Exception {
MediaFeedData result = new MediaFeedData();
assertNotNull(result);
// add additional test code here
}
/**
* Run the Caption getCaption() method test.
*
* @throws Exception
*
*
*/
@Test
public void testGetCaption_1() throws Exception {
MediaFeedData fixture = new MediaFeedData();
fixture.setId("");
fixture.setCreatedTime("");
fixture.setVideos(new Videos());
fixture.setCaption(new Caption());
fixture.setUser(new User());
fixture.setImageFilter("");
fixture.setImages(new Images());
fixture.setType("");
fixture.setTags(new ArrayList<String>());
fixture.setLink("");
fixture.setUserHasLiked(true);
fixture.setUsersInPhotoList(new ArrayList<UsersInPhoto>());
fixture.setComments(new Comments());
fixture.setLocation(new Location()); | fixture.setLikes(new Likes()); |
sachin-handiekar/jInstagram | src/main/java/org/jinstagram/entity/locations/LocationSearchFeed.java | // Path: src/main/java/org/jinstagram/entity/common/Location.java
// public class Location {
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("latitude")
// private double latitude;
//
// @SerializedName("longitude")
// private double longitude;
//
// /**
// * @return the latitude
// */
// public double getLatitude() {
// return latitude;
// }
//
// /**
// * @param latitude
// * the latitude to set
// */
// public void setLatitude(double latitude) {
// this.latitude = latitude;
// }
//
// /**
// * @return the longitude
// */
// public double getLongitude() {
// return longitude;
// }
//
// /**
// * @param longitude
// * the longitude to set
// */
// public void setLongitude(double longitude) {
// this.longitude = longitude;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return String.format("Location [id=%s, name=%s, latitude=%s, longitude=%s]", id, name, latitude, longitude);
// }
// }
| import java.util.List;
import org.jinstagram.InstagramObject;
import org.jinstagram.entity.common.Location;
import com.google.gson.annotations.SerializedName; | package org.jinstagram.entity.locations;
public class LocationSearchFeed extends InstagramObject{
@SerializedName("data") | // Path: src/main/java/org/jinstagram/entity/common/Location.java
// public class Location {
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("latitude")
// private double latitude;
//
// @SerializedName("longitude")
// private double longitude;
//
// /**
// * @return the latitude
// */
// public double getLatitude() {
// return latitude;
// }
//
// /**
// * @param latitude
// * the latitude to set
// */
// public void setLatitude(double latitude) {
// this.latitude = latitude;
// }
//
// /**
// * @return the longitude
// */
// public double getLongitude() {
// return longitude;
// }
//
// /**
// * @param longitude
// * the longitude to set
// */
// public void setLongitude(double longitude) {
// this.longitude = longitude;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return String.format("Location [id=%s, name=%s, latitude=%s, longitude=%s]", id, name, latitude, longitude);
// }
// }
// Path: src/main/java/org/jinstagram/entity/locations/LocationSearchFeed.java
import java.util.List;
import org.jinstagram.InstagramObject;
import org.jinstagram.entity.common.Location;
import com.google.gson.annotations.SerializedName;
package org.jinstagram.entity.locations;
public class LocationSearchFeed extends InstagramObject{
@SerializedName("data") | private List<Location> locationList; |
sachin-handiekar/jInstagram | src/main/java/org/jinstagram/entity/users/feed/MediaFeedData.java | // Path: src/main/java/org/jinstagram/entity/common/Likes.java
// public class Likes {
// @SerializedName("count")
// private int count;
//
// @SerializedName("data")
// private List<User> likesUserList;
//
// /**
// * @return the count
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @param count the count to set
// */
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<User> getLikesUserList() {
// return likesUserList;
// }
//
// public void setLikesUserList(List<User> likesUserList) {
// this.likesUserList = likesUserList;
// }
//
// @Override
// public String toString() {
// return String.format("Likes [count=%s, likesUserList=%s]", count, likesUserList);
// }
// }
//
// Path: src/main/java/org/jinstagram/entity/common/Location.java
// public class Location {
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("latitude")
// private double latitude;
//
// @SerializedName("longitude")
// private double longitude;
//
// /**
// * @return the latitude
// */
// public double getLatitude() {
// return latitude;
// }
//
// /**
// * @param latitude
// * the latitude to set
// */
// public void setLatitude(double latitude) {
// this.latitude = latitude;
// }
//
// /**
// * @return the longitude
// */
// public double getLongitude() {
// return longitude;
// }
//
// /**
// * @param longitude
// * the longitude to set
// */
// public void setLongitude(double longitude) {
// this.longitude = longitude;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return String.format("Location [id=%s, name=%s, latitude=%s, longitude=%s]", id, name, latitude, longitude);
// }
// }
| import java.util.List;
import org.jinstagram.entity.common.Caption;
import org.jinstagram.entity.common.Comments;
import org.jinstagram.entity.common.Images;
import org.jinstagram.entity.common.Likes;
import org.jinstagram.entity.common.Location;
import org.jinstagram.entity.common.User;
import org.jinstagram.entity.common.UsersInPhoto;
import org.jinstagram.entity.common.Videos;
import com.google.gson.annotations.SerializedName; | package org.jinstagram.entity.users.feed;
public class MediaFeedData {
@SerializedName("caption")
private Caption caption;
@SerializedName("comments")
private Comments comments;
@SerializedName("created_time")
private String createdTime;
@SerializedName("id")
private String id;
@SerializedName("filter")
private String imageFilter;
@SerializedName("images")
private Images images;
@SerializedName("videos")
private Videos videos;
@SerializedName("likes") | // Path: src/main/java/org/jinstagram/entity/common/Likes.java
// public class Likes {
// @SerializedName("count")
// private int count;
//
// @SerializedName("data")
// private List<User> likesUserList;
//
// /**
// * @return the count
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @param count the count to set
// */
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<User> getLikesUserList() {
// return likesUserList;
// }
//
// public void setLikesUserList(List<User> likesUserList) {
// this.likesUserList = likesUserList;
// }
//
// @Override
// public String toString() {
// return String.format("Likes [count=%s, likesUserList=%s]", count, likesUserList);
// }
// }
//
// Path: src/main/java/org/jinstagram/entity/common/Location.java
// public class Location {
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("latitude")
// private double latitude;
//
// @SerializedName("longitude")
// private double longitude;
//
// /**
// * @return the latitude
// */
// public double getLatitude() {
// return latitude;
// }
//
// /**
// * @param latitude
// * the latitude to set
// */
// public void setLatitude(double latitude) {
// this.latitude = latitude;
// }
//
// /**
// * @return the longitude
// */
// public double getLongitude() {
// return longitude;
// }
//
// /**
// * @param longitude
// * the longitude to set
// */
// public void setLongitude(double longitude) {
// this.longitude = longitude;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return String.format("Location [id=%s, name=%s, latitude=%s, longitude=%s]", id, name, latitude, longitude);
// }
// }
// Path: src/main/java/org/jinstagram/entity/users/feed/MediaFeedData.java
import java.util.List;
import org.jinstagram.entity.common.Caption;
import org.jinstagram.entity.common.Comments;
import org.jinstagram.entity.common.Images;
import org.jinstagram.entity.common.Likes;
import org.jinstagram.entity.common.Location;
import org.jinstagram.entity.common.User;
import org.jinstagram.entity.common.UsersInPhoto;
import org.jinstagram.entity.common.Videos;
import com.google.gson.annotations.SerializedName;
package org.jinstagram.entity.users.feed;
public class MediaFeedData {
@SerializedName("caption")
private Caption caption;
@SerializedName("comments")
private Comments comments;
@SerializedName("created_time")
private String createdTime;
@SerializedName("id")
private String id;
@SerializedName("filter")
private String imageFilter;
@SerializedName("images")
private Images images;
@SerializedName("videos")
private Videos videos;
@SerializedName("likes") | private Likes likes; |
sachin-handiekar/jInstagram | src/main/java/org/jinstagram/entity/users/feed/MediaFeedData.java | // Path: src/main/java/org/jinstagram/entity/common/Likes.java
// public class Likes {
// @SerializedName("count")
// private int count;
//
// @SerializedName("data")
// private List<User> likesUserList;
//
// /**
// * @return the count
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @param count the count to set
// */
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<User> getLikesUserList() {
// return likesUserList;
// }
//
// public void setLikesUserList(List<User> likesUserList) {
// this.likesUserList = likesUserList;
// }
//
// @Override
// public String toString() {
// return String.format("Likes [count=%s, likesUserList=%s]", count, likesUserList);
// }
// }
//
// Path: src/main/java/org/jinstagram/entity/common/Location.java
// public class Location {
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("latitude")
// private double latitude;
//
// @SerializedName("longitude")
// private double longitude;
//
// /**
// * @return the latitude
// */
// public double getLatitude() {
// return latitude;
// }
//
// /**
// * @param latitude
// * the latitude to set
// */
// public void setLatitude(double latitude) {
// this.latitude = latitude;
// }
//
// /**
// * @return the longitude
// */
// public double getLongitude() {
// return longitude;
// }
//
// /**
// * @param longitude
// * the longitude to set
// */
// public void setLongitude(double longitude) {
// this.longitude = longitude;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return String.format("Location [id=%s, name=%s, latitude=%s, longitude=%s]", id, name, latitude, longitude);
// }
// }
| import java.util.List;
import org.jinstagram.entity.common.Caption;
import org.jinstagram.entity.common.Comments;
import org.jinstagram.entity.common.Images;
import org.jinstagram.entity.common.Likes;
import org.jinstagram.entity.common.Location;
import org.jinstagram.entity.common.User;
import org.jinstagram.entity.common.UsersInPhoto;
import org.jinstagram.entity.common.Videos;
import com.google.gson.annotations.SerializedName; | package org.jinstagram.entity.users.feed;
public class MediaFeedData {
@SerializedName("caption")
private Caption caption;
@SerializedName("comments")
private Comments comments;
@SerializedName("created_time")
private String createdTime;
@SerializedName("id")
private String id;
@SerializedName("filter")
private String imageFilter;
@SerializedName("images")
private Images images;
@SerializedName("videos")
private Videos videos;
@SerializedName("likes")
private Likes likes;
@SerializedName("link")
private String link;
@SerializedName("location") | // Path: src/main/java/org/jinstagram/entity/common/Likes.java
// public class Likes {
// @SerializedName("count")
// private int count;
//
// @SerializedName("data")
// private List<User> likesUserList;
//
// /**
// * @return the count
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @param count the count to set
// */
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<User> getLikesUserList() {
// return likesUserList;
// }
//
// public void setLikesUserList(List<User> likesUserList) {
// this.likesUserList = likesUserList;
// }
//
// @Override
// public String toString() {
// return String.format("Likes [count=%s, likesUserList=%s]", count, likesUserList);
// }
// }
//
// Path: src/main/java/org/jinstagram/entity/common/Location.java
// public class Location {
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("latitude")
// private double latitude;
//
// @SerializedName("longitude")
// private double longitude;
//
// /**
// * @return the latitude
// */
// public double getLatitude() {
// return latitude;
// }
//
// /**
// * @param latitude
// * the latitude to set
// */
// public void setLatitude(double latitude) {
// this.latitude = latitude;
// }
//
// /**
// * @return the longitude
// */
// public double getLongitude() {
// return longitude;
// }
//
// /**
// * @param longitude
// * the longitude to set
// */
// public void setLongitude(double longitude) {
// this.longitude = longitude;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return String.format("Location [id=%s, name=%s, latitude=%s, longitude=%s]", id, name, latitude, longitude);
// }
// }
// Path: src/main/java/org/jinstagram/entity/users/feed/MediaFeedData.java
import java.util.List;
import org.jinstagram.entity.common.Caption;
import org.jinstagram.entity.common.Comments;
import org.jinstagram.entity.common.Images;
import org.jinstagram.entity.common.Likes;
import org.jinstagram.entity.common.Location;
import org.jinstagram.entity.common.User;
import org.jinstagram.entity.common.UsersInPhoto;
import org.jinstagram.entity.common.Videos;
import com.google.gson.annotations.SerializedName;
package org.jinstagram.entity.users.feed;
public class MediaFeedData {
@SerializedName("caption")
private Caption caption;
@SerializedName("comments")
private Comments comments;
@SerializedName("created_time")
private String createdTime;
@SerializedName("id")
private String id;
@SerializedName("filter")
private String imageFilter;
@SerializedName("images")
private Images images;
@SerializedName("videos")
private Videos videos;
@SerializedName("likes")
private Likes likes;
@SerializedName("link")
private String link;
@SerializedName("location") | private Location location; |
sachin-handiekar/jInstagram | src/test/java/org/jinstagram/auth/InstagramAuthServiceTest.java | // Path: src/main/java/org/jinstagram/auth/oauth/InstagramService.java
// public class InstagramService {
// private static final String VERSION = "1.0";
//
// private static final String AUTHORIZATION_CODE = "authorization_code";
//
// private final InstagramApi api;
//
// private final OAuthConfig config;
//
// /**
// * Default constructor
// *
// * @param api OAuth2.0 api information
// * @param config OAuth 2.0 configuration param object
// */
// public InstagramService(InstagramApi api, OAuthConfig config) {
// this.api = api;
// this.config = config;
// }
//
// /**
// * {@inheritDoc}
// */
// public Token getAccessToken(Verifier verifier) {
// OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
//
// // Add the oauth parameter in the body
// request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
// request.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
// request.addBodyParameter(OAuthConstants.GRANT_TYPE, AUTHORIZATION_CODE);
// request.addBodyParameter(OAuthConstants.CODE, verifier.getValue());
// request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
//
// if (config.hasScope()) {
// request.addBodyParameter(OAuthConstants.SCOPE, config.getScope());
// }
//
// if (config.getDisplay() != null) {
// request.addBodyParameter(OAuthConstants.DISPLAY, config.getDisplay());
// }
//
// if (config.getRequestProxy() != null) {
// request.setProxy(config.getRequestProxy() );
// }
//
// Response response;
// try {
// response = request.send();
// } catch (IOException e) {
// throw new OAuthException("Could not get access token", e);
// }
//
// return api.getAccessTokenExtractor().extract(response.getBody());
// }
//
// /**
// * {@inheritDoc}
// */
// public Token getRequestToken() {
// throw new UnsupportedOperationException(
// "Unsupported operation, please use 'getAuthorizationUrl' and redirect your users there");
// }
//
// /**
// * {@inheritDoc}
// */
// public String getVersion() {
// return VERSION;
// }
//
// /**
// * {@inheritDoc}
// */
// public void signRequest(Token accessToken, OAuthRequest request) {
// request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, accessToken.getToken());
// }
//
// /**
// * {@inheritDoc}
// */
// public String getAuthorizationUrl() {
// return api.getAuthorizationUrl(config);
// }
//
// /**
// * Return an Instagram object
// */
// public InstagramClient getInstagram(Token accessToken) {
// return new Instagram(accessToken);
// }
//
// /**
// * Return an Instagram object with enforced signed header
// */
// @Deprecated
// public InstagramClient getSignedHeaderInstagram(Token accessToken, String ipAddress) {
// return new Instagram(accessToken.getToken(), config.getApiSecret(), ipAddress);
// }
// }
| import static org.junit.Assert.assertNotNull;
import java.net.InetSocketAddress;
import java.net.Proxy;
import org.jinstagram.auth.oauth.InstagramService;
import org.junit.Test; |
// add additional test code here
// An unexpected exception was thrown in user code while executing this
// test:
// java.lang.IllegalArgumentException: Invalid Api secret
// at org.jinstagram.utils.Preconditions.check(Preconditions.java:116)
// at
// org.jinstagram.utils.Preconditions.checkEmptyString(Preconditions.java:48)
// at
// org.jinstagram.auth.InstagramAuthService.apiSecret(InstagramAuthService.java:67)
assertNotNull(result);
}
/**
* Run the InstagramService build() method test.
*
* @throws Exception
*
*
*/
@Test(expected = IllegalArgumentException.class)
public void testBuild() throws Exception {
InstagramAuthService fixture = new InstagramAuthService();
fixture.apiSecret("");
fixture.callback("");
fixture.scope("");
fixture.proxy(new Proxy(java.net.Proxy.Type.DIRECT, new InetSocketAddress(1)));
fixture.apiKey("");
fixture.display("");
| // Path: src/main/java/org/jinstagram/auth/oauth/InstagramService.java
// public class InstagramService {
// private static final String VERSION = "1.0";
//
// private static final String AUTHORIZATION_CODE = "authorization_code";
//
// private final InstagramApi api;
//
// private final OAuthConfig config;
//
// /**
// * Default constructor
// *
// * @param api OAuth2.0 api information
// * @param config OAuth 2.0 configuration param object
// */
// public InstagramService(InstagramApi api, OAuthConfig config) {
// this.api = api;
// this.config = config;
// }
//
// /**
// * {@inheritDoc}
// */
// public Token getAccessToken(Verifier verifier) {
// OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
//
// // Add the oauth parameter in the body
// request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
// request.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
// request.addBodyParameter(OAuthConstants.GRANT_TYPE, AUTHORIZATION_CODE);
// request.addBodyParameter(OAuthConstants.CODE, verifier.getValue());
// request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
//
// if (config.hasScope()) {
// request.addBodyParameter(OAuthConstants.SCOPE, config.getScope());
// }
//
// if (config.getDisplay() != null) {
// request.addBodyParameter(OAuthConstants.DISPLAY, config.getDisplay());
// }
//
// if (config.getRequestProxy() != null) {
// request.setProxy(config.getRequestProxy() );
// }
//
// Response response;
// try {
// response = request.send();
// } catch (IOException e) {
// throw new OAuthException("Could not get access token", e);
// }
//
// return api.getAccessTokenExtractor().extract(response.getBody());
// }
//
// /**
// * {@inheritDoc}
// */
// public Token getRequestToken() {
// throw new UnsupportedOperationException(
// "Unsupported operation, please use 'getAuthorizationUrl' and redirect your users there");
// }
//
// /**
// * {@inheritDoc}
// */
// public String getVersion() {
// return VERSION;
// }
//
// /**
// * {@inheritDoc}
// */
// public void signRequest(Token accessToken, OAuthRequest request) {
// request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, accessToken.getToken());
// }
//
// /**
// * {@inheritDoc}
// */
// public String getAuthorizationUrl() {
// return api.getAuthorizationUrl(config);
// }
//
// /**
// * Return an Instagram object
// */
// public InstagramClient getInstagram(Token accessToken) {
// return new Instagram(accessToken);
// }
//
// /**
// * Return an Instagram object with enforced signed header
// */
// @Deprecated
// public InstagramClient getSignedHeaderInstagram(Token accessToken, String ipAddress) {
// return new Instagram(accessToken.getToken(), config.getApiSecret(), ipAddress);
// }
// }
// Path: src/test/java/org/jinstagram/auth/InstagramAuthServiceTest.java
import static org.junit.Assert.assertNotNull;
import java.net.InetSocketAddress;
import java.net.Proxy;
import org.jinstagram.auth.oauth.InstagramService;
import org.junit.Test;
// add additional test code here
// An unexpected exception was thrown in user code while executing this
// test:
// java.lang.IllegalArgumentException: Invalid Api secret
// at org.jinstagram.utils.Preconditions.check(Preconditions.java:116)
// at
// org.jinstagram.utils.Preconditions.checkEmptyString(Preconditions.java:48)
// at
// org.jinstagram.auth.InstagramAuthService.apiSecret(InstagramAuthService.java:67)
assertNotNull(result);
}
/**
* Run the InstagramService build() method test.
*
* @throws Exception
*
*
*/
@Test(expected = IllegalArgumentException.class)
public void testBuild() throws Exception {
InstagramAuthService fixture = new InstagramAuthService();
fixture.apiSecret("");
fixture.callback("");
fixture.scope("");
fixture.proxy(new Proxy(java.net.Proxy.Type.DIRECT, new InetSocketAddress(1)));
fixture.apiKey("");
fixture.display("");
| InstagramService result = fixture.build(); |
sachin-handiekar/jInstagram | src/main/java/org/jinstagram/auth/model/Verifier.java | // Path: src/main/java/org/jinstagram/utils/Preconditions.java
// public class Preconditions {
// private static final String DEFAULT_MESSAGE = "Received an invalid parameter";
//
// private static final Pattern URL_PATTERN = Pattern.compile("^[a-zA-Z][a-zA-Z0-9+.-]*://\\S+");
// private static final Pattern LAT_LONG_PATTERN = Pattern.compile("(-)?[0-9]+(\\.)?[0-9]*");
// private static final Pattern NUMERIC_PATTERN = Pattern.compile("[0-9]+");
//
// /**
// * Checks that an object is not null.
// *
// * @param object any object
// * @param errorMsg error message
// * @throws IllegalArgumentException if the object is null
// */
// public static void checkNotNull(Object object, String errorMsg) {
// check(object != null, errorMsg);
// }
//
// /**
// * Checks that at least one of object1 or object2 is not null
// *
// * @param object1 any object
// * @param object2 any object
// * @param errorMsg error message
// * @throws IllegalArgumentException if both object1 and object2 are null
// */
// public static void checkBothNotNull(Object object1, Object object2, String errorMsg) {
// check(!(object1 == null && object2 == null), errorMsg);
// }
//
// /**
// * Checks that a string is not null or empty
// * @param string any string
// * @param errorMsg error message
// * @throws IllegalArgumentException if the string is null or empty
// */
// public static void checkEmptyString(String string, String errorMsg) {
// check(StringUtils.isNotBlank(string), errorMsg);
// }
//
// /**
// * Checks that a URL is valid
// *
// * @param url any string
// * @param errorMsg error message
// */
// public static void checkValidUrl(String url, String errorMsg) {
// checkEmptyString(url, errorMsg);
// check(isUrl(url), errorMsg);
// }
//
// /**
// * Checks that a URL is a valid OAuth callback
// *
// * @param url any string
// * @param errorMsg error message
// */
// public static void checkValidOAuthCallback(String url, String errorMsg) {
// checkEmptyString(url, errorMsg);
//
// if (url.toLowerCase().compareToIgnoreCase(OAuthConstants.OUT_OF_BAND) != 0) {
// check(isUrl(url), errorMsg);
// }
// }
//
// /**
// * Checks that a string is a valid longitude or latitude value ('lat' and 'lng')
// * as shown in <a href="http://instagram.com/developer/realtime/">Instagram Developer real time section</a>
// *
// * @param latOrLong any string
// * @param errorMsg error message
// */
// public static void checkValidLatLong(String latOrLong, String errorMsg) {
// checkEmptyString(latOrLong, errorMsg);
// check(isLatLong(latOrLong), errorMsg);
// }
//
// /**
// * Check that a string is a valid radius value ('radius')
// * as shown in <a href="http://instagram.com/developer/realtime/">Instagram Developer real time section</a>
// *
// * @param radiusString any string that is supposed to be a radius
// * @param errorMsg error message
// */
// public static void checkValidRadius(String radiusString, String errorMsg) {
// checkEmptyString(radiusString, errorMsg);
// check(isNumeric(radiusString), errorMsg);
// }
//
// private static boolean isUrl(String url) {
// return URL_PATTERN.matcher(url).matches();
// }
//
// private static boolean isLatLong(String latOrLong) {
// return LAT_LONG_PATTERN.matcher(latOrLong).matches();
// }
//
// private static boolean isNumeric(String numericString) {
// return NUMERIC_PATTERN.matcher(numericString).matches();
// }
//
// private static void check(boolean requirements, String error) {
// String message = StringUtils.isBlank(error) ? DEFAULT_MESSAGE : error;
//
// if (!requirements) {
// throw new IllegalArgumentException(message);
// }
// }
// }
| import org.jinstagram.utils.Preconditions; | package org.jinstagram.auth.model;
/**
* Represents an OAuth verifier code.
*/
public class Verifier {
private final String value;
/**
* Default constructor.
*
* @param value verifier value
*/
public Verifier(String value) { | // Path: src/main/java/org/jinstagram/utils/Preconditions.java
// public class Preconditions {
// private static final String DEFAULT_MESSAGE = "Received an invalid parameter";
//
// private static final Pattern URL_PATTERN = Pattern.compile("^[a-zA-Z][a-zA-Z0-9+.-]*://\\S+");
// private static final Pattern LAT_LONG_PATTERN = Pattern.compile("(-)?[0-9]+(\\.)?[0-9]*");
// private static final Pattern NUMERIC_PATTERN = Pattern.compile("[0-9]+");
//
// /**
// * Checks that an object is not null.
// *
// * @param object any object
// * @param errorMsg error message
// * @throws IllegalArgumentException if the object is null
// */
// public static void checkNotNull(Object object, String errorMsg) {
// check(object != null, errorMsg);
// }
//
// /**
// * Checks that at least one of object1 or object2 is not null
// *
// * @param object1 any object
// * @param object2 any object
// * @param errorMsg error message
// * @throws IllegalArgumentException if both object1 and object2 are null
// */
// public static void checkBothNotNull(Object object1, Object object2, String errorMsg) {
// check(!(object1 == null && object2 == null), errorMsg);
// }
//
// /**
// * Checks that a string is not null or empty
// * @param string any string
// * @param errorMsg error message
// * @throws IllegalArgumentException if the string is null or empty
// */
// public static void checkEmptyString(String string, String errorMsg) {
// check(StringUtils.isNotBlank(string), errorMsg);
// }
//
// /**
// * Checks that a URL is valid
// *
// * @param url any string
// * @param errorMsg error message
// */
// public static void checkValidUrl(String url, String errorMsg) {
// checkEmptyString(url, errorMsg);
// check(isUrl(url), errorMsg);
// }
//
// /**
// * Checks that a URL is a valid OAuth callback
// *
// * @param url any string
// * @param errorMsg error message
// */
// public static void checkValidOAuthCallback(String url, String errorMsg) {
// checkEmptyString(url, errorMsg);
//
// if (url.toLowerCase().compareToIgnoreCase(OAuthConstants.OUT_OF_BAND) != 0) {
// check(isUrl(url), errorMsg);
// }
// }
//
// /**
// * Checks that a string is a valid longitude or latitude value ('lat' and 'lng')
// * as shown in <a href="http://instagram.com/developer/realtime/">Instagram Developer real time section</a>
// *
// * @param latOrLong any string
// * @param errorMsg error message
// */
// public static void checkValidLatLong(String latOrLong, String errorMsg) {
// checkEmptyString(latOrLong, errorMsg);
// check(isLatLong(latOrLong), errorMsg);
// }
//
// /**
// * Check that a string is a valid radius value ('radius')
// * as shown in <a href="http://instagram.com/developer/realtime/">Instagram Developer real time section</a>
// *
// * @param radiusString any string that is supposed to be a radius
// * @param errorMsg error message
// */
// public static void checkValidRadius(String radiusString, String errorMsg) {
// checkEmptyString(radiusString, errorMsg);
// check(isNumeric(radiusString), errorMsg);
// }
//
// private static boolean isUrl(String url) {
// return URL_PATTERN.matcher(url).matches();
// }
//
// private static boolean isLatLong(String latOrLong) {
// return LAT_LONG_PATTERN.matcher(latOrLong).matches();
// }
//
// private static boolean isNumeric(String numericString) {
// return NUMERIC_PATTERN.matcher(numericString).matches();
// }
//
// private static void check(boolean requirements, String error) {
// String message = StringUtils.isBlank(error) ? DEFAULT_MESSAGE : error;
//
// if (!requirements) {
// throw new IllegalArgumentException(message);
// }
// }
// }
// Path: src/main/java/org/jinstagram/auth/model/Verifier.java
import org.jinstagram.utils.Preconditions;
package org.jinstagram.auth.model;
/**
* Represents an OAuth verifier code.
*/
public class Verifier {
private final String value;
/**
* Default constructor.
*
* @param value verifier value
*/
public Verifier(String value) { | Preconditions.checkNotNull(value, "Must provide a valid string as verifier"); |
sachin-handiekar/jInstagram | src/test/java/org/jinstagram/entity/locations/LocationSearchFeedTest.java | // Path: src/main/java/org/jinstagram/entity/common/Location.java
// public class Location {
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("latitude")
// private double latitude;
//
// @SerializedName("longitude")
// private double longitude;
//
// /**
// * @return the latitude
// */
// public double getLatitude() {
// return latitude;
// }
//
// /**
// * @param latitude
// * the latitude to set
// */
// public void setLatitude(double latitude) {
// this.latitude = latitude;
// }
//
// /**
// * @return the longitude
// */
// public double getLongitude() {
// return longitude;
// }
//
// /**
// * @param longitude
// * the longitude to set
// */
// public void setLongitude(double longitude) {
// this.longitude = longitude;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return String.format("Location [id=%s, name=%s, latitude=%s, longitude=%s]", id, name, latitude, longitude);
// }
// }
| import java.util.LinkedList;
import java.util.List;
import org.jinstagram.entity.common.Location;
import org.junit.*;
import static org.junit.Assert.*; | package org.jinstagram.entity.locations;
/**
* The class <code>LocationSearchFeedTest</code> contains tests for the class <code>{@link LocationSearchFeed}</code>.
*
* @generatedBy CodePro at 31/01/16 15:05
* @author SachinHandiekar
* @version $Revision: 1.0 $
*/
public class LocationSearchFeedTest {
/**
* Run the List<Location> getLocationList() method test.
*
* @throws Exception
*
* @generatedBy CodePro at 31/01/16 15:05
*/
@Test
public void testGetLocationList_1()
throws Exception {
LocationSearchFeed fixture = new LocationSearchFeed();
fixture.setLocationList(new LinkedList());
| // Path: src/main/java/org/jinstagram/entity/common/Location.java
// public class Location {
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("latitude")
// private double latitude;
//
// @SerializedName("longitude")
// private double longitude;
//
// /**
// * @return the latitude
// */
// public double getLatitude() {
// return latitude;
// }
//
// /**
// * @param latitude
// * the latitude to set
// */
// public void setLatitude(double latitude) {
// this.latitude = latitude;
// }
//
// /**
// * @return the longitude
// */
// public double getLongitude() {
// return longitude;
// }
//
// /**
// * @param longitude
// * the longitude to set
// */
// public void setLongitude(double longitude) {
// this.longitude = longitude;
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return String.format("Location [id=%s, name=%s, latitude=%s, longitude=%s]", id, name, latitude, longitude);
// }
// }
// Path: src/test/java/org/jinstagram/entity/locations/LocationSearchFeedTest.java
import java.util.LinkedList;
import java.util.List;
import org.jinstagram.entity.common.Location;
import org.junit.*;
import static org.junit.Assert.*;
package org.jinstagram.entity.locations;
/**
* The class <code>LocationSearchFeedTest</code> contains tests for the class <code>{@link LocationSearchFeed}</code>.
*
* @generatedBy CodePro at 31/01/16 15:05
* @author SachinHandiekar
* @version $Revision: 1.0 $
*/
public class LocationSearchFeedTest {
/**
* Run the List<Location> getLocationList() method test.
*
* @throws Exception
*
* @generatedBy CodePro at 31/01/16 15:05
*/
@Test
public void testGetLocationList_1()
throws Exception {
LocationSearchFeed fixture = new LocationSearchFeed();
fixture.setLocationList(new LinkedList());
| List<Location> result = fixture.getLocationList(); |
termd/termd | src/examples/java/examples/ptybridge/WebsocketPtyBridgeExample.java | // Path: src/main/java/io/termd/core/pty/TtyBridge.java
// public class TtyBridge {
//
// Logger log = LoggerFactory.getLogger(TtyBridge.class);
// final TtyConnection conn;
// private Consumer<PtyMaster> processListener;
// private Consumer<int[]> processStdoutListener;
// private Consumer<String> processStdinListener;
//
// public TtyBridge(TtyConnection conn) {
// this.conn = conn;
// }
//
// public Consumer<PtyMaster> getProcessListener() {
// return processListener;
// }
//
// public TtyBridge setProcessListener(Consumer<PtyMaster> processListener) {
// this.processListener = processListener;
// return this;
// }
//
// public Consumer<String> getProcessStdinListener() {
// return processStdinListener;
// }
//
// public TtyBridge setProcessStdinListener(Consumer<String> processStdinListener) {
// this.processStdinListener = processStdinListener;
// return this;
// }
//
// public Consumer<int[]> getProcessStdoutListener() {
// return processStdoutListener;
// }
//
// public TtyBridge setProcessStdoutListener(Consumer<int[]> processStdoutListener) {
// this.processStdoutListener = processStdoutListener;
// return this;
// }
//
// public TtyBridge readline() {
// InputStream inputrc = Keymap.class.getResourceAsStream("inputrc");
// Keymap keymap = new Keymap(inputrc);
// Readline readline = new Readline(keymap);
// for (io.termd.core.readline.Function function : Helper.loadServices(Thread.currentThread().getContextClassLoader(), io.termd.core.readline.Function.class)) {
// log.trace("Server is adding function to readline: {}", function);
//
// readline.addFunction(function);
// }
// conn.setTerminalTypeHandler(term -> {
// // Not used yet but we should propagage this to the process builder
// // System.out.println("CLIENT $TERM=" + term);
// });
// conn.stdoutHandler().accept(Helper.toCodePoints("Welcome sir\n"));
// read(conn, readline);
// return this;
// }
//
// void read(final TtyConnection conn, final Readline readline) {
// readline.readline(conn, "% ", line -> onNewLine(conn, readline, line));
// }
//
// private void onNewLine(TtyConnection conn, Readline readline, String line) {
// if (processStdinListener != null) {
// processStdinListener.accept(line);
// }
// if (line == null) {
// conn.close();
// return;
// }
// PtyMaster task = new PtyMaster(line, buffer -> onStdOut(conn, buffer), empty -> doneHandler(conn, readline));
// conn.setEventHandler((event,cp) -> {
// if (event == TtyEvent.INTR) {
// task.interruptProcess();
// }
// });
// if (processListener != null) {
// processListener.accept(task);
// }
// task.start();
// }
//
// private void doneHandler(TtyConnection conn, Readline readline) {
// conn.setEventHandler(null);
// conn.execute(() -> read(conn, readline));
// }
//
// private void onStdOut(TtyConnection conn, int[] buffer) {
// conn.execute(() -> {
// conn.stdoutHandler().accept(buffer);
// });
// if (processStdoutListener != null) {
// processStdoutListener.accept(buffer);
// }
// }
// }
| import io.termd.core.http.netty.NettyWebsocketTtyBootstrap;
import io.termd.core.pty.TtyBridge;
import java.util.concurrent.TimeUnit; | package examples.ptybridge;
public class WebsocketPtyBridgeExample {
public synchronized static void main(String[] args) throws Exception {
NettyWebsocketTtyBootstrap bootstrap = new NettyWebsocketTtyBootstrap().setHost("localhost").setPort(8080); | // Path: src/main/java/io/termd/core/pty/TtyBridge.java
// public class TtyBridge {
//
// Logger log = LoggerFactory.getLogger(TtyBridge.class);
// final TtyConnection conn;
// private Consumer<PtyMaster> processListener;
// private Consumer<int[]> processStdoutListener;
// private Consumer<String> processStdinListener;
//
// public TtyBridge(TtyConnection conn) {
// this.conn = conn;
// }
//
// public Consumer<PtyMaster> getProcessListener() {
// return processListener;
// }
//
// public TtyBridge setProcessListener(Consumer<PtyMaster> processListener) {
// this.processListener = processListener;
// return this;
// }
//
// public Consumer<String> getProcessStdinListener() {
// return processStdinListener;
// }
//
// public TtyBridge setProcessStdinListener(Consumer<String> processStdinListener) {
// this.processStdinListener = processStdinListener;
// return this;
// }
//
// public Consumer<int[]> getProcessStdoutListener() {
// return processStdoutListener;
// }
//
// public TtyBridge setProcessStdoutListener(Consumer<int[]> processStdoutListener) {
// this.processStdoutListener = processStdoutListener;
// return this;
// }
//
// public TtyBridge readline() {
// InputStream inputrc = Keymap.class.getResourceAsStream("inputrc");
// Keymap keymap = new Keymap(inputrc);
// Readline readline = new Readline(keymap);
// for (io.termd.core.readline.Function function : Helper.loadServices(Thread.currentThread().getContextClassLoader(), io.termd.core.readline.Function.class)) {
// log.trace("Server is adding function to readline: {}", function);
//
// readline.addFunction(function);
// }
// conn.setTerminalTypeHandler(term -> {
// // Not used yet but we should propagage this to the process builder
// // System.out.println("CLIENT $TERM=" + term);
// });
// conn.stdoutHandler().accept(Helper.toCodePoints("Welcome sir\n"));
// read(conn, readline);
// return this;
// }
//
// void read(final TtyConnection conn, final Readline readline) {
// readline.readline(conn, "% ", line -> onNewLine(conn, readline, line));
// }
//
// private void onNewLine(TtyConnection conn, Readline readline, String line) {
// if (processStdinListener != null) {
// processStdinListener.accept(line);
// }
// if (line == null) {
// conn.close();
// return;
// }
// PtyMaster task = new PtyMaster(line, buffer -> onStdOut(conn, buffer), empty -> doneHandler(conn, readline));
// conn.setEventHandler((event,cp) -> {
// if (event == TtyEvent.INTR) {
// task.interruptProcess();
// }
// });
// if (processListener != null) {
// processListener.accept(task);
// }
// task.start();
// }
//
// private void doneHandler(TtyConnection conn, Readline readline) {
// conn.setEventHandler(null);
// conn.execute(() -> read(conn, readline));
// }
//
// private void onStdOut(TtyConnection conn, int[] buffer) {
// conn.execute(() -> {
// conn.stdoutHandler().accept(buffer);
// });
// if (processStdoutListener != null) {
// processStdoutListener.accept(buffer);
// }
// }
// }
// Path: src/examples/java/examples/ptybridge/WebsocketPtyBridgeExample.java
import io.termd.core.http.netty.NettyWebsocketTtyBootstrap;
import io.termd.core.pty.TtyBridge;
import java.util.concurrent.TimeUnit;
package examples.ptybridge;
public class WebsocketPtyBridgeExample {
public synchronized static void main(String[] args) throws Exception {
NettyWebsocketTtyBootstrap bootstrap = new NettyWebsocketTtyBootstrap().setHost("localhost").setPort(8080); | bootstrap.start(conn -> new TtyBridge(conn).readline()).get(10, TimeUnit.SECONDS); |
termd/termd | src/test/java/io/termd/core/tty/NettyAsciiTelnetTtyTest.java | // Path: src/test/java/io/termd/core/telnet/TelnetServerRule.java
// public class TelnetServerRule extends ExternalResource {
//
// public static final Function<Supplier<TelnetHandler>, Closeable> NETTY_SERVER = handlerFactory -> {
// EventLoopGroup bossGroup = new NioEventLoopGroup(1);
// EventLoopGroup workerGroup = new NioEventLoopGroup();
// ServerBootstrap b = new ServerBootstrap();
// b.group(bossGroup, workerGroup)
// .channel(NioServerSocketChannel.class)
// .option(ChannelOption.SO_BACKLOG, 100)
// .handler(new LoggingHandler(LogLevel.INFO))
// .childHandler(new ChannelInitializer<SocketChannel>() {
// @Override
// public void initChannel(SocketChannel ch) throws Exception {
// ChannelPipeline p = ch.pipeline();
// TelnetChannelHandler handler = new TelnetChannelHandler(handlerFactory);
// p.addLast(handler);
// }
// });
// try {
// b.bind("localhost", 4000).sync();
// return () -> {
// bossGroup.shutdownGracefully();
// };
// } catch (InterruptedException e) {
// throw TestBase.failure(e);
// }
// };
//
// private final Function<Supplier<TelnetHandler>, Closeable> serverFactory;
// protected Closeable server;
//
// public TelnetServerRule(Function<Supplier<TelnetHandler>, Closeable> serverFactory) {
// this.serverFactory = serverFactory;
// }
//
// @Override
// protected void before() throws Throwable {
// server = null;
// }
//
// @Override
// protected void after() {
// if (server != null) {
// try {
// server.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// public final void start(Supplier<TelnetHandler> telnetFactory) {
// if (server != null) {
// throw TestBase.failure("Already a server");
// }
// server = serverFactory.apply(telnetFactory);
// }
// }
| import io.termd.core.telnet.TelnetHandler;
import io.termd.core.telnet.TelnetServerRule;
import java.io.Closeable;
import java.util.function.Function;
import java.util.function.Supplier; | /*
* Copyright 2015 Julien Viet
*
* 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 io.termd.core.tty;
/**
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class NettyAsciiTelnetTtyTest extends TelnetTtyTestBase {
public NettyAsciiTelnetTtyTest() {
binary = false;
}
@Override
protected Function<Supplier<TelnetHandler>, Closeable> serverFactory() { | // Path: src/test/java/io/termd/core/telnet/TelnetServerRule.java
// public class TelnetServerRule extends ExternalResource {
//
// public static final Function<Supplier<TelnetHandler>, Closeable> NETTY_SERVER = handlerFactory -> {
// EventLoopGroup bossGroup = new NioEventLoopGroup(1);
// EventLoopGroup workerGroup = new NioEventLoopGroup();
// ServerBootstrap b = new ServerBootstrap();
// b.group(bossGroup, workerGroup)
// .channel(NioServerSocketChannel.class)
// .option(ChannelOption.SO_BACKLOG, 100)
// .handler(new LoggingHandler(LogLevel.INFO))
// .childHandler(new ChannelInitializer<SocketChannel>() {
// @Override
// public void initChannel(SocketChannel ch) throws Exception {
// ChannelPipeline p = ch.pipeline();
// TelnetChannelHandler handler = new TelnetChannelHandler(handlerFactory);
// p.addLast(handler);
// }
// });
// try {
// b.bind("localhost", 4000).sync();
// return () -> {
// bossGroup.shutdownGracefully();
// };
// } catch (InterruptedException e) {
// throw TestBase.failure(e);
// }
// };
//
// private final Function<Supplier<TelnetHandler>, Closeable> serverFactory;
// protected Closeable server;
//
// public TelnetServerRule(Function<Supplier<TelnetHandler>, Closeable> serverFactory) {
// this.serverFactory = serverFactory;
// }
//
// @Override
// protected void before() throws Throwable {
// server = null;
// }
//
// @Override
// protected void after() {
// if (server != null) {
// try {
// server.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// public final void start(Supplier<TelnetHandler> telnetFactory) {
// if (server != null) {
// throw TestBase.failure("Already a server");
// }
// server = serverFactory.apply(telnetFactory);
// }
// }
// Path: src/test/java/io/termd/core/tty/NettyAsciiTelnetTtyTest.java
import io.termd.core.telnet.TelnetHandler;
import io.termd.core.telnet.TelnetServerRule;
import java.io.Closeable;
import java.util.function.Function;
import java.util.function.Supplier;
/*
* Copyright 2015 Julien Viet
*
* 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 io.termd.core.tty;
/**
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class NettyAsciiTelnetTtyTest extends TelnetTtyTestBase {
public NettyAsciiTelnetTtyTest() {
binary = false;
}
@Override
protected Function<Supplier<TelnetHandler>, Closeable> serverFactory() { | return TelnetServerRule.NETTY_SERVER; |
termd/termd | src/main/java/io/termd/core/telnet/TelnetTtyConnection.java | // Path: src/main/java/io/termd/core/io/TelnetCharset.java
// public class TelnetCharset extends Charset {
//
// public static final Charset INSTANCE = new TelnetCharset();
//
// private TelnetCharset() {
// super("Telnet", new String[0]);
// }
//
// @Override
// public boolean contains(Charset cs) {
// return cs.name().equals(name());
// }
//
// @Override
// public CharsetDecoder newDecoder() {
// return new CharsetDecoder(this, 1.0f, 1.0f) {
// private boolean prevCR;
// @Override
// protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
// int pos = in.position();
// int limit = in.limit();
// try {
// while (pos < limit) {
// byte b = in.get(pos);
// char c;
// if (b >= 0) {
// if (prevCR && (b == '\n' || b == 0)) {
// pos++;
// prevCR = false;
// continue;
// }
// c = (char) b;
// prevCR = b == '\r';
// } else {
// c = (char)(256 + b);
// }
// if (out.position() >= out.limit()) {
// return CoderResult.OVERFLOW;
// }
// pos++;
// out.put(c);
// }
// return CoderResult.UNDERFLOW;
// } finally {
// in.position(pos);
// }
// }
// };
// }
//
// @Override
// public CharsetEncoder newEncoder() {
// throw new UnsupportedOperationException();
// }
// }
| import java.util.function.Consumer;
import io.termd.core.tty.ReadBuffer;
import io.termd.core.tty.TtyEvent;
import io.termd.core.tty.TtyEventDecoder;
import io.termd.core.tty.TtyOutputMode;
import io.termd.core.util.Vector;
import io.termd.core.io.BinaryDecoder;
import io.termd.core.io.BinaryEncoder;
import io.termd.core.io.TelnetCharset;
import io.termd.core.tty.TtyConnection;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer; | /*
* Copyright 2015 Julien Viet
*
* 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 io.termd.core.telnet;
/**
* A telnet handler that implements {@link io.termd.core.tty.TtyConnection}.
*
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public final class TelnetTtyConnection extends TelnetHandler implements TtyConnection {
private final boolean inBinary;
private final boolean outBinary;
private boolean receivingBinary;
private boolean sendingBinary;
private boolean accepted;
private Vector size;
private String terminalType;
private Consumer<Vector> sizeHandler;
private Consumer<String> termHandler;
private Consumer<Void> closeHandler;
protected TelnetConnection conn;
private final Charset charset;
private final TtyEventDecoder eventDecoder = new TtyEventDecoder(3, 26, 4);
private final ReadBuffer readBuffer = new ReadBuffer(this::execute); | // Path: src/main/java/io/termd/core/io/TelnetCharset.java
// public class TelnetCharset extends Charset {
//
// public static final Charset INSTANCE = new TelnetCharset();
//
// private TelnetCharset() {
// super("Telnet", new String[0]);
// }
//
// @Override
// public boolean contains(Charset cs) {
// return cs.name().equals(name());
// }
//
// @Override
// public CharsetDecoder newDecoder() {
// return new CharsetDecoder(this, 1.0f, 1.0f) {
// private boolean prevCR;
// @Override
// protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
// int pos = in.position();
// int limit = in.limit();
// try {
// while (pos < limit) {
// byte b = in.get(pos);
// char c;
// if (b >= 0) {
// if (prevCR && (b == '\n' || b == 0)) {
// pos++;
// prevCR = false;
// continue;
// }
// c = (char) b;
// prevCR = b == '\r';
// } else {
// c = (char)(256 + b);
// }
// if (out.position() >= out.limit()) {
// return CoderResult.OVERFLOW;
// }
// pos++;
// out.put(c);
// }
// return CoderResult.UNDERFLOW;
// } finally {
// in.position(pos);
// }
// }
// };
// }
//
// @Override
// public CharsetEncoder newEncoder() {
// throw new UnsupportedOperationException();
// }
// }
// Path: src/main/java/io/termd/core/telnet/TelnetTtyConnection.java
import java.util.function.Consumer;
import io.termd.core.tty.ReadBuffer;
import io.termd.core.tty.TtyEvent;
import io.termd.core.tty.TtyEventDecoder;
import io.termd.core.tty.TtyOutputMode;
import io.termd.core.util.Vector;
import io.termd.core.io.BinaryDecoder;
import io.termd.core.io.BinaryEncoder;
import io.termd.core.io.TelnetCharset;
import io.termd.core.tty.TtyConnection;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
/*
* Copyright 2015 Julien Viet
*
* 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 io.termd.core.telnet;
/**
* A telnet handler that implements {@link io.termd.core.tty.TtyConnection}.
*
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public final class TelnetTtyConnection extends TelnetHandler implements TtyConnection {
private final boolean inBinary;
private final boolean outBinary;
private boolean receivingBinary;
private boolean sendingBinary;
private boolean accepted;
private Vector size;
private String terminalType;
private Consumer<Vector> sizeHandler;
private Consumer<String> termHandler;
private Consumer<Void> closeHandler;
protected TelnetConnection conn;
private final Charset charset;
private final TtyEventDecoder eventDecoder = new TtyEventDecoder(3, 26, 4);
private final ReadBuffer readBuffer = new ReadBuffer(this::execute); | private final BinaryDecoder decoder = new BinaryDecoder(512, TelnetCharset.INSTANCE, readBuffer); |
termd/termd | src/test/java/io/termd/core/http/websocket/server/TaskStatusUpdateEventDeserializer.java | // Path: src/main/java/io/termd/core/pty/Status.java
// public enum Status {
//
// NEW (false),
// RUNNING (false),
// COMPLETED (true),
// FAILED (true),
// INTERRUPTED (true);
//
// private final boolean final_;
//
// Status(boolean finalFlag) {
// this.final_ = finalFlag;
// }
//
// /**
// * @return true when master won't wait anymore for the process to end, the process may have terminated or not.
// */
// public boolean isFinal() {
// return final_;
// }
//
// }
| import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import io.termd.core.pty.Status;
import java.io.IOException; | /*
* Copyright 2015 Julien Viet
*
* 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 io.termd.core.http.websocket.server;
/**
* @author <a href="mailto:[email protected]">Matej Lazar</a>
*/
class TaskStatusUpdateEventDeserializer extends JsonDeserializer<TaskStatusUpdateEvent> {
@Override
public TaskStatusUpdateEvent deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
JsonNode node = jp.getCodec().readTree(jp);
String taskId = node.get("taskId").asText();
String oldStatus = node.get("oldStatus").asText();
String newStatus = node.get("newStatus").asText();
String context = node.get("context").asText();
| // Path: src/main/java/io/termd/core/pty/Status.java
// public enum Status {
//
// NEW (false),
// RUNNING (false),
// COMPLETED (true),
// FAILED (true),
// INTERRUPTED (true);
//
// private final boolean final_;
//
// Status(boolean finalFlag) {
// this.final_ = finalFlag;
// }
//
// /**
// * @return true when master won't wait anymore for the process to end, the process may have terminated or not.
// */
// public boolean isFinal() {
// return final_;
// }
//
// }
// Path: src/test/java/io/termd/core/http/websocket/server/TaskStatusUpdateEventDeserializer.java
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import io.termd.core.pty.Status;
import java.io.IOException;
/*
* Copyright 2015 Julien Viet
*
* 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 io.termd.core.http.websocket.server;
/**
* @author <a href="mailto:[email protected]">Matej Lazar</a>
*/
class TaskStatusUpdateEventDeserializer extends JsonDeserializer<TaskStatusUpdateEvent> {
@Override
public TaskStatusUpdateEvent deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
JsonNode node = jp.getCodec().readTree(jp);
String taskId = node.get("taskId").asText();
String oldStatus = node.get("oldStatus").asText();
String newStatus = node.get("newStatus").asText();
String context = node.get("context").asText();
| return new TaskStatusUpdateEvent(taskId, Status.valueOf(oldStatus), Status.valueOf(newStatus), context); |
termd/termd | src/test/java/org/apache/sshd/KeyReExchangeTest.java | // Path: src/test/java/org/apache/sshd/util/test/JSchLogger.java
// public class JSchLogger implements Logger {
// private final org.slf4j.Logger log = LoggerFactory.getLogger(JSch.class);
//
// public JSchLogger() {
// super();
// }
//
// @Override
// public boolean isEnabled(int level) {
// switch (level) {
// case INFO: // INFO is too "chatty" so we map it to debug
// case DEBUG:
// return log.isDebugEnabled();
// case WARN:
// return log.isWarnEnabled();
// case ERROR:
// return log.isErrorEnabled();
// case FATAL:
// return log.isErrorEnabled();
// default:
// return false;
// }
// }
//
// @Override
// public void log(int level, String message) {
// switch (level) {
// case INFO: // INFO is too "chatty" so we map it to debug
// case DEBUG:
// log.debug(message);
// break;
// case WARN:
// log.warn(message);
// break;
// case ERROR:
// case FATAL:
// log.error(message);
// break;
// default:
// log.error("[LEVEL=" + level + "]: " + message);
// }
// }
//
// public static void init() {
// JSch.setLogger(new JSchLogger());
// }
// }
//
// Path: src/test/java/org/apache/sshd/util/test/OutputCountTrackingOutputStream.java
// public class OutputCountTrackingOutputStream extends FilterOutputStream {
// protected long writeCount;
//
// public OutputCountTrackingOutputStream(OutputStream out) {
// super(out);
// }
//
// @Override
// public void write(int b) throws IOException {
// out.write(b);
// updateWriteCount(1L);
// }
//
// @Override
// public void write(byte[] b, int off, int len) throws IOException {
// out.write(b, off, len); // don't call super since it calls the single 'write'
// updateWriteCount(len);
// }
//
// public long getWriteCount() {
// return writeCount;
// }
//
// protected long updateWriteCount(long delta) {
// writeCount += delta;
// return writeCount;
// }
// }
| import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import com.jcraft.jsch.JSch;
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.channel.ChannelShell;
import org.apache.sshd.client.channel.ClientChannel;
import org.apache.sshd.client.channel.ClientChannelEvent;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.cipher.BuiltinCiphers;
import org.apache.sshd.common.future.KeyExchangeFuture;
import org.apache.sshd.common.kex.BuiltinDHFactories;
import org.apache.sshd.common.kex.KeyExchange;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.SessionListener;
import org.apache.sshd.common.subsystem.sftp.SftpConstants;
import org.apache.sshd.common.util.SecurityUtils;
import org.apache.sshd.common.util.io.NullOutputStream;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.util.test.BaseTestSupport;
import org.apache.sshd.util.test.JSchLogger;
import org.apache.sshd.util.test.OutputCountTrackingOutputStream;
import org.apache.sshd.util.test.SimpleUserInfo;
import org.apache.sshd.util.test.TeeOutputStream;
import org.junit.After;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters; | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.sshd;
/**
* Test key exchange algorithms.
*
* @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class KeyReExchangeTest extends BaseTestSupport {
private SshServer sshd;
private int port;
public KeyReExchangeTest() {
super();
}
@BeforeClass
public static void jschInit() { | // Path: src/test/java/org/apache/sshd/util/test/JSchLogger.java
// public class JSchLogger implements Logger {
// private final org.slf4j.Logger log = LoggerFactory.getLogger(JSch.class);
//
// public JSchLogger() {
// super();
// }
//
// @Override
// public boolean isEnabled(int level) {
// switch (level) {
// case INFO: // INFO is too "chatty" so we map it to debug
// case DEBUG:
// return log.isDebugEnabled();
// case WARN:
// return log.isWarnEnabled();
// case ERROR:
// return log.isErrorEnabled();
// case FATAL:
// return log.isErrorEnabled();
// default:
// return false;
// }
// }
//
// @Override
// public void log(int level, String message) {
// switch (level) {
// case INFO: // INFO is too "chatty" so we map it to debug
// case DEBUG:
// log.debug(message);
// break;
// case WARN:
// log.warn(message);
// break;
// case ERROR:
// case FATAL:
// log.error(message);
// break;
// default:
// log.error("[LEVEL=" + level + "]: " + message);
// }
// }
//
// public static void init() {
// JSch.setLogger(new JSchLogger());
// }
// }
//
// Path: src/test/java/org/apache/sshd/util/test/OutputCountTrackingOutputStream.java
// public class OutputCountTrackingOutputStream extends FilterOutputStream {
// protected long writeCount;
//
// public OutputCountTrackingOutputStream(OutputStream out) {
// super(out);
// }
//
// @Override
// public void write(int b) throws IOException {
// out.write(b);
// updateWriteCount(1L);
// }
//
// @Override
// public void write(byte[] b, int off, int len) throws IOException {
// out.write(b, off, len); // don't call super since it calls the single 'write'
// updateWriteCount(len);
// }
//
// public long getWriteCount() {
// return writeCount;
// }
//
// protected long updateWriteCount(long delta) {
// writeCount += delta;
// return writeCount;
// }
// }
// Path: src/test/java/org/apache/sshd/KeyReExchangeTest.java
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import com.jcraft.jsch.JSch;
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.channel.ChannelShell;
import org.apache.sshd.client.channel.ClientChannel;
import org.apache.sshd.client.channel.ClientChannelEvent;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.cipher.BuiltinCiphers;
import org.apache.sshd.common.future.KeyExchangeFuture;
import org.apache.sshd.common.kex.BuiltinDHFactories;
import org.apache.sshd.common.kex.KeyExchange;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.SessionListener;
import org.apache.sshd.common.subsystem.sftp.SftpConstants;
import org.apache.sshd.common.util.SecurityUtils;
import org.apache.sshd.common.util.io.NullOutputStream;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.util.test.BaseTestSupport;
import org.apache.sshd.util.test.JSchLogger;
import org.apache.sshd.util.test.OutputCountTrackingOutputStream;
import org.apache.sshd.util.test.SimpleUserInfo;
import org.apache.sshd.util.test.TeeOutputStream;
import org.junit.After;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.sshd;
/**
* Test key exchange algorithms.
*
* @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class KeyReExchangeTest extends BaseTestSupport {
private SshServer sshd;
private int port;
public KeyReExchangeTest() {
super();
}
@BeforeClass
public static void jschInit() { | JSchLogger.init(); |
termd/termd | src/test/java/org/apache/sshd/KeyReExchangeTest.java | // Path: src/test/java/org/apache/sshd/util/test/JSchLogger.java
// public class JSchLogger implements Logger {
// private final org.slf4j.Logger log = LoggerFactory.getLogger(JSch.class);
//
// public JSchLogger() {
// super();
// }
//
// @Override
// public boolean isEnabled(int level) {
// switch (level) {
// case INFO: // INFO is too "chatty" so we map it to debug
// case DEBUG:
// return log.isDebugEnabled();
// case WARN:
// return log.isWarnEnabled();
// case ERROR:
// return log.isErrorEnabled();
// case FATAL:
// return log.isErrorEnabled();
// default:
// return false;
// }
// }
//
// @Override
// public void log(int level, String message) {
// switch (level) {
// case INFO: // INFO is too "chatty" so we map it to debug
// case DEBUG:
// log.debug(message);
// break;
// case WARN:
// log.warn(message);
// break;
// case ERROR:
// case FATAL:
// log.error(message);
// break;
// default:
// log.error("[LEVEL=" + level + "]: " + message);
// }
// }
//
// public static void init() {
// JSch.setLogger(new JSchLogger());
// }
// }
//
// Path: src/test/java/org/apache/sshd/util/test/OutputCountTrackingOutputStream.java
// public class OutputCountTrackingOutputStream extends FilterOutputStream {
// protected long writeCount;
//
// public OutputCountTrackingOutputStream(OutputStream out) {
// super(out);
// }
//
// @Override
// public void write(int b) throws IOException {
// out.write(b);
// updateWriteCount(1L);
// }
//
// @Override
// public void write(byte[] b, int off, int len) throws IOException {
// out.write(b, off, len); // don't call super since it calls the single 'write'
// updateWriteCount(len);
// }
//
// public long getWriteCount() {
// return writeCount;
// }
//
// protected long updateWriteCount(long delta) {
// writeCount += delta;
// return writeCount;
// }
// }
| import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import com.jcraft.jsch.JSch;
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.channel.ChannelShell;
import org.apache.sshd.client.channel.ClientChannel;
import org.apache.sshd.client.channel.ClientChannelEvent;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.cipher.BuiltinCiphers;
import org.apache.sshd.common.future.KeyExchangeFuture;
import org.apache.sshd.common.kex.BuiltinDHFactories;
import org.apache.sshd.common.kex.KeyExchange;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.SessionListener;
import org.apache.sshd.common.subsystem.sftp.SftpConstants;
import org.apache.sshd.common.util.SecurityUtils;
import org.apache.sshd.common.util.io.NullOutputStream;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.util.test.BaseTestSupport;
import org.apache.sshd.util.test.JSchLogger;
import org.apache.sshd.util.test.OutputCountTrackingOutputStream;
import org.apache.sshd.util.test.SimpleUserInfo;
import org.apache.sshd.util.test.TeeOutputStream;
import org.junit.After;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters; | try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession();
ByteArrayOutputStream sent = new ByteArrayOutputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream() {
private long writeCount;
@Override
public void write(int b) {
super.write(b);
updateWriteCount(1L);
pipedCount.release(1);
}
@Override
public void write(byte[] b, int off, int len) {
super.write(b, off, len);
updateWriteCount(len);
pipedCount.release(len);
}
private void updateWriteCount(long delta) {
writeCount += delta;
outputDebugMessage("OUT write count=%d", writeCount);
}
}) {
session.addPasswordIdentity(getCurrentTestName());
session.auth().verify(5L, TimeUnit.SECONDS);
byte[] sentData;
try (ChannelShell channel = session.createShellChannel();
PipedOutputStream pipedIn = new PipedOutputStream(); | // Path: src/test/java/org/apache/sshd/util/test/JSchLogger.java
// public class JSchLogger implements Logger {
// private final org.slf4j.Logger log = LoggerFactory.getLogger(JSch.class);
//
// public JSchLogger() {
// super();
// }
//
// @Override
// public boolean isEnabled(int level) {
// switch (level) {
// case INFO: // INFO is too "chatty" so we map it to debug
// case DEBUG:
// return log.isDebugEnabled();
// case WARN:
// return log.isWarnEnabled();
// case ERROR:
// return log.isErrorEnabled();
// case FATAL:
// return log.isErrorEnabled();
// default:
// return false;
// }
// }
//
// @Override
// public void log(int level, String message) {
// switch (level) {
// case INFO: // INFO is too "chatty" so we map it to debug
// case DEBUG:
// log.debug(message);
// break;
// case WARN:
// log.warn(message);
// break;
// case ERROR:
// case FATAL:
// log.error(message);
// break;
// default:
// log.error("[LEVEL=" + level + "]: " + message);
// }
// }
//
// public static void init() {
// JSch.setLogger(new JSchLogger());
// }
// }
//
// Path: src/test/java/org/apache/sshd/util/test/OutputCountTrackingOutputStream.java
// public class OutputCountTrackingOutputStream extends FilterOutputStream {
// protected long writeCount;
//
// public OutputCountTrackingOutputStream(OutputStream out) {
// super(out);
// }
//
// @Override
// public void write(int b) throws IOException {
// out.write(b);
// updateWriteCount(1L);
// }
//
// @Override
// public void write(byte[] b, int off, int len) throws IOException {
// out.write(b, off, len); // don't call super since it calls the single 'write'
// updateWriteCount(len);
// }
//
// public long getWriteCount() {
// return writeCount;
// }
//
// protected long updateWriteCount(long delta) {
// writeCount += delta;
// return writeCount;
// }
// }
// Path: src/test/java/org/apache/sshd/KeyReExchangeTest.java
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import com.jcraft.jsch.JSch;
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.channel.ChannelShell;
import org.apache.sshd.client.channel.ClientChannel;
import org.apache.sshd.client.channel.ClientChannelEvent;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.cipher.BuiltinCiphers;
import org.apache.sshd.common.future.KeyExchangeFuture;
import org.apache.sshd.common.kex.BuiltinDHFactories;
import org.apache.sshd.common.kex.KeyExchange;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.SessionListener;
import org.apache.sshd.common.subsystem.sftp.SftpConstants;
import org.apache.sshd.common.util.SecurityUtils;
import org.apache.sshd.common.util.io.NullOutputStream;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.util.test.BaseTestSupport;
import org.apache.sshd.util.test.JSchLogger;
import org.apache.sshd.util.test.OutputCountTrackingOutputStream;
import org.apache.sshd.util.test.SimpleUserInfo;
import org.apache.sshd.util.test.TeeOutputStream;
import org.junit.After;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession();
ByteArrayOutputStream sent = new ByteArrayOutputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream() {
private long writeCount;
@Override
public void write(int b) {
super.write(b);
updateWriteCount(1L);
pipedCount.release(1);
}
@Override
public void write(byte[] b, int off, int len) {
super.write(b, off, len);
updateWriteCount(len);
pipedCount.release(len);
}
private void updateWriteCount(long delta) {
writeCount += delta;
outputDebugMessage("OUT write count=%d", writeCount);
}
}) {
session.addPasswordIdentity(getCurrentTestName());
session.auth().verify(5L, TimeUnit.SECONDS);
byte[] sentData;
try (ChannelShell channel = session.createShellChannel();
PipedOutputStream pipedIn = new PipedOutputStream(); | OutputStream sentTracker = new OutputCountTrackingOutputStream(sent) { |
termd/termd | src/examples/java/examples/ptybridge/SshPtyBridgeExample.java | // Path: src/main/java/io/termd/core/pty/TtyBridge.java
// public class TtyBridge {
//
// Logger log = LoggerFactory.getLogger(TtyBridge.class);
// final TtyConnection conn;
// private Consumer<PtyMaster> processListener;
// private Consumer<int[]> processStdoutListener;
// private Consumer<String> processStdinListener;
//
// public TtyBridge(TtyConnection conn) {
// this.conn = conn;
// }
//
// public Consumer<PtyMaster> getProcessListener() {
// return processListener;
// }
//
// public TtyBridge setProcessListener(Consumer<PtyMaster> processListener) {
// this.processListener = processListener;
// return this;
// }
//
// public Consumer<String> getProcessStdinListener() {
// return processStdinListener;
// }
//
// public TtyBridge setProcessStdinListener(Consumer<String> processStdinListener) {
// this.processStdinListener = processStdinListener;
// return this;
// }
//
// public Consumer<int[]> getProcessStdoutListener() {
// return processStdoutListener;
// }
//
// public TtyBridge setProcessStdoutListener(Consumer<int[]> processStdoutListener) {
// this.processStdoutListener = processStdoutListener;
// return this;
// }
//
// public TtyBridge readline() {
// InputStream inputrc = Keymap.class.getResourceAsStream("inputrc");
// Keymap keymap = new Keymap(inputrc);
// Readline readline = new Readline(keymap);
// for (io.termd.core.readline.Function function : Helper.loadServices(Thread.currentThread().getContextClassLoader(), io.termd.core.readline.Function.class)) {
// log.trace("Server is adding function to readline: {}", function);
//
// readline.addFunction(function);
// }
// conn.setTerminalTypeHandler(term -> {
// // Not used yet but we should propagage this to the process builder
// // System.out.println("CLIENT $TERM=" + term);
// });
// conn.stdoutHandler().accept(Helper.toCodePoints("Welcome sir\n"));
// read(conn, readline);
// return this;
// }
//
// void read(final TtyConnection conn, final Readline readline) {
// readline.readline(conn, "% ", line -> onNewLine(conn, readline, line));
// }
//
// private void onNewLine(TtyConnection conn, Readline readline, String line) {
// if (processStdinListener != null) {
// processStdinListener.accept(line);
// }
// if (line == null) {
// conn.close();
// return;
// }
// PtyMaster task = new PtyMaster(line, buffer -> onStdOut(conn, buffer), empty -> doneHandler(conn, readline));
// conn.setEventHandler((event,cp) -> {
// if (event == TtyEvent.INTR) {
// task.interruptProcess();
// }
// });
// if (processListener != null) {
// processListener.accept(task);
// }
// task.start();
// }
//
// private void doneHandler(TtyConnection conn, Readline readline) {
// conn.setEventHandler(null);
// conn.execute(() -> read(conn, readline));
// }
//
// private void onStdOut(TtyConnection conn, int[] buffer) {
// conn.execute(() -> {
// conn.stdoutHandler().accept(buffer);
// });
// if (processStdoutListener != null) {
// processStdoutListener.accept(buffer);
// }
// }
// }
| import io.termd.core.pty.TtyBridge;
import io.termd.core.ssh.netty.NettySshTtyBootstrap;
import java.util.concurrent.TimeUnit; | /*
* Copyright 2015 Julien Viet
*
* 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 examples.ptybridge;
public class SshPtyBridgeExample {
public synchronized static void main(String[] args) throws Exception {
NettySshTtyBootstrap bootstrap = new NettySshTtyBootstrap().
setPort(5000).
setHost("localhost"); | // Path: src/main/java/io/termd/core/pty/TtyBridge.java
// public class TtyBridge {
//
// Logger log = LoggerFactory.getLogger(TtyBridge.class);
// final TtyConnection conn;
// private Consumer<PtyMaster> processListener;
// private Consumer<int[]> processStdoutListener;
// private Consumer<String> processStdinListener;
//
// public TtyBridge(TtyConnection conn) {
// this.conn = conn;
// }
//
// public Consumer<PtyMaster> getProcessListener() {
// return processListener;
// }
//
// public TtyBridge setProcessListener(Consumer<PtyMaster> processListener) {
// this.processListener = processListener;
// return this;
// }
//
// public Consumer<String> getProcessStdinListener() {
// return processStdinListener;
// }
//
// public TtyBridge setProcessStdinListener(Consumer<String> processStdinListener) {
// this.processStdinListener = processStdinListener;
// return this;
// }
//
// public Consumer<int[]> getProcessStdoutListener() {
// return processStdoutListener;
// }
//
// public TtyBridge setProcessStdoutListener(Consumer<int[]> processStdoutListener) {
// this.processStdoutListener = processStdoutListener;
// return this;
// }
//
// public TtyBridge readline() {
// InputStream inputrc = Keymap.class.getResourceAsStream("inputrc");
// Keymap keymap = new Keymap(inputrc);
// Readline readline = new Readline(keymap);
// for (io.termd.core.readline.Function function : Helper.loadServices(Thread.currentThread().getContextClassLoader(), io.termd.core.readline.Function.class)) {
// log.trace("Server is adding function to readline: {}", function);
//
// readline.addFunction(function);
// }
// conn.setTerminalTypeHandler(term -> {
// // Not used yet but we should propagage this to the process builder
// // System.out.println("CLIENT $TERM=" + term);
// });
// conn.stdoutHandler().accept(Helper.toCodePoints("Welcome sir\n"));
// read(conn, readline);
// return this;
// }
//
// void read(final TtyConnection conn, final Readline readline) {
// readline.readline(conn, "% ", line -> onNewLine(conn, readline, line));
// }
//
// private void onNewLine(TtyConnection conn, Readline readline, String line) {
// if (processStdinListener != null) {
// processStdinListener.accept(line);
// }
// if (line == null) {
// conn.close();
// return;
// }
// PtyMaster task = new PtyMaster(line, buffer -> onStdOut(conn, buffer), empty -> doneHandler(conn, readline));
// conn.setEventHandler((event,cp) -> {
// if (event == TtyEvent.INTR) {
// task.interruptProcess();
// }
// });
// if (processListener != null) {
// processListener.accept(task);
// }
// task.start();
// }
//
// private void doneHandler(TtyConnection conn, Readline readline) {
// conn.setEventHandler(null);
// conn.execute(() -> read(conn, readline));
// }
//
// private void onStdOut(TtyConnection conn, int[] buffer) {
// conn.execute(() -> {
// conn.stdoutHandler().accept(buffer);
// });
// if (processStdoutListener != null) {
// processStdoutListener.accept(buffer);
// }
// }
// }
// Path: src/examples/java/examples/ptybridge/SshPtyBridgeExample.java
import io.termd.core.pty.TtyBridge;
import io.termd.core.ssh.netty.NettySshTtyBootstrap;
import java.util.concurrent.TimeUnit;
/*
* Copyright 2015 Julien Viet
*
* 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 examples.ptybridge;
public class SshPtyBridgeExample {
public synchronized static void main(String[] args) throws Exception {
NettySshTtyBootstrap bootstrap = new NettySshTtyBootstrap().
setPort(5000).
setHost("localhost"); | bootstrap.start(conn -> new TtyBridge(conn).readline()).get(10, TimeUnit.SECONDS); |
jsksxs360/AHANLP | src/me/xiaosheng/chnlp/addition/WordCloud.java | // Path: src/me/xiaosheng/chnlp/Config.java
// public class Config {
//
// private static String configFilePath = "ahanlp.properties";
// private static Properties props = new Properties();
// static {
// try {
// ClassLoader loader = Thread.currentThread().getContextClassLoader();
// if (loader == null) loader = Config.class.getClassLoader();
// props.load(new InputStreamReader(loader.getResourceAsStream(configFilePath), "UTF-8"));
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// /**
// * word2vec模型路径
// *
// * @return
// */
// public static String word2vecModelPath() {
// return props.getProperty("word2vecModel");
// }
//
// /**
// * HanLDA模型路径
// *
// * @return
// */
// public static String hanLDAModelPath() {
// return props.getProperty("hanLDAModel");
// }
//
// /**
// * SRL模型路径
// *
// * @return
// */
// public static String srlTaggerModelPath() {
// return props.getProperty("srlTaggerModel");
// }
//
// public static String srlParserModelPath() {
// return props.getProperty("srlParserModel");
// }
//
// public static String srlModelPath() {
// return props.getProperty("srlModel");
// }
//
// /**
// * word cloud文件目录
// *
// * @return
// */
// public static String wordCloudPath() {
// return props.getProperty("wordCloudPath");
// }
//
// /**
// * python 调用命令
// *
// * @return
// */
// public static String pythonCMD() {
// return props.getProperty("pythonCMD");
// }
// }
| import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import me.xiaosheng.chnlp.Config; | package me.xiaosheng.chnlp.addition;
public class WordCloud {
private List<String> wordList = null;
public WordCloud(List<String> wordList) {
this.wordList = wordList;
}
/**
* 绘制词云图片
* @param savePicPath 图片存储路径
* @throws IOException
*/
public void createImage(String savePicPath) throws IOException {
createImage(savePicPath, 500, 400, false);
}
/**
* 绘制词云图片
* @param savePicPath 图片存储路径
* @param blackBackground 是否使用黑色背景
* @throws IOException
*/
public void createImage(String savePicPath, boolean blackBackground) throws IOException {
createImage(savePicPath, 500, 400, true);
}
/**
* 绘制词云图片
* @param savePicPath 图片存储路径
* @param picWidth 图片宽度
* @param picHeight 图片高度
* @throws IOException
*/
public void createImage(String savePicPath, int picWidth, int picHeight) throws IOException {
createImage(savePicPath, picWidth, picHeight, false);
}
/**
* 绘制词云图片
* @param savePicPath 图片存储路径
* @param picWidth 图片宽度
* @param picHeight 图片高度
* @param blackBackground 是否使用黑色背景
* @throws IOException
*/
public void createImage(String savePicPath, int picWidth, int picHeight, boolean blackBackground) throws IOException {
String tempFileName = UUID.randomUUID().toString();
// 生成临时词语文件 | // Path: src/me/xiaosheng/chnlp/Config.java
// public class Config {
//
// private static String configFilePath = "ahanlp.properties";
// private static Properties props = new Properties();
// static {
// try {
// ClassLoader loader = Thread.currentThread().getContextClassLoader();
// if (loader == null) loader = Config.class.getClassLoader();
// props.load(new InputStreamReader(loader.getResourceAsStream(configFilePath), "UTF-8"));
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// /**
// * word2vec模型路径
// *
// * @return
// */
// public static String word2vecModelPath() {
// return props.getProperty("word2vecModel");
// }
//
// /**
// * HanLDA模型路径
// *
// * @return
// */
// public static String hanLDAModelPath() {
// return props.getProperty("hanLDAModel");
// }
//
// /**
// * SRL模型路径
// *
// * @return
// */
// public static String srlTaggerModelPath() {
// return props.getProperty("srlTaggerModel");
// }
//
// public static String srlParserModelPath() {
// return props.getProperty("srlParserModel");
// }
//
// public static String srlModelPath() {
// return props.getProperty("srlModel");
// }
//
// /**
// * word cloud文件目录
// *
// * @return
// */
// public static String wordCloudPath() {
// return props.getProperty("wordCloudPath");
// }
//
// /**
// * python 调用命令
// *
// * @return
// */
// public static String pythonCMD() {
// return props.getProperty("pythonCMD");
// }
// }
// Path: src/me/xiaosheng/chnlp/addition/WordCloud.java
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import me.xiaosheng.chnlp.Config;
package me.xiaosheng.chnlp.addition;
public class WordCloud {
private List<String> wordList = null;
public WordCloud(List<String> wordList) {
this.wordList = wordList;
}
/**
* 绘制词云图片
* @param savePicPath 图片存储路径
* @throws IOException
*/
public void createImage(String savePicPath) throws IOException {
createImage(savePicPath, 500, 400, false);
}
/**
* 绘制词云图片
* @param savePicPath 图片存储路径
* @param blackBackground 是否使用黑色背景
* @throws IOException
*/
public void createImage(String savePicPath, boolean blackBackground) throws IOException {
createImage(savePicPath, 500, 400, true);
}
/**
* 绘制词云图片
* @param savePicPath 图片存储路径
* @param picWidth 图片宽度
* @param picHeight 图片高度
* @throws IOException
*/
public void createImage(String savePicPath, int picWidth, int picHeight) throws IOException {
createImage(savePicPath, picWidth, picHeight, false);
}
/**
* 绘制词云图片
* @param savePicPath 图片存储路径
* @param picWidth 图片宽度
* @param picHeight 图片高度
* @param blackBackground 是否使用黑色背景
* @throws IOException
*/
public void createImage(String savePicPath, int picWidth, int picHeight, boolean blackBackground) throws IOException {
String tempFileName = UUID.randomUUID().toString();
// 生成临时词语文件 | BufferedWriter bw = new BufferedWriter(new FileWriter(Config.wordCloudPath() + tempFileName)); |
googleapis/java-core | google-cloud-core/src/test/java/com/google/cloud/PolicyTest.java | // Path: google-cloud-core/src/main/java/com/google/cloud/Policy.java
// public static class DefaultMarshaller extends Marshaller<com.google.iam.v1.Policy> {
//
// @Override
// protected Policy fromPb(com.google.iam.v1.Policy policyPb) {
// ImmutableList.Builder<Binding> bindingsListBuilder = ImmutableList.builder();
// for (com.google.iam.v1.Binding bindingPb : policyPb.getBindingsList()) {
// Binding.Builder convertedBinding =
// Binding.newBuilder()
// .setRole(bindingPb.getRole())
// .setMembers(bindingPb.getMembersList());
// if (bindingPb.hasCondition()) {
// Expr expr = bindingPb.getCondition();
// convertedBinding.setCondition(
// Condition.newBuilder()
// .setTitle(expr.getTitle())
// .setDescription(expr.getDescription())
// .setExpression(expr.getExpression())
// .build());
// }
// bindingsListBuilder.add(convertedBinding.build());
// }
// return newBuilder()
// .setBindings(bindingsListBuilder.build())
// .setEtag(
// policyPb.getEtag().isEmpty()
// ? null
// : BaseEncoding.base64().encode(policyPb.getEtag().toByteArray()))
// .setVersion(policyPb.getVersion())
// .build();
// }
//
// @Override
// protected com.google.iam.v1.Policy toPb(Policy policy) {
// com.google.iam.v1.Policy.Builder policyBuilder = com.google.iam.v1.Policy.newBuilder();
// List<com.google.iam.v1.Binding> bindingPbList = new LinkedList<>();
// for (Binding binding : policy.getBindingsList()) {
// com.google.iam.v1.Binding.Builder bindingBuilder = com.google.iam.v1.Binding.newBuilder();
// bindingBuilder.setRole(binding.getRole());
// bindingBuilder.addAllMembers(binding.getMembers());
// if (binding.getCondition() != null) {
// Condition condition = binding.getCondition();
// bindingBuilder.setCondition(
// Expr.newBuilder()
// .setTitle(condition.getTitle())
// .setDescription(condition.getDescription())
// .setExpression(condition.getExpression())
// .build());
// }
// bindingPbList.add(bindingBuilder.build());
// }
// policyBuilder.addAllBindings(bindingPbList);
// if (policy.etag != null) {
// policyBuilder.setEtag(ByteString.copyFrom(BaseEncoding.base64().decode(policy.etag)));
// }
// policyBuilder.setVersion(policy.version);
// return policyBuilder.build();
// }
// }
| import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.cloud.Policy.DefaultMarshaller;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set; | Policy anotherPolicy = Policy.newBuilder().build();
assertEquals(emptyPolicy, anotherPolicy);
assertEquals(emptyPolicy.hashCode(), anotherPolicy.hashCode());
assertNotEquals(FULL_POLICY, SIMPLE_POLICY);
assertNotEquals(FULL_POLICY.hashCode(), SIMPLE_POLICY.hashCode());
Policy copy = SIMPLE_POLICY.toBuilder().build();
assertEquals(SIMPLE_POLICY, copy);
assertEquals(SIMPLE_POLICY.hashCode(), copy.hashCode());
}
@Test
public void testBindings() {
assertTrue(Policy.newBuilder().build().getBindings().isEmpty());
assertEquals(BINDINGS, SIMPLE_POLICY.getBindings());
}
@Test
public void testEtag() {
assertNull(SIMPLE_POLICY.getEtag());
assertEquals("etag", FULL_POLICY.getEtag());
}
@Test
public void testVersion() {
assertEquals(0, SIMPLE_POLICY.getVersion());
assertEquals(1, FULL_POLICY.getVersion());
}
@Test
public void testDefaultMarshaller() { | // Path: google-cloud-core/src/main/java/com/google/cloud/Policy.java
// public static class DefaultMarshaller extends Marshaller<com.google.iam.v1.Policy> {
//
// @Override
// protected Policy fromPb(com.google.iam.v1.Policy policyPb) {
// ImmutableList.Builder<Binding> bindingsListBuilder = ImmutableList.builder();
// for (com.google.iam.v1.Binding bindingPb : policyPb.getBindingsList()) {
// Binding.Builder convertedBinding =
// Binding.newBuilder()
// .setRole(bindingPb.getRole())
// .setMembers(bindingPb.getMembersList());
// if (bindingPb.hasCondition()) {
// Expr expr = bindingPb.getCondition();
// convertedBinding.setCondition(
// Condition.newBuilder()
// .setTitle(expr.getTitle())
// .setDescription(expr.getDescription())
// .setExpression(expr.getExpression())
// .build());
// }
// bindingsListBuilder.add(convertedBinding.build());
// }
// return newBuilder()
// .setBindings(bindingsListBuilder.build())
// .setEtag(
// policyPb.getEtag().isEmpty()
// ? null
// : BaseEncoding.base64().encode(policyPb.getEtag().toByteArray()))
// .setVersion(policyPb.getVersion())
// .build();
// }
//
// @Override
// protected com.google.iam.v1.Policy toPb(Policy policy) {
// com.google.iam.v1.Policy.Builder policyBuilder = com.google.iam.v1.Policy.newBuilder();
// List<com.google.iam.v1.Binding> bindingPbList = new LinkedList<>();
// for (Binding binding : policy.getBindingsList()) {
// com.google.iam.v1.Binding.Builder bindingBuilder = com.google.iam.v1.Binding.newBuilder();
// bindingBuilder.setRole(binding.getRole());
// bindingBuilder.addAllMembers(binding.getMembers());
// if (binding.getCondition() != null) {
// Condition condition = binding.getCondition();
// bindingBuilder.setCondition(
// Expr.newBuilder()
// .setTitle(condition.getTitle())
// .setDescription(condition.getDescription())
// .setExpression(condition.getExpression())
// .build());
// }
// bindingPbList.add(bindingBuilder.build());
// }
// policyBuilder.addAllBindings(bindingPbList);
// if (policy.etag != null) {
// policyBuilder.setEtag(ByteString.copyFrom(BaseEncoding.base64().decode(policy.etag)));
// }
// policyBuilder.setVersion(policy.version);
// return policyBuilder.build();
// }
// }
// Path: google-cloud-core/src/test/java/com/google/cloud/PolicyTest.java
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.cloud.Policy.DefaultMarshaller;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Policy anotherPolicy = Policy.newBuilder().build();
assertEquals(emptyPolicy, anotherPolicy);
assertEquals(emptyPolicy.hashCode(), anotherPolicy.hashCode());
assertNotEquals(FULL_POLICY, SIMPLE_POLICY);
assertNotEquals(FULL_POLICY.hashCode(), SIMPLE_POLICY.hashCode());
Policy copy = SIMPLE_POLICY.toBuilder().build();
assertEquals(SIMPLE_POLICY, copy);
assertEquals(SIMPLE_POLICY.hashCode(), copy.hashCode());
}
@Test
public void testBindings() {
assertTrue(Policy.newBuilder().build().getBindings().isEmpty());
assertEquals(BINDINGS, SIMPLE_POLICY.getBindings());
}
@Test
public void testEtag() {
assertNull(SIMPLE_POLICY.getEtag());
assertEquals("etag", FULL_POLICY.getEtag());
}
@Test
public void testVersion() {
assertEquals(0, SIMPLE_POLICY.getVersion());
assertEquals(1, FULL_POLICY.getVersion());
}
@Test
public void testDefaultMarshaller() { | DefaultMarshaller marshaller = new DefaultMarshaller(); |
googleapis/java-core | google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/GrpcTransportOptionsTest.java | // Path: google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java
// @InternalApi
// public static class DefaultExecutorFactory implements ExecutorFactory<ScheduledExecutorService> {
//
// private static final DefaultExecutorFactory INSTANCE = new DefaultExecutorFactory();
//
// @Override
// public ScheduledExecutorService get() {
// return SharedResourceHolder.get(EXECUTOR);
// }
//
// @Override
// public synchronized void release(ScheduledExecutorService executor) {
// SharedResourceHolder.release(EXECUTOR, executor);
// }
// }
//
// Path: google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java
// public interface ExecutorFactory<T extends ExecutorService> {
//
// /** Gets an executor service instance. */
// T get();
//
// /** Releases resources used by the executor and possibly shuts it down. */
// void release(T executor);
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import com.google.cloud.grpc.GrpcTransportOptions.DefaultExecutorFactory;
import com.google.cloud.grpc.GrpcTransportOptions.ExecutorFactory;
import java.util.concurrent.ScheduledExecutorService;
import org.easymock.EasyMock;
import org.junit.Test; | /*
* Copyright 2016 Google LLC
*
* 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.google.cloud.grpc;
public class GrpcTransportOptionsTest {
private static final ExecutorFactory MOCK_EXECUTOR_FACTORY =
EasyMock.createMock(ExecutorFactory.class);
private static final GrpcTransportOptions OPTIONS =
GrpcTransportOptions.newBuilder().setExecutorFactory(MOCK_EXECUTOR_FACTORY).build();
private static final GrpcTransportOptions DEFAULT_OPTIONS =
GrpcTransportOptions.newBuilder().build();
private static final GrpcTransportOptions OPTIONS_COPY = OPTIONS.toBuilder().build();
@Test
public void testBuilder() {
assertSame(MOCK_EXECUTOR_FACTORY, OPTIONS.getExecutorFactory()); | // Path: google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java
// @InternalApi
// public static class DefaultExecutorFactory implements ExecutorFactory<ScheduledExecutorService> {
//
// private static final DefaultExecutorFactory INSTANCE = new DefaultExecutorFactory();
//
// @Override
// public ScheduledExecutorService get() {
// return SharedResourceHolder.get(EXECUTOR);
// }
//
// @Override
// public synchronized void release(ScheduledExecutorService executor) {
// SharedResourceHolder.release(EXECUTOR, executor);
// }
// }
//
// Path: google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java
// public interface ExecutorFactory<T extends ExecutorService> {
//
// /** Gets an executor service instance. */
// T get();
//
// /** Releases resources used by the executor and possibly shuts it down. */
// void release(T executor);
// }
// Path: google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/GrpcTransportOptionsTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import com.google.cloud.grpc.GrpcTransportOptions.DefaultExecutorFactory;
import com.google.cloud.grpc.GrpcTransportOptions.ExecutorFactory;
import java.util.concurrent.ScheduledExecutorService;
import org.easymock.EasyMock;
import org.junit.Test;
/*
* Copyright 2016 Google LLC
*
* 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.google.cloud.grpc;
public class GrpcTransportOptionsTest {
private static final ExecutorFactory MOCK_EXECUTOR_FACTORY =
EasyMock.createMock(ExecutorFactory.class);
private static final GrpcTransportOptions OPTIONS =
GrpcTransportOptions.newBuilder().setExecutorFactory(MOCK_EXECUTOR_FACTORY).build();
private static final GrpcTransportOptions DEFAULT_OPTIONS =
GrpcTransportOptions.newBuilder().build();
private static final GrpcTransportOptions OPTIONS_COPY = OPTIONS.toBuilder().build();
@Test
public void testBuilder() {
assertSame(MOCK_EXECUTOR_FACTORY, OPTIONS.getExecutorFactory()); | assertTrue(DEFAULT_OPTIONS.getExecutorFactory() instanceof DefaultExecutorFactory); |
googleapis/java-core | google-cloud-core/src/main/java/com/google/cloud/BaseService.java | // Path: google-cloud-core/src/main/java/com/google/cloud/ExceptionHandler.java
// public interface Interceptor extends Serializable {
//
// enum RetryResult {
// NO_RETRY,
// RETRY,
// CONTINUE_EVALUATION;
// }
//
// /**
// * This method is called before exception evaluation and could short-circuit the process.
// *
// * @param exception the exception that is being evaluated
// * @return {@link RetryResult} to indicate if the exception should be ignored ( {@link
// * RetryResult#RETRY}), propagated ({@link RetryResult#NO_RETRY}), or evaluation should
// * proceed ({@link RetryResult#CONTINUE_EVALUATION}).
// */
// RetryResult beforeEval(Exception exception);
//
// /**
// * This method is called after the evaluation and could alter its result.
// *
// * @param exception the exception that is being evaluated
// * @param retryResult the result of the evaluation so far
// * @return {@link RetryResult} to indicate if the exception should be ignored ( {@link
// * RetryResult#RETRY}), propagated ({@link RetryResult#NO_RETRY}), or evaluation should
// * proceed ({@link RetryResult#CONTINUE_EVALUATION}).
// */
// RetryResult afterEval(Exception exception, RetryResult retryResult);
// }
| import com.google.api.core.InternalApi;
import com.google.cloud.ExceptionHandler.Interceptor; | /*
* Copyright 2015 Google LLC
*
* 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.google.cloud;
/**
* Base class for service objects.
*
* @param <OptionsT> the {@code ServiceOptions} subclass corresponding to the service
*/
public abstract class BaseService<OptionsT extends ServiceOptions<?, OptionsT>>
implements Service<OptionsT> {
| // Path: google-cloud-core/src/main/java/com/google/cloud/ExceptionHandler.java
// public interface Interceptor extends Serializable {
//
// enum RetryResult {
// NO_RETRY,
// RETRY,
// CONTINUE_EVALUATION;
// }
//
// /**
// * This method is called before exception evaluation and could short-circuit the process.
// *
// * @param exception the exception that is being evaluated
// * @return {@link RetryResult} to indicate if the exception should be ignored ( {@link
// * RetryResult#RETRY}), propagated ({@link RetryResult#NO_RETRY}), or evaluation should
// * proceed ({@link RetryResult#CONTINUE_EVALUATION}).
// */
// RetryResult beforeEval(Exception exception);
//
// /**
// * This method is called after the evaluation and could alter its result.
// *
// * @param exception the exception that is being evaluated
// * @param retryResult the result of the evaluation so far
// * @return {@link RetryResult} to indicate if the exception should be ignored ( {@link
// * RetryResult#RETRY}), propagated ({@link RetryResult#NO_RETRY}), or evaluation should
// * proceed ({@link RetryResult#CONTINUE_EVALUATION}).
// */
// RetryResult afterEval(Exception exception, RetryResult retryResult);
// }
// Path: google-cloud-core/src/main/java/com/google/cloud/BaseService.java
import com.google.api.core.InternalApi;
import com.google.cloud.ExceptionHandler.Interceptor;
/*
* Copyright 2015 Google LLC
*
* 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.google.cloud;
/**
* Base class for service objects.
*
* @param <OptionsT> the {@code ServiceOptions} subclass corresponding to the service
*/
public abstract class BaseService<OptionsT extends ServiceOptions<?, OptionsT>>
implements Service<OptionsT> {
| public static final Interceptor EXCEPTION_HANDLER_INTERCEPTOR = |
googleapis/java-core | google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java | // Path: google-cloud-core/src/main/java/com/google/cloud/spi/ServiceRpcFactory.java
// @SuppressWarnings("rawtypes")
// public interface ServiceRpcFactory<OptionsT extends ServiceOptions> {
//
// ServiceRpc create(OptionsT options);
// }
| import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.GenericJson;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.JsonObjectParser;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.core.ApiClock;
import com.google.api.core.BetaApi;
import com.google.api.core.CurrentMillisClock;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.GaxProperties;
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.rpc.FixedHeaderProvider;
import com.google.api.gax.rpc.HeaderProvider;
import com.google.api.gax.rpc.NoHeaderProvider;
import com.google.auth.Credentials;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.auth.oauth2.QuotaProjectIdProvider;
import com.google.auth.oauth2.ServiceAccountCredentials;
import com.google.cloud.spi.ServiceRpcFactory;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.io.Files;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.threeten.bp.Duration; | /*
* Copyright 2015 Google LLC
*
* 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.google.cloud;
/**
* Abstract class representing service options.
*
* @param <ServiceT> the service subclass
* @param <OptionsT> the {@code ServiceOptions} subclass corresponding to the service
*/
public abstract class ServiceOptions<
ServiceT extends Service<OptionsT>, OptionsT extends ServiceOptions<ServiceT, OptionsT>>
implements Serializable {
public static final String CREDENTIAL_ENV_NAME = "GOOGLE_APPLICATION_CREDENTIALS";
private static final String DEFAULT_HOST = "https://www.googleapis.com";
private static final String LEGACY_PROJECT_ENV_NAME = "GCLOUD_PROJECT";
private static final String PROJECT_ENV_NAME = "GOOGLE_CLOUD_PROJECT";
private static final RetrySettings DEFAULT_RETRY_SETTINGS =
getDefaultRetrySettingsBuilder().build();
private static final RetrySettings NO_RETRY_SETTINGS =
getDefaultRetrySettingsBuilder().setMaxAttempts(1).build();
private static final long serialVersionUID = 9198896031667942014L;
protected final String clientLibToken;
private final String projectId;
private final String host;
private final RetrySettings retrySettings;
private final String serviceRpcFactoryClassName;
private final String serviceFactoryClassName;
private final ApiClock clock;
protected Credentials credentials;
private final TransportOptions transportOptions;
private final HeaderProvider headerProvider;
private final String quotaProjectId;
| // Path: google-cloud-core/src/main/java/com/google/cloud/spi/ServiceRpcFactory.java
// @SuppressWarnings("rawtypes")
// public interface ServiceRpcFactory<OptionsT extends ServiceOptions> {
//
// ServiceRpc create(OptionsT options);
// }
// Path: google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java
import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.GenericJson;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.JsonObjectParser;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.core.ApiClock;
import com.google.api.core.BetaApi;
import com.google.api.core.CurrentMillisClock;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.GaxProperties;
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.rpc.FixedHeaderProvider;
import com.google.api.gax.rpc.HeaderProvider;
import com.google.api.gax.rpc.NoHeaderProvider;
import com.google.auth.Credentials;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.auth.oauth2.QuotaProjectIdProvider;
import com.google.auth.oauth2.ServiceAccountCredentials;
import com.google.cloud.spi.ServiceRpcFactory;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.io.Files;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.threeten.bp.Duration;
/*
* Copyright 2015 Google LLC
*
* 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.google.cloud;
/**
* Abstract class representing service options.
*
* @param <ServiceT> the service subclass
* @param <OptionsT> the {@code ServiceOptions} subclass corresponding to the service
*/
public abstract class ServiceOptions<
ServiceT extends Service<OptionsT>, OptionsT extends ServiceOptions<ServiceT, OptionsT>>
implements Serializable {
public static final String CREDENTIAL_ENV_NAME = "GOOGLE_APPLICATION_CREDENTIALS";
private static final String DEFAULT_HOST = "https://www.googleapis.com";
private static final String LEGACY_PROJECT_ENV_NAME = "GCLOUD_PROJECT";
private static final String PROJECT_ENV_NAME = "GOOGLE_CLOUD_PROJECT";
private static final RetrySettings DEFAULT_RETRY_SETTINGS =
getDefaultRetrySettingsBuilder().build();
private static final RetrySettings NO_RETRY_SETTINGS =
getDefaultRetrySettingsBuilder().setMaxAttempts(1).build();
private static final long serialVersionUID = 9198896031667942014L;
protected final String clientLibToken;
private final String projectId;
private final String host;
private final RetrySettings retrySettings;
private final String serviceRpcFactoryClassName;
private final String serviceFactoryClassName;
private final ApiClock clock;
protected Credentials credentials;
private final TransportOptions transportOptions;
private final HeaderProvider headerProvider;
private final String quotaProjectId;
| private transient ServiceRpcFactory<OptionsT> serviceRpcFactory; |
googleapis/java-core | google-cloud-core/src/test/java/com/google/cloud/testing/junit4/tests/MultipleAttemptsRuleTest.java | // Path: google-cloud-core/src/test/java/com/google/cloud/testing/junit4/MultipleAttemptsRule.java
// public final class MultipleAttemptsRule implements TestRule {
// private final long initialBackoffMillis;
// private final int maxAttemptCount;
//
// /**
// * Construct a {@link MultipleAttemptsRule} which will attempt a test up to {@code attemptCount}
// * times before ultimately reporting failure of the test.
// *
// * <p>The initialBackoffMillis will be set to 1000L.
// *
// * @param maxAttemptCount max number of attempts before reporting failure, must be greater than 0
// * @see #MultipleAttemptsRule(int, long)
// */
// public MultipleAttemptsRule(int maxAttemptCount) {
// this(maxAttemptCount, 1000L);
// }
//
// /**
// * Construct a {@link MultipleAttemptsRule} which will attempt a test up to {@code attemptCount}
// * times before ultimately reporting failure of the test.
// *
// * <p>The {@code initialBackoffMillis} will be used as the first pause duration before
// * reattempting the test.
// *
// * @param maxAttemptCount max number of attempts before reporting failure, must be greater than 0
// * @param initialBackoffMillis initial duration in millis to wait between attempts, must be
// * greater than or equal to 0
// */
// public MultipleAttemptsRule(int maxAttemptCount, long initialBackoffMillis) {
// checkArgument(maxAttemptCount > 0, "attemptCount must be > 0");
// checkArgument(initialBackoffMillis >= 0, "initialBackoffMillis must be >= 0");
// this.initialBackoffMillis = initialBackoffMillis;
// this.maxAttemptCount = maxAttemptCount;
// }
//
// @Override
// public Statement apply(final Statement base, Description description) {
// return new Statement() {
// @Override
// public void evaluate() throws Throwable {
// List<Throwable> failures = new ArrayList<>();
//
// long retryIntervalMillis = initialBackoffMillis;
//
// for (int i = 1; i <= maxAttemptCount; i++) {
// try {
// base.evaluate();
// return;
// } catch (Throwable t) {
// failures.add(t);
// Thread.sleep(retryIntervalMillis);
// retryIntervalMillis *= 1.5f;
// }
// }
//
// MultipleFailureException.assertEmpty(failures);
// }
// };
// }
// }
| import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runners.model.MultipleFailureException;
import org.junit.runners.model.Statement; | /*
* Copyright 2020 Google LLC
*
* 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.google.cloud.testing.junit4.tests;
public final class MultipleAttemptsRuleTest {
private static final int NUMBER_OF_ATTEMPTS = 5;
| // Path: google-cloud-core/src/test/java/com/google/cloud/testing/junit4/MultipleAttemptsRule.java
// public final class MultipleAttemptsRule implements TestRule {
// private final long initialBackoffMillis;
// private final int maxAttemptCount;
//
// /**
// * Construct a {@link MultipleAttemptsRule} which will attempt a test up to {@code attemptCount}
// * times before ultimately reporting failure of the test.
// *
// * <p>The initialBackoffMillis will be set to 1000L.
// *
// * @param maxAttemptCount max number of attempts before reporting failure, must be greater than 0
// * @see #MultipleAttemptsRule(int, long)
// */
// public MultipleAttemptsRule(int maxAttemptCount) {
// this(maxAttemptCount, 1000L);
// }
//
// /**
// * Construct a {@link MultipleAttemptsRule} which will attempt a test up to {@code attemptCount}
// * times before ultimately reporting failure of the test.
// *
// * <p>The {@code initialBackoffMillis} will be used as the first pause duration before
// * reattempting the test.
// *
// * @param maxAttemptCount max number of attempts before reporting failure, must be greater than 0
// * @param initialBackoffMillis initial duration in millis to wait between attempts, must be
// * greater than or equal to 0
// */
// public MultipleAttemptsRule(int maxAttemptCount, long initialBackoffMillis) {
// checkArgument(maxAttemptCount > 0, "attemptCount must be > 0");
// checkArgument(initialBackoffMillis >= 0, "initialBackoffMillis must be >= 0");
// this.initialBackoffMillis = initialBackoffMillis;
// this.maxAttemptCount = maxAttemptCount;
// }
//
// @Override
// public Statement apply(final Statement base, Description description) {
// return new Statement() {
// @Override
// public void evaluate() throws Throwable {
// List<Throwable> failures = new ArrayList<>();
//
// long retryIntervalMillis = initialBackoffMillis;
//
// for (int i = 1; i <= maxAttemptCount; i++) {
// try {
// base.evaluate();
// return;
// } catch (Throwable t) {
// failures.add(t);
// Thread.sleep(retryIntervalMillis);
// retryIntervalMillis *= 1.5f;
// }
// }
//
// MultipleFailureException.assertEmpty(failures);
// }
// };
// }
// }
// Path: google-cloud-core/src/test/java/com/google/cloud/testing/junit4/tests/MultipleAttemptsRuleTest.java
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runners.model.MultipleFailureException;
import org.junit.runners.model.Statement;
/*
* Copyright 2020 Google LLC
*
* 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.google.cloud.testing.junit4.tests;
public final class MultipleAttemptsRuleTest {
private static final int NUMBER_OF_ATTEMPTS = 5;
| @Rule public MultipleAttemptsRule rr = new MultipleAttemptsRule(NUMBER_OF_ATTEMPTS, 0); |
googleapis/java-core | google-cloud-core/src/test/java/com/google/cloud/ServiceOptionsTest.java | // Path: google-cloud-core/src/main/java/com/google/cloud/spi/ServiceRpcFactory.java
// @SuppressWarnings("rawtypes")
// public interface ServiceRpcFactory<OptionsT extends ServiceOptions> {
//
// ServiceRpc create(OptionsT options);
// }
| import static com.google.common.truth.Truth.assertThat;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.LowLevelHttpRequest;
import com.google.api.client.http.LowLevelHttpResponse;
import com.google.api.client.testing.http.HttpTesting;
import com.google.api.client.testing.http.MockHttpTransport;
import com.google.api.client.testing.http.MockLowLevelHttpRequest;
import com.google.api.client.testing.http.MockLowLevelHttpResponse;
import com.google.api.core.ApiClock;
import com.google.api.core.CurrentMillisClock;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.spi.ServiceRpcFactory;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.io.Files;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import org.junit.Test; | public long nanoTime() {
return 123_456_789_000_000L;
}
@Override
public long millisTime() {
return 123_456_789L;
}
}
interface TestService extends Service<TestServiceOptions> {}
private static class TestServiceImpl extends BaseService<TestServiceOptions>
implements TestService {
private TestServiceImpl(TestServiceOptions options) {
super(options);
}
}
public interface TestServiceFactory extends ServiceFactory<TestService, TestServiceOptions> {}
private static class DefaultTestServiceFactory implements TestServiceFactory {
private static final TestServiceFactory INSTANCE = new DefaultTestServiceFactory();
@Override
public TestService create(TestServiceOptions options) {
return new TestServiceImpl(options);
}
}
| // Path: google-cloud-core/src/main/java/com/google/cloud/spi/ServiceRpcFactory.java
// @SuppressWarnings("rawtypes")
// public interface ServiceRpcFactory<OptionsT extends ServiceOptions> {
//
// ServiceRpc create(OptionsT options);
// }
// Path: google-cloud-core/src/test/java/com/google/cloud/ServiceOptionsTest.java
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.LowLevelHttpRequest;
import com.google.api.client.http.LowLevelHttpResponse;
import com.google.api.client.testing.http.HttpTesting;
import com.google.api.client.testing.http.MockHttpTransport;
import com.google.api.client.testing.http.MockLowLevelHttpRequest;
import com.google.api.client.testing.http.MockLowLevelHttpResponse;
import com.google.api.core.ApiClock;
import com.google.api.core.CurrentMillisClock;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.spi.ServiceRpcFactory;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.io.Files;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import org.junit.Test;
public long nanoTime() {
return 123_456_789_000_000L;
}
@Override
public long millisTime() {
return 123_456_789L;
}
}
interface TestService extends Service<TestServiceOptions> {}
private static class TestServiceImpl extends BaseService<TestServiceOptions>
implements TestService {
private TestServiceImpl(TestServiceOptions options) {
super(options);
}
}
public interface TestServiceFactory extends ServiceFactory<TestService, TestServiceOptions> {}
private static class DefaultTestServiceFactory implements TestServiceFactory {
private static final TestServiceFactory INSTANCE = new DefaultTestServiceFactory();
@Override
public TestService create(TestServiceOptions options) {
return new TestServiceImpl(options);
}
}
| public interface TestServiceRpcFactory extends ServiceRpcFactory<TestServiceOptions> {} |
googleapis/java-core | google-cloud-core/src/test/java/com/google/cloud/PolicyV3Test.java | // Path: google-cloud-core/src/main/java/com/google/cloud/Policy.java
// public static class DefaultMarshaller extends Marshaller<com.google.iam.v1.Policy> {
//
// @Override
// protected Policy fromPb(com.google.iam.v1.Policy policyPb) {
// ImmutableList.Builder<Binding> bindingsListBuilder = ImmutableList.builder();
// for (com.google.iam.v1.Binding bindingPb : policyPb.getBindingsList()) {
// Binding.Builder convertedBinding =
// Binding.newBuilder()
// .setRole(bindingPb.getRole())
// .setMembers(bindingPb.getMembersList());
// if (bindingPb.hasCondition()) {
// Expr expr = bindingPb.getCondition();
// convertedBinding.setCondition(
// Condition.newBuilder()
// .setTitle(expr.getTitle())
// .setDescription(expr.getDescription())
// .setExpression(expr.getExpression())
// .build());
// }
// bindingsListBuilder.add(convertedBinding.build());
// }
// return newBuilder()
// .setBindings(bindingsListBuilder.build())
// .setEtag(
// policyPb.getEtag().isEmpty()
// ? null
// : BaseEncoding.base64().encode(policyPb.getEtag().toByteArray()))
// .setVersion(policyPb.getVersion())
// .build();
// }
//
// @Override
// protected com.google.iam.v1.Policy toPb(Policy policy) {
// com.google.iam.v1.Policy.Builder policyBuilder = com.google.iam.v1.Policy.newBuilder();
// List<com.google.iam.v1.Binding> bindingPbList = new LinkedList<>();
// for (Binding binding : policy.getBindingsList()) {
// com.google.iam.v1.Binding.Builder bindingBuilder = com.google.iam.v1.Binding.newBuilder();
// bindingBuilder.setRole(binding.getRole());
// bindingBuilder.addAllMembers(binding.getMembers());
// if (binding.getCondition() != null) {
// Condition condition = binding.getCondition();
// bindingBuilder.setCondition(
// Expr.newBuilder()
// .setTitle(condition.getTitle())
// .setDescription(condition.getDescription())
// .setExpression(condition.getExpression())
// .build());
// }
// bindingPbList.add(bindingBuilder.build());
// }
// policyBuilder.addAllBindings(bindingPbList);
// if (policy.etag != null) {
// policyBuilder.setEtag(ByteString.copyFrom(BaseEncoding.base64().decode(policy.etag)));
// }
// policyBuilder.setVersion(policy.version);
// return policyBuilder.build();
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.cloud.Policy.DefaultMarshaller;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.junit.Test; | assertEquals(emptyPolicy, anotherPolicy);
assertEquals(emptyPolicy.hashCode(), anotherPolicy.hashCode());
assertNotEquals(FULL_POLICY_V3, FULL_POLICY_V1);
assertNotEquals(FULL_POLICY_V3.hashCode(), FULL_POLICY_V1.hashCode());
Policy copy = FULL_POLICY_V1.toBuilder().build();
assertEquals(FULL_POLICY_V1, copy);
assertEquals(FULL_POLICY_V1.hashCode(), copy.hashCode());
}
@Test
public void testBindings() {
assertTrue(Policy.newBuilder().build().getBindingsList().isEmpty());
assertEquals(BINDINGS_WITH_CONDITIONS, FULL_POLICY_V3.getBindingsList());
}
@Test
public void testEtag() {
assertNotNull(FULL_POLICY_V3.getEtag());
assertEquals("etag", FULL_POLICY_V3.getEtag());
}
@Test
public void testVersion() {
assertEquals(1, FULL_POLICY_V1.getVersion());
assertEquals(3, FULL_POLICY_V3.getVersion());
assertEquals(1, FULL_POLICY_V3_WITH_VERSION_1.getVersion());
}
@Test
public void testDefaultMarshaller() { | // Path: google-cloud-core/src/main/java/com/google/cloud/Policy.java
// public static class DefaultMarshaller extends Marshaller<com.google.iam.v1.Policy> {
//
// @Override
// protected Policy fromPb(com.google.iam.v1.Policy policyPb) {
// ImmutableList.Builder<Binding> bindingsListBuilder = ImmutableList.builder();
// for (com.google.iam.v1.Binding bindingPb : policyPb.getBindingsList()) {
// Binding.Builder convertedBinding =
// Binding.newBuilder()
// .setRole(bindingPb.getRole())
// .setMembers(bindingPb.getMembersList());
// if (bindingPb.hasCondition()) {
// Expr expr = bindingPb.getCondition();
// convertedBinding.setCondition(
// Condition.newBuilder()
// .setTitle(expr.getTitle())
// .setDescription(expr.getDescription())
// .setExpression(expr.getExpression())
// .build());
// }
// bindingsListBuilder.add(convertedBinding.build());
// }
// return newBuilder()
// .setBindings(bindingsListBuilder.build())
// .setEtag(
// policyPb.getEtag().isEmpty()
// ? null
// : BaseEncoding.base64().encode(policyPb.getEtag().toByteArray()))
// .setVersion(policyPb.getVersion())
// .build();
// }
//
// @Override
// protected com.google.iam.v1.Policy toPb(Policy policy) {
// com.google.iam.v1.Policy.Builder policyBuilder = com.google.iam.v1.Policy.newBuilder();
// List<com.google.iam.v1.Binding> bindingPbList = new LinkedList<>();
// for (Binding binding : policy.getBindingsList()) {
// com.google.iam.v1.Binding.Builder bindingBuilder = com.google.iam.v1.Binding.newBuilder();
// bindingBuilder.setRole(binding.getRole());
// bindingBuilder.addAllMembers(binding.getMembers());
// if (binding.getCondition() != null) {
// Condition condition = binding.getCondition();
// bindingBuilder.setCondition(
// Expr.newBuilder()
// .setTitle(condition.getTitle())
// .setDescription(condition.getDescription())
// .setExpression(condition.getExpression())
// .build());
// }
// bindingPbList.add(bindingBuilder.build());
// }
// policyBuilder.addAllBindings(bindingPbList);
// if (policy.etag != null) {
// policyBuilder.setEtag(ByteString.copyFrom(BaseEncoding.base64().decode(policy.etag)));
// }
// policyBuilder.setVersion(policy.version);
// return policyBuilder.build();
// }
// }
// Path: google-cloud-core/src/test/java/com/google/cloud/PolicyV3Test.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.cloud.Policy.DefaultMarshaller;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.junit.Test;
assertEquals(emptyPolicy, anotherPolicy);
assertEquals(emptyPolicy.hashCode(), anotherPolicy.hashCode());
assertNotEquals(FULL_POLICY_V3, FULL_POLICY_V1);
assertNotEquals(FULL_POLICY_V3.hashCode(), FULL_POLICY_V1.hashCode());
Policy copy = FULL_POLICY_V1.toBuilder().build();
assertEquals(FULL_POLICY_V1, copy);
assertEquals(FULL_POLICY_V1.hashCode(), copy.hashCode());
}
@Test
public void testBindings() {
assertTrue(Policy.newBuilder().build().getBindingsList().isEmpty());
assertEquals(BINDINGS_WITH_CONDITIONS, FULL_POLICY_V3.getBindingsList());
}
@Test
public void testEtag() {
assertNotNull(FULL_POLICY_V3.getEtag());
assertEquals("etag", FULL_POLICY_V3.getEtag());
}
@Test
public void testVersion() {
assertEquals(1, FULL_POLICY_V1.getVersion());
assertEquals(3, FULL_POLICY_V3.getVersion());
assertEquals(1, FULL_POLICY_V3_WITH_VERSION_1.getVersion());
}
@Test
public void testDefaultMarshaller() { | DefaultMarshaller marshaller = new DefaultMarshaller(); |
googleapis/java-core | google-cloud-core/src/test/java/com/google/cloud/BaseWriteChannelTest.java | // Path: google-cloud-core/src/main/java/com/google/cloud/spi/ServiceRpcFactory.java
// @SuppressWarnings("rawtypes")
// public interface ServiceRpcFactory<OptionsT extends ServiceOptions> {
//
// ServiceRpc create(OptionsT options);
// }
| import org.junit.Before;
import org.junit.Test;
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import com.google.cloud.spi.ServiceRpcFactory;
import java.io.IOException;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.util.Arrays;
import java.util.Random; | /*
* Copyright 2015 Google LLC
*
* 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.google.cloud;
public class BaseWriteChannelTest {
private abstract static class CustomService implements Service<CustomServiceOptions> {}
private abstract static class CustomServiceOptions
extends ServiceOptions<CustomService, CustomServiceOptions> {
private static final long serialVersionUID = 3302358029307467197L;
protected CustomServiceOptions(
Class<? extends ServiceFactory<CustomService, CustomServiceOptions>> serviceFactoryClass, | // Path: google-cloud-core/src/main/java/com/google/cloud/spi/ServiceRpcFactory.java
// @SuppressWarnings("rawtypes")
// public interface ServiceRpcFactory<OptionsT extends ServiceOptions> {
//
// ServiceRpc create(OptionsT options);
// }
// Path: google-cloud-core/src/test/java/com/google/cloud/BaseWriteChannelTest.java
import org.junit.Before;
import org.junit.Test;
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import com.google.cloud.spi.ServiceRpcFactory;
import java.io.IOException;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.util.Arrays;
import java.util.Random;
/*
* Copyright 2015 Google LLC
*
* 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.google.cloud;
public class BaseWriteChannelTest {
private abstract static class CustomService implements Service<CustomServiceOptions> {}
private abstract static class CustomServiceOptions
extends ServiceOptions<CustomService, CustomServiceOptions> {
private static final long serialVersionUID = 3302358029307467197L;
protected CustomServiceOptions(
Class<? extends ServiceFactory<CustomService, CustomServiceOptions>> serviceFactoryClass, | Class<? extends ServiceRpcFactory<CustomServiceOptions>> rpcFactoryClass, |
rochaeinar/data-access | DataAccessLayer/app/src/main/java/com/erc/dataaccesslayer/UpgradeExample.java | // Path: DataAccessLayer/dal/src/main/java/com/erc/dal/Log.java
// public class Log {
// public static void e(String message, Exception e) {
// if (e == null) {
// e = new Exception();
// }
// String fullMessagemessage = "ERROR: " + message +
// ", Message:" + e.getMessage() +
// ", LocalizedMessage:" + e.getLocalizedMessage() +
// ", ToString:" + e.toString();
// android.util.Log.e(Constant.TAG, fullMessagemessage);
// e.printStackTrace();
// }
//
// public static void w(String message) {
// android.util.Log.w(Constant.TAG, message);
// }
//
// public static void i(String message) {
// android.util.Log.i(Constant.TAG, message);
// }
// }
//
// Path: DataAccessLayer/dal/src/main/java/com/erc/dal/upgrade/UpgradeListener.java
// public interface UpgradeListener {
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion);
// }
| import android.database.sqlite.SQLiteDatabase;
import com.erc.dal.Log;
import com.erc.dal.upgrade.UpgradeListener; | package com.erc.dataaccesslayer;
public class UpgradeExample implements UpgradeListener {
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion < 0) {
try {
db.execSQL("ALTER TABLE SETTINGS ADD COLUMN UPGRADE_EXAMPLE TEXT;");
} catch (Exception e) { | // Path: DataAccessLayer/dal/src/main/java/com/erc/dal/Log.java
// public class Log {
// public static void e(String message, Exception e) {
// if (e == null) {
// e = new Exception();
// }
// String fullMessagemessage = "ERROR: " + message +
// ", Message:" + e.getMessage() +
// ", LocalizedMessage:" + e.getLocalizedMessage() +
// ", ToString:" + e.toString();
// android.util.Log.e(Constant.TAG, fullMessagemessage);
// e.printStackTrace();
// }
//
// public static void w(String message) {
// android.util.Log.w(Constant.TAG, message);
// }
//
// public static void i(String message) {
// android.util.Log.i(Constant.TAG, message);
// }
// }
//
// Path: DataAccessLayer/dal/src/main/java/com/erc/dal/upgrade/UpgradeListener.java
// public interface UpgradeListener {
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion);
// }
// Path: DataAccessLayer/app/src/main/java/com/erc/dataaccesslayer/UpgradeExample.java
import android.database.sqlite.SQLiteDatabase;
import com.erc.dal.Log;
import com.erc.dal.upgrade.UpgradeListener;
package com.erc.dataaccesslayer;
public class UpgradeExample implements UpgradeListener {
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion < 0) {
try {
db.execSQL("ALTER TABLE SETTINGS ADD COLUMN UPGRADE_EXAMPLE TEXT;");
} catch (Exception e) { | Log.w("UpgradeExample.onUpgrade"); |
rochaeinar/data-access | DataAccessLayer/app/src/main/java/com/erc/dataaccesslayer/Util.java | // Path: DataAccessLayer/dal/src/main/java/com/erc/dal/Log.java
// public class Log {
// public static void e(String message, Exception e) {
// if (e == null) {
// e = new Exception();
// }
// String fullMessagemessage = "ERROR: " + message +
// ", Message:" + e.getMessage() +
// ", LocalizedMessage:" + e.getLocalizedMessage() +
// ", ToString:" + e.toString();
// android.util.Log.e(Constant.TAG, fullMessagemessage);
// e.printStackTrace();
// }
//
// public static void w(String message) {
// android.util.Log.w(Constant.TAG, message);
// }
//
// public static void i(String message) {
// android.util.Log.i(Constant.TAG, message);
// }
// }
| import android.content.Context;
import com.erc.dal.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream; | package com.erc.dataaccesslayer;
/**
* Created by einar on 9/5/2015.
*/
public class Util {
public static String getAppPath(Context context) {
return context.getFilesDir() + "/";
}
public static void copyRawFileToSdCard(int idFileRaw, String fullPath, Context context) {
try {
InputStream in = context.getResources().openRawResource(idFileRaw);
File file = new File(fullPath);
File folder = new File(file.getParent());
if (!folder.exists()) {
folder.mkdirs();
}
FileOutputStream out = new FileOutputStream(fullPath);
byte[] buff = new byte[65536];
int read = 0;
try {
while ((read = in.read(buff)) > 0) {
out.write(buff, 0, read);
}
} finally {
in.close();
out.close();
}
} catch (Exception e) { | // Path: DataAccessLayer/dal/src/main/java/com/erc/dal/Log.java
// public class Log {
// public static void e(String message, Exception e) {
// if (e == null) {
// e = new Exception();
// }
// String fullMessagemessage = "ERROR: " + message +
// ", Message:" + e.getMessage() +
// ", LocalizedMessage:" + e.getLocalizedMessage() +
// ", ToString:" + e.toString();
// android.util.Log.e(Constant.TAG, fullMessagemessage);
// e.printStackTrace();
// }
//
// public static void w(String message) {
// android.util.Log.w(Constant.TAG, message);
// }
//
// public static void i(String message) {
// android.util.Log.i(Constant.TAG, message);
// }
// }
// Path: DataAccessLayer/app/src/main/java/com/erc/dataaccesslayer/Util.java
import android.content.Context;
import com.erc.dal.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
package com.erc.dataaccesslayer;
/**
* Created by einar on 9/5/2015.
*/
public class Util {
public static String getAppPath(Context context) {
return context.getFilesDir() + "/";
}
public static void copyRawFileToSdCard(int idFileRaw, String fullPath, Context context) {
try {
InputStream in = context.getResources().openRawResource(idFileRaw);
File file = new File(fullPath);
File folder = new File(file.getParent());
if (!folder.exists()) {
folder.mkdirs();
}
FileOutputStream out = new FileOutputStream(fullPath);
byte[] buff = new byte[65536];
int read = 0;
try {
while ((read = in.read(buff)) > 0) {
out.write(buff, 0, read);
}
} finally {
in.close();
out.close();
}
} catch (Exception e) { | Log.e("copyFileRawToSdCard" + fullPath, e); |
rochaeinar/data-access | DataAccessLayer/dal/src/main/java/com/erc/dal/DBOperations.java | // Path: DataAccessLayer/dal/src/main/java/com/erc/dal/upgrade/DBConfig.java
// public class DBConfig {
// private String dataBaseName;
// private int version;
// private int currentVersionCache;
// private long tableCountCache;
// private String url;
// private Context context;
// private String packageFilter;
// private UpgradeListener upgradeListener;
//
// public DBConfig(Context context, String dataBaseName, int version, String url) {
// this.context = context;
// this.dataBaseName = dataBaseName;
// this.version = version;
// setUrl(url);
// if (Util.isNullOrEmpty(dataBaseName)) {
// this.dataBaseName = SQLiteDatabaseManager.getDataBaseName(context);
// }
// }
//
// public UpgradeListener getUpgradeListener() {
// return upgradeListener;
// }
//
// public void setOnUpgradeListener(UpgradeListener upgradeListener) {
// this.upgradeListener = upgradeListener;
// }
//
// public Context getContext() {
// return context;
// }
//
// public void setContext(Context context) {
// this.context = context;
// }
//
// public String getDataBaseName() {
// return dataBaseName;
// }
//
// public void setDataBaseName(String dataBaseName) {
// this.dataBaseName = dataBaseName;
// }
//
// public int getVersion() {
// return version;
// }
//
// int getCurrentVersionCache() {
// return currentVersionCache;
// }
//
// void setCurrentVersionCache(int currentVersionCache) {
// this.currentVersionCache = currentVersionCache;
// }
//
// public long getTableCountCache() {
// return tableCountCache;
// }
//
// public void setTableCountCache(long tableCountCache) {
// this.tableCountCache = tableCountCache;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// if (url == null) {
// url = "";
// }
// this.url = url.replaceAll("/$", "");
// }
//
// public String getPackageFilter() {
// return packageFilter;
// }
//
// public void setPackageFilter(String packageFilter) {
// this.packageFilter = packageFilter;
// }
// }
| import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.erc.dal.upgrade.DBConfig;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Date; | package com.erc.dal;
/**
* Created by einar on 10/17/2016.
*/
class DBOperations {
SQLiteDatabase db;
private static DBOperations dbOperations;
private DBOperations() {
}
public static DBOperations getInstance() {
if (dbOperations == null) {
dbOperations = new DBOperations();
}
return dbOperations;
}
| // Path: DataAccessLayer/dal/src/main/java/com/erc/dal/upgrade/DBConfig.java
// public class DBConfig {
// private String dataBaseName;
// private int version;
// private int currentVersionCache;
// private long tableCountCache;
// private String url;
// private Context context;
// private String packageFilter;
// private UpgradeListener upgradeListener;
//
// public DBConfig(Context context, String dataBaseName, int version, String url) {
// this.context = context;
// this.dataBaseName = dataBaseName;
// this.version = version;
// setUrl(url);
// if (Util.isNullOrEmpty(dataBaseName)) {
// this.dataBaseName = SQLiteDatabaseManager.getDataBaseName(context);
// }
// }
//
// public UpgradeListener getUpgradeListener() {
// return upgradeListener;
// }
//
// public void setOnUpgradeListener(UpgradeListener upgradeListener) {
// this.upgradeListener = upgradeListener;
// }
//
// public Context getContext() {
// return context;
// }
//
// public void setContext(Context context) {
// this.context = context;
// }
//
// public String getDataBaseName() {
// return dataBaseName;
// }
//
// public void setDataBaseName(String dataBaseName) {
// this.dataBaseName = dataBaseName;
// }
//
// public int getVersion() {
// return version;
// }
//
// int getCurrentVersionCache() {
// return currentVersionCache;
// }
//
// void setCurrentVersionCache(int currentVersionCache) {
// this.currentVersionCache = currentVersionCache;
// }
//
// public long getTableCountCache() {
// return tableCountCache;
// }
//
// public void setTableCountCache(long tableCountCache) {
// this.tableCountCache = tableCountCache;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// if (url == null) {
// url = "";
// }
// this.url = url.replaceAll("/$", "");
// }
//
// public String getPackageFilter() {
// return packageFilter;
// }
//
// public void setPackageFilter(String packageFilter) {
// this.packageFilter = packageFilter;
// }
// }
// Path: DataAccessLayer/dal/src/main/java/com/erc/dal/DBOperations.java
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.erc.dal.upgrade.DBConfig;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Date;
package com.erc.dal;
/**
* Created by einar on 10/17/2016.
*/
class DBOperations {
SQLiteDatabase db;
private static DBOperations dbOperations;
private DBOperations() {
}
public static DBOperations getInstance() {
if (dbOperations == null) {
dbOperations = new DBOperations();
}
return dbOperations;
}
| public synchronized Entity save(Entity entity, DBConfig dbConfig) { |
rochaeinar/data-access | DataAccessLayer/dal/src/main/java/com/erc/dal/upgrade/UpgradeHelper.java | // Path: DataAccessLayer/dal/src/main/java/com/erc/dal/SQLiteDatabaseManager.java
// public class SQLiteDatabaseManager extends SQLiteOpenHelper {
//
// private static Map<String, UpgradeListener> upgradeableMap = new HashMap<>();
// private static SQLiteDatabaseManager sqLiteDatabaseManager;
// private Context context;
// private DBConfig dbConfig;
//
// private SQLiteDatabaseManager(DBConfig dbConfigs) {
// super(dbConfigs.getContext(), dbConfigs.getDataBaseName(), null, dbConfigs.getVersion());
// this.dbConfig = dbConfigs;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// }
//
// private static SQLiteDatabaseManager getInstance(DBConfig dbConfig) {
// if (sqLiteDatabaseManager == null) {
// sqLiteDatabaseManager = new SQLiteDatabaseManager(dbConfig);
// }
// return sqLiteDatabaseManager;
// }
//
// public static SQLiteDatabase open(DBConfig dbConfig) {
// SQLiteDatabase db = null;
// try {
// if (Util.isNullOrEmpty(dbConfig.getUrl())) {
// db = getInstance(dbConfig).getWritableDatabase();
// db.setLockingEnabled(false);
// } else {
// db = SQLiteDatabase.openDatabase(getFullDatabaseName(dbConfig), null, SQLiteDatabase.OPEN_READWRITE | SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.CREATE_IF_NECESSARY);
// }
// if (CreatorHelper.createTables(dbConfig, db)) {
// return open(dbConfig);
// }
// UpgradeHelper.verifyUpgrade(dbConfig, db);
// } catch (Exception e) {
// Log.e("Opening database", e);
// }
// return db;
// }
//
// public static SQLiteDatabase openReadOnly(DBConfig dbConfig) {
// SQLiteDatabase db = null;
// try {
// if (Util.isNullOrEmpty(dbConfig.getUrl())) {
// db = getInstance(dbConfig).getReadableDatabase();
// db.setLockingEnabled(false);
// } else {
// db = SQLiteDatabase.openDatabase(getFullDatabaseName(dbConfig), null, SQLiteDatabase.OPEN_READONLY | SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.CREATE_IF_NECESSARY);
// }
// if (CreatorHelper.createTables(dbConfig, db)) {
// return openReadOnly(dbConfig);
// }
// UpgradeHelper.verifyUpgrade(dbConfig, db);
// } catch (Exception e) {
// Log.e("Opening database", e);
// }
// return db;
// }
//
// public static void closeDb() {
// try {
// if (sqLiteDatabaseManager != null) {
// sqLiteDatabaseManager.close();
// }
// } catch (Exception e) {
// Log.e("Closing data base", e);
// }
// }
//
// public static String getDataBaseName(Context context) {
// String dataBaseName = RegEx.match(context.getPackageName(), RegEx.PATTERN_EXTENSION);
// dataBaseName = dataBaseName.replace(".", "");
// return dataBaseName;
// }
//
// private static String getFullDatabaseName(DBConfig dbConfig) {
// return dbConfig.getUrl() + "/" + dbConfig.getDataBaseName();
// }
// }
| import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.erc.dal.SQLiteDatabaseManager; | package com.erc.dal.upgrade;
public class UpgradeHelper {
public static void verifyUpgrade(DBConfig dbConfig, SQLiteDatabase db) {
if (dbConfig.getUpgradeListener() != null) {
int currentVersion = UpgradeHelper.getCurrentVersion(db, dbConfig);
if (dbConfig.getVersion() != currentVersion) {
if (db.isReadOnly()) { | // Path: DataAccessLayer/dal/src/main/java/com/erc/dal/SQLiteDatabaseManager.java
// public class SQLiteDatabaseManager extends SQLiteOpenHelper {
//
// private static Map<String, UpgradeListener> upgradeableMap = new HashMap<>();
// private static SQLiteDatabaseManager sqLiteDatabaseManager;
// private Context context;
// private DBConfig dbConfig;
//
// private SQLiteDatabaseManager(DBConfig dbConfigs) {
// super(dbConfigs.getContext(), dbConfigs.getDataBaseName(), null, dbConfigs.getVersion());
// this.dbConfig = dbConfigs;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// }
//
// private static SQLiteDatabaseManager getInstance(DBConfig dbConfig) {
// if (sqLiteDatabaseManager == null) {
// sqLiteDatabaseManager = new SQLiteDatabaseManager(dbConfig);
// }
// return sqLiteDatabaseManager;
// }
//
// public static SQLiteDatabase open(DBConfig dbConfig) {
// SQLiteDatabase db = null;
// try {
// if (Util.isNullOrEmpty(dbConfig.getUrl())) {
// db = getInstance(dbConfig).getWritableDatabase();
// db.setLockingEnabled(false);
// } else {
// db = SQLiteDatabase.openDatabase(getFullDatabaseName(dbConfig), null, SQLiteDatabase.OPEN_READWRITE | SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.CREATE_IF_NECESSARY);
// }
// if (CreatorHelper.createTables(dbConfig, db)) {
// return open(dbConfig);
// }
// UpgradeHelper.verifyUpgrade(dbConfig, db);
// } catch (Exception e) {
// Log.e("Opening database", e);
// }
// return db;
// }
//
// public static SQLiteDatabase openReadOnly(DBConfig dbConfig) {
// SQLiteDatabase db = null;
// try {
// if (Util.isNullOrEmpty(dbConfig.getUrl())) {
// db = getInstance(dbConfig).getReadableDatabase();
// db.setLockingEnabled(false);
// } else {
// db = SQLiteDatabase.openDatabase(getFullDatabaseName(dbConfig), null, SQLiteDatabase.OPEN_READONLY | SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.CREATE_IF_NECESSARY);
// }
// if (CreatorHelper.createTables(dbConfig, db)) {
// return openReadOnly(dbConfig);
// }
// UpgradeHelper.verifyUpgrade(dbConfig, db);
// } catch (Exception e) {
// Log.e("Opening database", e);
// }
// return db;
// }
//
// public static void closeDb() {
// try {
// if (sqLiteDatabaseManager != null) {
// sqLiteDatabaseManager.close();
// }
// } catch (Exception e) {
// Log.e("Closing data base", e);
// }
// }
//
// public static String getDataBaseName(Context context) {
// String dataBaseName = RegEx.match(context.getPackageName(), RegEx.PATTERN_EXTENSION);
// dataBaseName = dataBaseName.replace(".", "");
// return dataBaseName;
// }
//
// private static String getFullDatabaseName(DBConfig dbConfig) {
// return dbConfig.getUrl() + "/" + dbConfig.getDataBaseName();
// }
// }
// Path: DataAccessLayer/dal/src/main/java/com/erc/dal/upgrade/UpgradeHelper.java
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.erc.dal.SQLiteDatabaseManager;
package com.erc.dal.upgrade;
public class UpgradeHelper {
public static void verifyUpgrade(DBConfig dbConfig, SQLiteDatabase db) {
if (dbConfig.getUpgradeListener() != null) {
int currentVersion = UpgradeHelper.getCurrentVersion(db, dbConfig);
if (dbConfig.getVersion() != currentVersion) {
if (db.isReadOnly()) { | SQLiteDatabaseManager.open(dbConfig); |
rochaeinar/data-access | DataAccessLayer/dal/src/main/java/com/erc/dal/DBs.java | // Path: DataAccessLayer/dal/src/main/java/com/erc/dal/upgrade/DBConfig.java
// public class DBConfig {
// private String dataBaseName;
// private int version;
// private int currentVersionCache;
// private long tableCountCache;
// private String url;
// private Context context;
// private String packageFilter;
// private UpgradeListener upgradeListener;
//
// public DBConfig(Context context, String dataBaseName, int version, String url) {
// this.context = context;
// this.dataBaseName = dataBaseName;
// this.version = version;
// setUrl(url);
// if (Util.isNullOrEmpty(dataBaseName)) {
// this.dataBaseName = SQLiteDatabaseManager.getDataBaseName(context);
// }
// }
//
// public UpgradeListener getUpgradeListener() {
// return upgradeListener;
// }
//
// public void setOnUpgradeListener(UpgradeListener upgradeListener) {
// this.upgradeListener = upgradeListener;
// }
//
// public Context getContext() {
// return context;
// }
//
// public void setContext(Context context) {
// this.context = context;
// }
//
// public String getDataBaseName() {
// return dataBaseName;
// }
//
// public void setDataBaseName(String dataBaseName) {
// this.dataBaseName = dataBaseName;
// }
//
// public int getVersion() {
// return version;
// }
//
// int getCurrentVersionCache() {
// return currentVersionCache;
// }
//
// void setCurrentVersionCache(int currentVersionCache) {
// this.currentVersionCache = currentVersionCache;
// }
//
// public long getTableCountCache() {
// return tableCountCache;
// }
//
// public void setTableCountCache(long tableCountCache) {
// this.tableCountCache = tableCountCache;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// if (url == null) {
// url = "";
// }
// this.url = url.replaceAll("/$", "");
// }
//
// public String getPackageFilter() {
// return packageFilter;
// }
//
// public void setPackageFilter(String packageFilter) {
// this.packageFilter = packageFilter;
// }
// }
| import com.erc.dal.upgrade.DBConfig;
import java.util.HashMap; | package com.erc.dal;
/**
* Created by Einar on 7/9/2018.
*/
public class DBs {
private HashMap<String, DB> dbsMap;
private static DBs dbs = null;
public static DBs getInstance() {
if (dbs == null) {
dbs = new DBs();
}
return dbs;
}
| // Path: DataAccessLayer/dal/src/main/java/com/erc/dal/upgrade/DBConfig.java
// public class DBConfig {
// private String dataBaseName;
// private int version;
// private int currentVersionCache;
// private long tableCountCache;
// private String url;
// private Context context;
// private String packageFilter;
// private UpgradeListener upgradeListener;
//
// public DBConfig(Context context, String dataBaseName, int version, String url) {
// this.context = context;
// this.dataBaseName = dataBaseName;
// this.version = version;
// setUrl(url);
// if (Util.isNullOrEmpty(dataBaseName)) {
// this.dataBaseName = SQLiteDatabaseManager.getDataBaseName(context);
// }
// }
//
// public UpgradeListener getUpgradeListener() {
// return upgradeListener;
// }
//
// public void setOnUpgradeListener(UpgradeListener upgradeListener) {
// this.upgradeListener = upgradeListener;
// }
//
// public Context getContext() {
// return context;
// }
//
// public void setContext(Context context) {
// this.context = context;
// }
//
// public String getDataBaseName() {
// return dataBaseName;
// }
//
// public void setDataBaseName(String dataBaseName) {
// this.dataBaseName = dataBaseName;
// }
//
// public int getVersion() {
// return version;
// }
//
// int getCurrentVersionCache() {
// return currentVersionCache;
// }
//
// void setCurrentVersionCache(int currentVersionCache) {
// this.currentVersionCache = currentVersionCache;
// }
//
// public long getTableCountCache() {
// return tableCountCache;
// }
//
// public void setTableCountCache(long tableCountCache) {
// this.tableCountCache = tableCountCache;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// if (url == null) {
// url = "";
// }
// this.url = url.replaceAll("/$", "");
// }
//
// public String getPackageFilter() {
// return packageFilter;
// }
//
// public void setPackageFilter(String packageFilter) {
// this.packageFilter = packageFilter;
// }
// }
// Path: DataAccessLayer/dal/src/main/java/com/erc/dal/DBs.java
import com.erc.dal.upgrade.DBConfig;
import java.util.HashMap;
package com.erc.dal;
/**
* Created by Einar on 7/9/2018.
*/
public class DBs {
private HashMap<String, DB> dbsMap;
private static DBs dbs = null;
public static DBs getInstance() {
if (dbs == null) {
dbs = new DBs();
}
return dbs;
}
| public DB getDB(DBConfig dbConfig) { |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/NonDeterminsticControllerTest.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/dao/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
| import org.statefulj.framework.tests.model.User;
import org.statefulj.fsm.TooBusyException;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.dao.UserRepository; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/applicationContext-StatefulControllerTests.xml"})
public class NonDeterminsticControllerTest {
@Resource | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/dao/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/NonDeterminsticControllerTest.java
import org.statefulj.framework.tests.model.User;
import org.statefulj.fsm.TooBusyException;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.dao.UserRepository;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/applicationContext-StatefulControllerTests.xml"})
public class NonDeterminsticControllerTest {
@Resource | UserRepository userRepo; |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/NonDeterminsticControllerTest.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/dao/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
| import org.statefulj.framework.tests.model.User;
import org.statefulj.fsm.TooBusyException;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.dao.UserRepository; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/applicationContext-StatefulControllerTests.xml"})
public class NonDeterminsticControllerTest {
@Resource
UserRepository userRepo;
@FSM("nonDetermisticController") | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/dao/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/NonDeterminsticControllerTest.java
import org.statefulj.framework.tests.model.User;
import org.statefulj.fsm.TooBusyException;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.dao.UserRepository;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/applicationContext-StatefulControllerTests.xml"})
public class NonDeterminsticControllerTest {
@Resource
UserRepository userRepo;
@FSM("nonDetermisticController") | StatefulFSM<User> nonDetermisticFSM; |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/NonDeterminsticControllerTest.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/dao/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
| import org.statefulj.framework.tests.model.User;
import org.statefulj.fsm.TooBusyException;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.dao.UserRepository; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/applicationContext-StatefulControllerTests.xml"})
public class NonDeterminsticControllerTest {
@Resource
UserRepository userRepo;
@FSM("nonDetermisticController") | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/dao/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/NonDeterminsticControllerTest.java
import org.statefulj.framework.tests.model.User;
import org.statefulj.fsm.TooBusyException;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.dao.UserRepository;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/applicationContext-StatefulControllerTests.xml"})
public class NonDeterminsticControllerTest {
@Resource
UserRepository userRepo;
@FSM("nonDetermisticController") | StatefulFSM<User> nonDetermisticFSM; |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/NonDeterminsticControllerTest.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/dao/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
| import org.statefulj.framework.tests.model.User;
import org.statefulj.fsm.TooBusyException;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.dao.UserRepository; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/applicationContext-StatefulControllerTests.xml"})
public class NonDeterminsticControllerTest {
@Resource
UserRepository userRepo;
@FSM("nonDetermisticController")
StatefulFSM<User> nonDetermisticFSM;
@Test | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/dao/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/NonDeterminsticControllerTest.java
import org.statefulj.framework.tests.model.User;
import org.statefulj.fsm.TooBusyException;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.dao.UserRepository;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/applicationContext-StatefulControllerTests.xml"})
public class NonDeterminsticControllerTest {
@Resource
UserRepository userRepo;
@FSM("nonDetermisticController")
StatefulFSM<User> nonDetermisticFSM;
@Test | public void testNonDeterministicTransitions() throws TooBusyException { |
statefulj/statefulj | statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/StateActionPairImpl.java | // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/StateActionPair.java
// public interface StateActionPair<T> {
//
// /**
// * @return the {@link org.statefulj.fsm.model.State}
// */
// State<T> getState();
//
// /**
// * @return {@link org.statefulj.fsm.model.Action}
// */
// Action<T> getAction();
//
// }
| import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.StateActionPair; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.fsm.model.impl;
public class StateActionPairImpl<T> implements StateActionPair<T> {
State<T> state; | // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/StateActionPair.java
// public interface StateActionPair<T> {
//
// /**
// * @return the {@link org.statefulj.fsm.model.State}
// */
// State<T> getState();
//
// /**
// * @return {@link org.statefulj.fsm.model.Action}
// */
// Action<T> getAction();
//
// }
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/StateActionPairImpl.java
import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.StateActionPair;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.fsm.model.impl;
public class StateActionPairImpl<T> implements StateActionPair<T> {
State<T> state; | Action<T> action; |
statefulj/statefulj | statefulj-persistence/statefulj-persistence-jpa/src/test/java/org/statefulj/persistence/jpa/Order.java | // Path: statefulj-persistence/statefulj-persistence-jpa/src/main/java/org/statefulj/persistence/jpa/model/StatefulEntity.java
// @MappedSuperclass
// public abstract class StatefulEntity {
//
// /**
// * Field be set on insert. But updates must be done through the JPAPersister
// *
// */
// @State
// @Column(insertable=true, updatable=false)
// private String state;
//
// public String getState() {
// return state;
// }
// }
| import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.statefulj.persistence.jpa.model.StatefulEntity; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.persistence.jpa;
@Entity
@Table(name="Orders") | // Path: statefulj-persistence/statefulj-persistence-jpa/src/main/java/org/statefulj/persistence/jpa/model/StatefulEntity.java
// @MappedSuperclass
// public abstract class StatefulEntity {
//
// /**
// * Field be set on insert. But updates must be done through the JPAPersister
// *
// */
// @State
// @Column(insertable=true, updatable=false)
// private String state;
//
// public String getState() {
// return state;
// }
// }
// Path: statefulj-persistence/statefulj-persistence-jpa/src/test/java/org/statefulj/persistence/jpa/Order.java
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.statefulj.persistence.jpa.model.StatefulEntity;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.persistence.jpa;
@Entity
@Table(name="Orders") | public class Order extends StatefulEntity { |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/clients/FSMClient1.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
| import org.springframework.stereotype.Component;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.model.User;
import javax.inject.Inject; | package org.statefulj.framework.tests.clients;
/**
* Created by andrewhall on 8/21/15.
*/
@Component
public class FSMClient1 {
| // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/clients/FSMClient1.java
import org.springframework.stereotype.Component;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.model.User;
import javax.inject.Inject;
package org.statefulj.framework.tests.clients;
/**
* Created by andrewhall on 8/21/15.
*/
@Component
public class FSMClient1 {
| public StatefulFSM<User> userStatefulFSM; |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/clients/FSMClient1.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
| import org.springframework.stereotype.Component;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.model.User;
import javax.inject.Inject; | package org.statefulj.framework.tests.clients;
/**
* Created by andrewhall on 8/21/15.
*/
@Component
public class FSMClient1 {
| // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/clients/FSMClient1.java
import org.springframework.stereotype.Component;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.model.User;
import javax.inject.Inject;
package org.statefulj.framework.tests.clients;
/**
* Created by andrewhall on 8/21/15.
*/
@Component
public class FSMClient1 {
| public StatefulFSM<User> userStatefulFSM; |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/clients/FSMClient2.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/MemoryObject.java
// public class MemoryObject {
//
// public final static String ONE_STATE = "one";
// public final static String TWO_STATE = "two";
//
// @State
// private String state;
//
// public String getState() {
// return this.state;
// }
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
| import org.springframework.stereotype.Component;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.model.MemoryObject;
import org.statefulj.framework.tests.model.User;
import javax.inject.Inject; | package org.statefulj.framework.tests.clients;
/**
* Created by andrewhall on 8/21/15.
*/
@Component
public class FSMClient2 {
| // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/MemoryObject.java
// public class MemoryObject {
//
// public final static String ONE_STATE = "one";
// public final static String TWO_STATE = "two";
//
// @State
// private String state;
//
// public String getState() {
// return this.state;
// }
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/clients/FSMClient2.java
import org.springframework.stereotype.Component;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.model.MemoryObject;
import org.statefulj.framework.tests.model.User;
import javax.inject.Inject;
package org.statefulj.framework.tests.clients;
/**
* Created by andrewhall on 8/21/15.
*/
@Component
public class FSMClient2 {
| public StatefulFSM<User> userStatefulFSM; |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/clients/FSMClient2.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/MemoryObject.java
// public class MemoryObject {
//
// public final static String ONE_STATE = "one";
// public final static String TWO_STATE = "two";
//
// @State
// private String state;
//
// public String getState() {
// return this.state;
// }
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
| import org.springframework.stereotype.Component;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.model.MemoryObject;
import org.statefulj.framework.tests.model.User;
import javax.inject.Inject; | package org.statefulj.framework.tests.clients;
/**
* Created by andrewhall on 8/21/15.
*/
@Component
public class FSMClient2 {
| // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/MemoryObject.java
// public class MemoryObject {
//
// public final static String ONE_STATE = "one";
// public final static String TWO_STATE = "two";
//
// @State
// private String state;
//
// public String getState() {
// return this.state;
// }
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/clients/FSMClient2.java
import org.springframework.stereotype.Component;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.model.MemoryObject;
import org.statefulj.framework.tests.model.User;
import javax.inject.Inject;
package org.statefulj.framework.tests.clients;
/**
* Created by andrewhall on 8/21/15.
*/
@Component
public class FSMClient2 {
| public StatefulFSM<User> userStatefulFSM; |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/clients/FSMClient2.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/MemoryObject.java
// public class MemoryObject {
//
// public final static String ONE_STATE = "one";
// public final static String TWO_STATE = "two";
//
// @State
// private String state;
//
// public String getState() {
// return this.state;
// }
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
| import org.springframework.stereotype.Component;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.model.MemoryObject;
import org.statefulj.framework.tests.model.User;
import javax.inject.Inject; | package org.statefulj.framework.tests.clients;
/**
* Created by andrewhall on 8/21/15.
*/
@Component
public class FSMClient2 {
public StatefulFSM<User> userStatefulFSM;
| // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/MemoryObject.java
// public class MemoryObject {
//
// public final static String ONE_STATE = "one";
// public final static String TWO_STATE = "two";
//
// @State
// private String state;
//
// public String getState() {
// return this.state;
// }
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/clients/FSMClient2.java
import org.springframework.stereotype.Component;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.tests.model.MemoryObject;
import org.statefulj.framework.tests.model.User;
import javax.inject.Inject;
package org.statefulj.framework.tests.clients;
/**
* Created by andrewhall on 8/21/15.
*/
@Component
public class FSMClient2 {
public StatefulFSM<User> userStatefulFSM;
| public StatefulFSM<MemoryObject> memoryObjectStatefulFSM; |
statefulj/statefulj | statefulj-framework/statefulj-framework-core/src/test/java/org/alternative/AltTestBinder.java | // Path: statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/mocks/MockProxy.java
// public class MockProxy {
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/EndpointBinder.java
// public interface EndpointBinder {
//
// /**
// * Returns the "key" for this EndpointBinder. The key is the first part of the tuple in an Event.
// * For example, the key for the SpringMVC binder is "springmvc".
// *
// * @return The first part of the tuple in an Event
// */
// String getKey();
//
// /**
// * Invoked by the StatefulController to construct an EndpointBinder Class
// *
// * @param beanName The Spring Bean Name for the Endpoint Binder
// * @param stateControllerClass The class of the associated {@link org.statefulj.framework.core.annotations.StatefulController}
// * @param idType The Class Type of the id field for the associated StatefulEntity
// * @param isDomainEntity A flag indicating the StatefulEntity and the {@link org.statefulj.framework.core.annotations.StatefulController} are one in the same
// * @param eventMapping Association of Event to the Action Method
// * @param refFactory The {@link org.statefulj.framework.core.model.ReferenceFactory} that generates all Spring Bean ids
// * @return The generated Class of the EndpointBinder
// * @throws CannotCompileException
// * @throws NotFoundException
// * @throws IllegalArgumentException
// * @throws IllegalAccessException
// * @throws InvocationTargetException
// */
// Class<?> bindEndpoints(
// String beanName,
// Class<?> stateControllerClass,
// Class<?> idType,
// boolean isDomainEntity,
// Map<String, Method> eventMapping,
// ReferenceFactory refFactory) throws CannotCompileException, NotFoundException, IllegalArgumentException, IllegalAccessException, InvocationTargetException;
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/ReferenceFactory.java
// public interface ReferenceFactory {
//
// String getBinderId(String key);
//
// String getFinderId();
//
// String getFSMHarnessId();
//
// String getPersisterId();
//
// String getFactoryId();
//
// String getStatefulFSMId();
//
// String getFSMId();
//
// String getStateId(String state);
//
// String getTransitionId(int cnt);
//
// String getActionId(Method method);
//
// }
| import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import javassist.CannotCompileException;
import javassist.NotFoundException;
import org.statefulj.framework.core.mocks.MockProxy;
import org.statefulj.framework.core.model.EndpointBinder;
import org.statefulj.framework.core.model.ReferenceFactory; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.alternative;
public class AltTestBinder implements EndpointBinder {
@Override
public String getKey() {
return "test";
}
@Override
public Class<?> bindEndpoints(
String beanId,
Class<?> stateControllerClass,
Class<?> idType,
boolean isDomainEntity,
Map<String, Method> eventMapping, | // Path: statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/mocks/MockProxy.java
// public class MockProxy {
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/EndpointBinder.java
// public interface EndpointBinder {
//
// /**
// * Returns the "key" for this EndpointBinder. The key is the first part of the tuple in an Event.
// * For example, the key for the SpringMVC binder is "springmvc".
// *
// * @return The first part of the tuple in an Event
// */
// String getKey();
//
// /**
// * Invoked by the StatefulController to construct an EndpointBinder Class
// *
// * @param beanName The Spring Bean Name for the Endpoint Binder
// * @param stateControllerClass The class of the associated {@link org.statefulj.framework.core.annotations.StatefulController}
// * @param idType The Class Type of the id field for the associated StatefulEntity
// * @param isDomainEntity A flag indicating the StatefulEntity and the {@link org.statefulj.framework.core.annotations.StatefulController} are one in the same
// * @param eventMapping Association of Event to the Action Method
// * @param refFactory The {@link org.statefulj.framework.core.model.ReferenceFactory} that generates all Spring Bean ids
// * @return The generated Class of the EndpointBinder
// * @throws CannotCompileException
// * @throws NotFoundException
// * @throws IllegalArgumentException
// * @throws IllegalAccessException
// * @throws InvocationTargetException
// */
// Class<?> bindEndpoints(
// String beanName,
// Class<?> stateControllerClass,
// Class<?> idType,
// boolean isDomainEntity,
// Map<String, Method> eventMapping,
// ReferenceFactory refFactory) throws CannotCompileException, NotFoundException, IllegalArgumentException, IllegalAccessException, InvocationTargetException;
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/ReferenceFactory.java
// public interface ReferenceFactory {
//
// String getBinderId(String key);
//
// String getFinderId();
//
// String getFSMHarnessId();
//
// String getPersisterId();
//
// String getFactoryId();
//
// String getStatefulFSMId();
//
// String getFSMId();
//
// String getStateId(String state);
//
// String getTransitionId(int cnt);
//
// String getActionId(Method method);
//
// }
// Path: statefulj-framework/statefulj-framework-core/src/test/java/org/alternative/AltTestBinder.java
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import javassist.CannotCompileException;
import javassist.NotFoundException;
import org.statefulj.framework.core.mocks.MockProxy;
import org.statefulj.framework.core.model.EndpointBinder;
import org.statefulj.framework.core.model.ReferenceFactory;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.alternative;
public class AltTestBinder implements EndpointBinder {
@Override
public String getKey() {
return "test";
}
@Override
public Class<?> bindEndpoints(
String beanId,
Class<?> stateControllerClass,
Class<?> idType,
boolean isDomainEntity,
Map<String, Method> eventMapping, | ReferenceFactory refFactory) |
statefulj/statefulj | statefulj-framework/statefulj-framework-core/src/test/java/org/alternative/AltTestBinder.java | // Path: statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/mocks/MockProxy.java
// public class MockProxy {
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/EndpointBinder.java
// public interface EndpointBinder {
//
// /**
// * Returns the "key" for this EndpointBinder. The key is the first part of the tuple in an Event.
// * For example, the key for the SpringMVC binder is "springmvc".
// *
// * @return The first part of the tuple in an Event
// */
// String getKey();
//
// /**
// * Invoked by the StatefulController to construct an EndpointBinder Class
// *
// * @param beanName The Spring Bean Name for the Endpoint Binder
// * @param stateControllerClass The class of the associated {@link org.statefulj.framework.core.annotations.StatefulController}
// * @param idType The Class Type of the id field for the associated StatefulEntity
// * @param isDomainEntity A flag indicating the StatefulEntity and the {@link org.statefulj.framework.core.annotations.StatefulController} are one in the same
// * @param eventMapping Association of Event to the Action Method
// * @param refFactory The {@link org.statefulj.framework.core.model.ReferenceFactory} that generates all Spring Bean ids
// * @return The generated Class of the EndpointBinder
// * @throws CannotCompileException
// * @throws NotFoundException
// * @throws IllegalArgumentException
// * @throws IllegalAccessException
// * @throws InvocationTargetException
// */
// Class<?> bindEndpoints(
// String beanName,
// Class<?> stateControllerClass,
// Class<?> idType,
// boolean isDomainEntity,
// Map<String, Method> eventMapping,
// ReferenceFactory refFactory) throws CannotCompileException, NotFoundException, IllegalArgumentException, IllegalAccessException, InvocationTargetException;
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/ReferenceFactory.java
// public interface ReferenceFactory {
//
// String getBinderId(String key);
//
// String getFinderId();
//
// String getFSMHarnessId();
//
// String getPersisterId();
//
// String getFactoryId();
//
// String getStatefulFSMId();
//
// String getFSMId();
//
// String getStateId(String state);
//
// String getTransitionId(int cnt);
//
// String getActionId(Method method);
//
// }
| import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import javassist.CannotCompileException;
import javassist.NotFoundException;
import org.statefulj.framework.core.mocks.MockProxy;
import org.statefulj.framework.core.model.EndpointBinder;
import org.statefulj.framework.core.model.ReferenceFactory; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.alternative;
public class AltTestBinder implements EndpointBinder {
@Override
public String getKey() {
return "test";
}
@Override
public Class<?> bindEndpoints(
String beanId,
Class<?> stateControllerClass,
Class<?> idType,
boolean isDomainEntity,
Map<String, Method> eventMapping,
ReferenceFactory refFactory)
throws CannotCompileException, NotFoundException,
IllegalArgumentException, IllegalAccessException,
InvocationTargetException {
| // Path: statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/mocks/MockProxy.java
// public class MockProxy {
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/EndpointBinder.java
// public interface EndpointBinder {
//
// /**
// * Returns the "key" for this EndpointBinder. The key is the first part of the tuple in an Event.
// * For example, the key for the SpringMVC binder is "springmvc".
// *
// * @return The first part of the tuple in an Event
// */
// String getKey();
//
// /**
// * Invoked by the StatefulController to construct an EndpointBinder Class
// *
// * @param beanName The Spring Bean Name for the Endpoint Binder
// * @param stateControllerClass The class of the associated {@link org.statefulj.framework.core.annotations.StatefulController}
// * @param idType The Class Type of the id field for the associated StatefulEntity
// * @param isDomainEntity A flag indicating the StatefulEntity and the {@link org.statefulj.framework.core.annotations.StatefulController} are one in the same
// * @param eventMapping Association of Event to the Action Method
// * @param refFactory The {@link org.statefulj.framework.core.model.ReferenceFactory} that generates all Spring Bean ids
// * @return The generated Class of the EndpointBinder
// * @throws CannotCompileException
// * @throws NotFoundException
// * @throws IllegalArgumentException
// * @throws IllegalAccessException
// * @throws InvocationTargetException
// */
// Class<?> bindEndpoints(
// String beanName,
// Class<?> stateControllerClass,
// Class<?> idType,
// boolean isDomainEntity,
// Map<String, Method> eventMapping,
// ReferenceFactory refFactory) throws CannotCompileException, NotFoundException, IllegalArgumentException, IllegalAccessException, InvocationTargetException;
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/ReferenceFactory.java
// public interface ReferenceFactory {
//
// String getBinderId(String key);
//
// String getFinderId();
//
// String getFSMHarnessId();
//
// String getPersisterId();
//
// String getFactoryId();
//
// String getStatefulFSMId();
//
// String getFSMId();
//
// String getStateId(String state);
//
// String getTransitionId(int cnt);
//
// String getActionId(Method method);
//
// }
// Path: statefulj-framework/statefulj-framework-core/src/test/java/org/alternative/AltTestBinder.java
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import javassist.CannotCompileException;
import javassist.NotFoundException;
import org.statefulj.framework.core.mocks.MockProxy;
import org.statefulj.framework.core.model.EndpointBinder;
import org.statefulj.framework.core.model.ReferenceFactory;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.alternative;
public class AltTestBinder implements EndpointBinder {
@Override
public String getKey() {
return "test";
}
@Override
public Class<?> bindEndpoints(
String beanId,
Class<?> stateControllerClass,
Class<?> idType,
boolean isDomainEntity,
Map<String, Method> eventMapping,
ReferenceFactory refFactory)
throws CannotCompileException, NotFoundException,
IllegalArgumentException, IllegalAccessException,
InvocationTargetException {
| return MockProxy.class; |
statefulj/statefulj | statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/CompositeActionImpl.java | // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/RetryException.java
// public class RetryException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public RetryException() {
// super();
// }
//
// public RetryException(String msg) {
// super(msg);
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
| import java.util.List;
import org.statefulj.fsm.RetryException;
import org.statefulj.fsm.model.Action; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.fsm.model.impl;
/**
* A "composite" Action which is composed of a set of {@link org.statefulj.fsm.model.Action}. When invoked,
* it will iterate and invoke all the composition Actions.
*
* @author Andrew Hall
*
* @param <T> The class of the Stateful Entity
*/
public class CompositeActionImpl<T> implements Action<T> {
List<Action<T>> actions;
public CompositeActionImpl(List<Action<T>> actions) {
this.actions = actions;
}
| // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/RetryException.java
// public class RetryException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public RetryException() {
// super();
// }
//
// public RetryException(String msg) {
// super(msg);
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/CompositeActionImpl.java
import java.util.List;
import org.statefulj.fsm.RetryException;
import org.statefulj.fsm.model.Action;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.fsm.model.impl;
/**
* A "composite" Action which is composed of a set of {@link org.statefulj.fsm.model.Action}. When invoked,
* it will iterate and invoke all the composition Actions.
*
* @author Andrew Hall
*
* @param <T> The class of the Stateful Entity
*/
public class CompositeActionImpl<T> implements Action<T> {
List<Action<T>> actions;
public CompositeActionImpl(List<Action<T>> actions) {
this.actions = actions;
}
| public void execute(T stateful, String event, Object ... args) throws RetryException{ |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/controllers/OverloadedMethodController.java | // Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
| import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.tests.model.User;
import static org.statefulj.framework.tests.model.User.*; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests.controllers;
@StatefulController(
value="overloadedMethodController", | // Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/controllers/OverloadedMethodController.java
import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.tests.model.User;
import static org.statefulj.framework.tests.model.User.*;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests.controllers;
@StatefulController(
value="overloadedMethodController", | clazz=User.class, |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/ddd/DomainEntity.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: statefulj-persistence/statefulj-persistence-jpa/src/main/java/org/statefulj/persistence/jpa/model/StatefulEntity.java
// @MappedSuperclass
// public abstract class StatefulEntity {
//
// /**
// * Field be set on insert. But updates must be done through the JPAPersister
// *
// */
// @State
// @Column(insertable=true, updatable=false)
// private String state;
//
// public String getState() {
// return state;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/ddd/DomainEntity.java
// @Entity
// @Scope("prototype")
// @StatefulController(
// clazz=DomainEntity.class,
// startState=STATE_A
// )
// public class DomainEntity extends StatefulEntity {
//
// // States
// //
// public final static String STATE_A = "A";
// public final static String STATE_B = "B";
//
// // Internal Events
// //
// private final static String EVENT_X = "event-x";
// private final static String EVENT_Y = "event-y";
// private final static String SPRING_EVENT_X = "springmvc:/" + EVENT_X;
// private final static String SPRING_EVENT_Y = "springmvc:/" + EVENT_Y;
//
// @Id
// private Long id;
//
// private int value;
//
// @FSM
// @Transient
// private StatefulFSM<DomainEntity> fsm;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public int getValue() {
// return value;
// }
//
// public void setValue(int value) {
// this.value = value;
// }
//
// public void onEventX(int value) throws TooBusyException {
// fsm.onEvent(this, EVENT_X, value);
// }
//
// public void onEventY(int value) throws TooBusyException {
// fsm.onEvent(this, EVENT_Y, value);
// }
//
// @Transitions({
// @Transition(from=STATE_A, event=EVENT_X, to=STATE_B),
// @Transition(from=STATE_A, event=SPRING_EVENT_X, to=STATE_B),
// })
// protected DomainEntity actionAXB(String event, Integer value) {
// System.out.println("actionAXB");
// this.value = value;
// return this;
// }
//
// @Transitions({
// @Transition(from=STATE_B, event=EVENT_Y, to=STATE_A),
// @Transition(from=STATE_B, event=SPRING_EVENT_Y, to=STATE_A),
// })
// protected DomainEntity actionBYA(String event, Integer value) {
// System.out.println("actionBYA");
// this.value = value;
// return this;
// }
// }
| import static org.statefulj.framework.tests.ddd.DomainEntity.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;
import org.springframework.context.annotation.Scope;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.core.annotations.Transitions;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
import org.statefulj.persistence.jpa.model.StatefulEntity; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests.ddd;
/**
* Entity class. We will scope this as a non-singleton (prototype)
*
* @author Andrew Hall
*
*/
@Entity
@Scope("prototype")
@StatefulController( | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: statefulj-persistence/statefulj-persistence-jpa/src/main/java/org/statefulj/persistence/jpa/model/StatefulEntity.java
// @MappedSuperclass
// public abstract class StatefulEntity {
//
// /**
// * Field be set on insert. But updates must be done through the JPAPersister
// *
// */
// @State
// @Column(insertable=true, updatable=false)
// private String state;
//
// public String getState() {
// return state;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/ddd/DomainEntity.java
// @Entity
// @Scope("prototype")
// @StatefulController(
// clazz=DomainEntity.class,
// startState=STATE_A
// )
// public class DomainEntity extends StatefulEntity {
//
// // States
// //
// public final static String STATE_A = "A";
// public final static String STATE_B = "B";
//
// // Internal Events
// //
// private final static String EVENT_X = "event-x";
// private final static String EVENT_Y = "event-y";
// private final static String SPRING_EVENT_X = "springmvc:/" + EVENT_X;
// private final static String SPRING_EVENT_Y = "springmvc:/" + EVENT_Y;
//
// @Id
// private Long id;
//
// private int value;
//
// @FSM
// @Transient
// private StatefulFSM<DomainEntity> fsm;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public int getValue() {
// return value;
// }
//
// public void setValue(int value) {
// this.value = value;
// }
//
// public void onEventX(int value) throws TooBusyException {
// fsm.onEvent(this, EVENT_X, value);
// }
//
// public void onEventY(int value) throws TooBusyException {
// fsm.onEvent(this, EVENT_Y, value);
// }
//
// @Transitions({
// @Transition(from=STATE_A, event=EVENT_X, to=STATE_B),
// @Transition(from=STATE_A, event=SPRING_EVENT_X, to=STATE_B),
// })
// protected DomainEntity actionAXB(String event, Integer value) {
// System.out.println("actionAXB");
// this.value = value;
// return this;
// }
//
// @Transitions({
// @Transition(from=STATE_B, event=EVENT_Y, to=STATE_A),
// @Transition(from=STATE_B, event=SPRING_EVENT_Y, to=STATE_A),
// })
// protected DomainEntity actionBYA(String event, Integer value) {
// System.out.println("actionBYA");
// this.value = value;
// return this;
// }
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/ddd/DomainEntity.java
import static org.statefulj.framework.tests.ddd.DomainEntity.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;
import org.springframework.context.annotation.Scope;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.core.annotations.Transitions;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
import org.statefulj.persistence.jpa.model.StatefulEntity;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests.ddd;
/**
* Entity class. We will scope this as a non-singleton (prototype)
*
* @author Andrew Hall
*
*/
@Entity
@Scope("prototype")
@StatefulController( | clazz=DomainEntity.class, |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/ddd/DomainEntity.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: statefulj-persistence/statefulj-persistence-jpa/src/main/java/org/statefulj/persistence/jpa/model/StatefulEntity.java
// @MappedSuperclass
// public abstract class StatefulEntity {
//
// /**
// * Field be set on insert. But updates must be done through the JPAPersister
// *
// */
// @State
// @Column(insertable=true, updatable=false)
// private String state;
//
// public String getState() {
// return state;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/ddd/DomainEntity.java
// @Entity
// @Scope("prototype")
// @StatefulController(
// clazz=DomainEntity.class,
// startState=STATE_A
// )
// public class DomainEntity extends StatefulEntity {
//
// // States
// //
// public final static String STATE_A = "A";
// public final static String STATE_B = "B";
//
// // Internal Events
// //
// private final static String EVENT_X = "event-x";
// private final static String EVENT_Y = "event-y";
// private final static String SPRING_EVENT_X = "springmvc:/" + EVENT_X;
// private final static String SPRING_EVENT_Y = "springmvc:/" + EVENT_Y;
//
// @Id
// private Long id;
//
// private int value;
//
// @FSM
// @Transient
// private StatefulFSM<DomainEntity> fsm;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public int getValue() {
// return value;
// }
//
// public void setValue(int value) {
// this.value = value;
// }
//
// public void onEventX(int value) throws TooBusyException {
// fsm.onEvent(this, EVENT_X, value);
// }
//
// public void onEventY(int value) throws TooBusyException {
// fsm.onEvent(this, EVENT_Y, value);
// }
//
// @Transitions({
// @Transition(from=STATE_A, event=EVENT_X, to=STATE_B),
// @Transition(from=STATE_A, event=SPRING_EVENT_X, to=STATE_B),
// })
// protected DomainEntity actionAXB(String event, Integer value) {
// System.out.println("actionAXB");
// this.value = value;
// return this;
// }
//
// @Transitions({
// @Transition(from=STATE_B, event=EVENT_Y, to=STATE_A),
// @Transition(from=STATE_B, event=SPRING_EVENT_Y, to=STATE_A),
// })
// protected DomainEntity actionBYA(String event, Integer value) {
// System.out.println("actionBYA");
// this.value = value;
// return this;
// }
// }
| import static org.statefulj.framework.tests.ddd.DomainEntity.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;
import org.springframework.context.annotation.Scope;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.core.annotations.Transitions;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
import org.statefulj.persistence.jpa.model.StatefulEntity; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests.ddd;
/**
* Entity class. We will scope this as a non-singleton (prototype)
*
* @author Andrew Hall
*
*/
@Entity
@Scope("prototype")
@StatefulController(
clazz=DomainEntity.class,
startState=STATE_A
) | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: statefulj-persistence/statefulj-persistence-jpa/src/main/java/org/statefulj/persistence/jpa/model/StatefulEntity.java
// @MappedSuperclass
// public abstract class StatefulEntity {
//
// /**
// * Field be set on insert. But updates must be done through the JPAPersister
// *
// */
// @State
// @Column(insertable=true, updatable=false)
// private String state;
//
// public String getState() {
// return state;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/ddd/DomainEntity.java
// @Entity
// @Scope("prototype")
// @StatefulController(
// clazz=DomainEntity.class,
// startState=STATE_A
// )
// public class DomainEntity extends StatefulEntity {
//
// // States
// //
// public final static String STATE_A = "A";
// public final static String STATE_B = "B";
//
// // Internal Events
// //
// private final static String EVENT_X = "event-x";
// private final static String EVENT_Y = "event-y";
// private final static String SPRING_EVENT_X = "springmvc:/" + EVENT_X;
// private final static String SPRING_EVENT_Y = "springmvc:/" + EVENT_Y;
//
// @Id
// private Long id;
//
// private int value;
//
// @FSM
// @Transient
// private StatefulFSM<DomainEntity> fsm;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public int getValue() {
// return value;
// }
//
// public void setValue(int value) {
// this.value = value;
// }
//
// public void onEventX(int value) throws TooBusyException {
// fsm.onEvent(this, EVENT_X, value);
// }
//
// public void onEventY(int value) throws TooBusyException {
// fsm.onEvent(this, EVENT_Y, value);
// }
//
// @Transitions({
// @Transition(from=STATE_A, event=EVENT_X, to=STATE_B),
// @Transition(from=STATE_A, event=SPRING_EVENT_X, to=STATE_B),
// })
// protected DomainEntity actionAXB(String event, Integer value) {
// System.out.println("actionAXB");
// this.value = value;
// return this;
// }
//
// @Transitions({
// @Transition(from=STATE_B, event=EVENT_Y, to=STATE_A),
// @Transition(from=STATE_B, event=SPRING_EVENT_Y, to=STATE_A),
// })
// protected DomainEntity actionBYA(String event, Integer value) {
// System.out.println("actionBYA");
// this.value = value;
// return this;
// }
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/ddd/DomainEntity.java
import static org.statefulj.framework.tests.ddd.DomainEntity.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;
import org.springframework.context.annotation.Scope;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.core.annotations.Transitions;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
import org.statefulj.persistence.jpa.model.StatefulEntity;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests.ddd;
/**
* Entity class. We will scope this as a non-singleton (prototype)
*
* @author Andrew Hall
*
*/
@Entity
@Scope("prototype")
@StatefulController(
clazz=DomainEntity.class,
startState=STATE_A
) | public class DomainEntity extends StatefulEntity { |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/ddd/DomainEntity.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: statefulj-persistence/statefulj-persistence-jpa/src/main/java/org/statefulj/persistence/jpa/model/StatefulEntity.java
// @MappedSuperclass
// public abstract class StatefulEntity {
//
// /**
// * Field be set on insert. But updates must be done through the JPAPersister
// *
// */
// @State
// @Column(insertable=true, updatable=false)
// private String state;
//
// public String getState() {
// return state;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/ddd/DomainEntity.java
// @Entity
// @Scope("prototype")
// @StatefulController(
// clazz=DomainEntity.class,
// startState=STATE_A
// )
// public class DomainEntity extends StatefulEntity {
//
// // States
// //
// public final static String STATE_A = "A";
// public final static String STATE_B = "B";
//
// // Internal Events
// //
// private final static String EVENT_X = "event-x";
// private final static String EVENT_Y = "event-y";
// private final static String SPRING_EVENT_X = "springmvc:/" + EVENT_X;
// private final static String SPRING_EVENT_Y = "springmvc:/" + EVENT_Y;
//
// @Id
// private Long id;
//
// private int value;
//
// @FSM
// @Transient
// private StatefulFSM<DomainEntity> fsm;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public int getValue() {
// return value;
// }
//
// public void setValue(int value) {
// this.value = value;
// }
//
// public void onEventX(int value) throws TooBusyException {
// fsm.onEvent(this, EVENT_X, value);
// }
//
// public void onEventY(int value) throws TooBusyException {
// fsm.onEvent(this, EVENT_Y, value);
// }
//
// @Transitions({
// @Transition(from=STATE_A, event=EVENT_X, to=STATE_B),
// @Transition(from=STATE_A, event=SPRING_EVENT_X, to=STATE_B),
// })
// protected DomainEntity actionAXB(String event, Integer value) {
// System.out.println("actionAXB");
// this.value = value;
// return this;
// }
//
// @Transitions({
// @Transition(from=STATE_B, event=EVENT_Y, to=STATE_A),
// @Transition(from=STATE_B, event=SPRING_EVENT_Y, to=STATE_A),
// })
// protected DomainEntity actionBYA(String event, Integer value) {
// System.out.println("actionBYA");
// this.value = value;
// return this;
// }
// }
| import static org.statefulj.framework.tests.ddd.DomainEntity.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;
import org.springframework.context.annotation.Scope;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.core.annotations.Transitions;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
import org.statefulj.persistence.jpa.model.StatefulEntity; | private final static String EVENT_X = "event-x";
private final static String EVENT_Y = "event-y";
private final static String SPRING_EVENT_X = "springmvc:/" + EVENT_X;
private final static String SPRING_EVENT_Y = "springmvc:/" + EVENT_Y;
@Id
private Long id;
private int value;
@FSM
@Transient
private StatefulFSM<DomainEntity> fsm;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
| // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: statefulj-persistence/statefulj-persistence-jpa/src/main/java/org/statefulj/persistence/jpa/model/StatefulEntity.java
// @MappedSuperclass
// public abstract class StatefulEntity {
//
// /**
// * Field be set on insert. But updates must be done through the JPAPersister
// *
// */
// @State
// @Column(insertable=true, updatable=false)
// private String state;
//
// public String getState() {
// return state;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/ddd/DomainEntity.java
// @Entity
// @Scope("prototype")
// @StatefulController(
// clazz=DomainEntity.class,
// startState=STATE_A
// )
// public class DomainEntity extends StatefulEntity {
//
// // States
// //
// public final static String STATE_A = "A";
// public final static String STATE_B = "B";
//
// // Internal Events
// //
// private final static String EVENT_X = "event-x";
// private final static String EVENT_Y = "event-y";
// private final static String SPRING_EVENT_X = "springmvc:/" + EVENT_X;
// private final static String SPRING_EVENT_Y = "springmvc:/" + EVENT_Y;
//
// @Id
// private Long id;
//
// private int value;
//
// @FSM
// @Transient
// private StatefulFSM<DomainEntity> fsm;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public int getValue() {
// return value;
// }
//
// public void setValue(int value) {
// this.value = value;
// }
//
// public void onEventX(int value) throws TooBusyException {
// fsm.onEvent(this, EVENT_X, value);
// }
//
// public void onEventY(int value) throws TooBusyException {
// fsm.onEvent(this, EVENT_Y, value);
// }
//
// @Transitions({
// @Transition(from=STATE_A, event=EVENT_X, to=STATE_B),
// @Transition(from=STATE_A, event=SPRING_EVENT_X, to=STATE_B),
// })
// protected DomainEntity actionAXB(String event, Integer value) {
// System.out.println("actionAXB");
// this.value = value;
// return this;
// }
//
// @Transitions({
// @Transition(from=STATE_B, event=EVENT_Y, to=STATE_A),
// @Transition(from=STATE_B, event=SPRING_EVENT_Y, to=STATE_A),
// })
// protected DomainEntity actionBYA(String event, Integer value) {
// System.out.println("actionBYA");
// this.value = value;
// return this;
// }
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/ddd/DomainEntity.java
import static org.statefulj.framework.tests.ddd.DomainEntity.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;
import org.springframework.context.annotation.Scope;
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.core.annotations.Transitions;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
import org.statefulj.persistence.jpa.model.StatefulEntity;
private final static String EVENT_X = "event-x";
private final static String EVENT_Y = "event-y";
private final static String SPRING_EVENT_X = "springmvc:/" + EVENT_X;
private final static String SPRING_EVENT_Y = "springmvc:/" + EVENT_Y;
@Id
private Long id;
private int value;
@FSM
@Transient
private StatefulFSM<DomainEntity> fsm;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
| public void onEventX(int value) throws TooBusyException { |
statefulj/statefulj | statefulj-persistence/statefulj-persistence-jpa/src/test/java/org/statefulj/persistence/jpa/embedded/EmbeddedOrder.java | // Path: statefulj-persistence/statefulj-persistence-jpa/src/main/java/org/statefulj/persistence/jpa/model/StatefulEntity.java
// @MappedSuperclass
// public abstract class StatefulEntity {
//
// /**
// * Field be set on insert. But updates must be done through the JPAPersister
// *
// */
// @State
// @Column(insertable=true, updatable=false)
// private String state;
//
// public String getState() {
// return state;
// }
// }
| import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.statefulj.persistence.jpa.model.StatefulEntity; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.persistence.jpa.embedded;
@Entity
@Table(name="EmbeddedOrders") | // Path: statefulj-persistence/statefulj-persistence-jpa/src/main/java/org/statefulj/persistence/jpa/model/StatefulEntity.java
// @MappedSuperclass
// public abstract class StatefulEntity {
//
// /**
// * Field be set on insert. But updates must be done through the JPAPersister
// *
// */
// @State
// @Column(insertable=true, updatable=false)
// private String state;
//
// public String getState() {
// return state;
// }
// }
// Path: statefulj-persistence/statefulj-persistence-jpa/src/test/java/org/statefulj/persistence/jpa/embedded/EmbeddedOrder.java
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.statefulj.persistence.jpa.model.StatefulEntity;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.persistence.jpa.embedded;
@Entity
@Table(name="EmbeddedOrders") | public class EmbeddedOrder extends StatefulEntity { |
statefulj/statefulj | statefulj-persistence/statefulj-persistence-common/src/test/java/org/statefulj/persistence/common/MockPersister.java | // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/StaleStateException.java
// public class StaleStateException extends RetryException {
//
//
// private static final long serialVersionUID = 1L;
//
// public StaleStateException() {
// super();
// }
//
// public StaleStateException(String err) {
// super(err);
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
| import java.lang.reflect.Field;
import java.util.List;
import org.statefulj.fsm.StaleStateException;
import org.statefulj.fsm.model.State; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.persistence.common;
public class MockPersister<T> extends AbstractPersister<T, String> {
public MockPersister(List<State<T>> states, String stateFieldName,
State<T> start, Class<T> clazz) {
super(states, stateFieldName, start, clazz);
}
@Override | // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/StaleStateException.java
// public class StaleStateException extends RetryException {
//
//
// private static final long serialVersionUID = 1L;
//
// public StaleStateException() {
// super();
// }
//
// public StaleStateException(String err) {
// super(err);
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
// Path: statefulj-persistence/statefulj-persistence-common/src/test/java/org/statefulj/persistence/common/MockPersister.java
import java.lang.reflect.Field;
import java.util.List;
import org.statefulj.fsm.StaleStateException;
import org.statefulj.fsm.model.State;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.persistence.common;
public class MockPersister<T> extends AbstractPersister<T, String> {
public MockPersister(List<State<T>> states, String stateFieldName,
State<T> start, Class<T> clazz) {
super(states, stateFieldName, start, clazz);
}
@Override | public void setCurrent(T stateful, State<T> current, State<T> next) throws StaleStateException { |
statefulj/statefulj | statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/DeterministicTransitionImpl.java | // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/StateActionPair.java
// public interface StateActionPair<T> {
//
// /**
// * @return the {@link org.statefulj.fsm.model.State}
// */
// State<T> getState();
//
// /**
// * @return {@link org.statefulj.fsm.model.Action}
// */
// Action<T> getAction();
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Transition.java
// public interface Transition<T> {
//
// /**
// * Return the {@link org.statefulj.fsm.model.StateActionPair}
// *
// * @param stateful the Stateful Entity
// *
// * @return the {@link org.statefulj.fsm.model.StateActionPair}
// * @param event The occurring Event
// * @param args Optional parameters that was passed into the FSM
// *
// * @throws RetryException is thrown if there is an error determining the next State and Action and the FSM should
// * re-process the event
// */
// StateActionPair<T> getStateActionPair(T stateful, String event, Object ... args) throws RetryException;
// }
| import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.StateActionPair;
import org.statefulj.fsm.model.Transition; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.fsm.model.impl;
public class DeterministicTransitionImpl<T> implements Transition<T> {
private StateActionPair<T> stateActionPair;
| // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/StateActionPair.java
// public interface StateActionPair<T> {
//
// /**
// * @return the {@link org.statefulj.fsm.model.State}
// */
// State<T> getState();
//
// /**
// * @return {@link org.statefulj.fsm.model.Action}
// */
// Action<T> getAction();
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Transition.java
// public interface Transition<T> {
//
// /**
// * Return the {@link org.statefulj.fsm.model.StateActionPair}
// *
// * @param stateful the Stateful Entity
// *
// * @return the {@link org.statefulj.fsm.model.StateActionPair}
// * @param event The occurring Event
// * @param args Optional parameters that was passed into the FSM
// *
// * @throws RetryException is thrown if there is an error determining the next State and Action and the FSM should
// * re-process the event
// */
// StateActionPair<T> getStateActionPair(T stateful, String event, Object ... args) throws RetryException;
// }
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/DeterministicTransitionImpl.java
import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.StateActionPair;
import org.statefulj.fsm.model.Transition;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.fsm.model.impl;
public class DeterministicTransitionImpl<T> implements Transition<T> {
private StateActionPair<T> stateActionPair;
| public DeterministicTransitionImpl(State<T> from, State<T> to, String event) { |
statefulj/statefulj | statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/DeterministicTransitionImpl.java | // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/StateActionPair.java
// public interface StateActionPair<T> {
//
// /**
// * @return the {@link org.statefulj.fsm.model.State}
// */
// State<T> getState();
//
// /**
// * @return {@link org.statefulj.fsm.model.Action}
// */
// Action<T> getAction();
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Transition.java
// public interface Transition<T> {
//
// /**
// * Return the {@link org.statefulj.fsm.model.StateActionPair}
// *
// * @param stateful the Stateful Entity
// *
// * @return the {@link org.statefulj.fsm.model.StateActionPair}
// * @param event The occurring Event
// * @param args Optional parameters that was passed into the FSM
// *
// * @throws RetryException is thrown if there is an error determining the next State and Action and the FSM should
// * re-process the event
// */
// StateActionPair<T> getStateActionPair(T stateful, String event, Object ... args) throws RetryException;
// }
| import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.StateActionPair;
import org.statefulj.fsm.model.Transition; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.fsm.model.impl;
public class DeterministicTransitionImpl<T> implements Transition<T> {
private StateActionPair<T> stateActionPair;
public DeterministicTransitionImpl(State<T> from, State<T> to, String event) {
stateActionPair = new StateActionPairImpl<T>(to, null);
from.addTransition(event, this);
}
| // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/StateActionPair.java
// public interface StateActionPair<T> {
//
// /**
// * @return the {@link org.statefulj.fsm.model.State}
// */
// State<T> getState();
//
// /**
// * @return {@link org.statefulj.fsm.model.Action}
// */
// Action<T> getAction();
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Transition.java
// public interface Transition<T> {
//
// /**
// * Return the {@link org.statefulj.fsm.model.StateActionPair}
// *
// * @param stateful the Stateful Entity
// *
// * @return the {@link org.statefulj.fsm.model.StateActionPair}
// * @param event The occurring Event
// * @param args Optional parameters that was passed into the FSM
// *
// * @throws RetryException is thrown if there is an error determining the next State and Action and the FSM should
// * re-process the event
// */
// StateActionPair<T> getStateActionPair(T stateful, String event, Object ... args) throws RetryException;
// }
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/DeterministicTransitionImpl.java
import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.StateActionPair;
import org.statefulj.fsm.model.Transition;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.fsm.model.impl;
public class DeterministicTransitionImpl<T> implements Transition<T> {
private StateActionPair<T> stateActionPair;
public DeterministicTransitionImpl(State<T> from, State<T> to, String event) {
stateActionPair = new StateActionPairImpl<T>(to, null);
from.addTransition(event, this);
}
| public DeterministicTransitionImpl(State<T> from, State<T> to, String event, Action<T> action) { |
statefulj/statefulj | statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/controllers/UserController.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/model/User.java
// public class User {
//
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
| import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.core.model.User; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.core.controllers;
@StatefulController(
clazz=User.class,
startState=UserController.ONE_STATE,
blockingStates={UserController.FIVE_STATE},
noops={
@Transition(event="mock:four", to=UserController.FOUR_STATE),
@Transition(event="five", to=UserController.FIVE_STATE)
}
)
public class UserController {
// States
//
public static final String ONE_STATE = "one";
public static final String TWO_STATE = "two";
public static final String THREE_STATE = "three";
public static final String FOUR_STATE = "four";
public static final String FIVE_STATE = "five";
@FSM | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/model/User.java
// public class User {
//
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
// Path: statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/controllers/UserController.java
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.core.model.User;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.core.controllers;
@StatefulController(
clazz=User.class,
startState=UserController.ONE_STATE,
blockingStates={UserController.FIVE_STATE},
noops={
@Transition(event="mock:four", to=UserController.FOUR_STATE),
@Transition(event="five", to=UserController.FIVE_STATE)
}
)
public class UserController {
// States
//
public static final String ONE_STATE = "one";
public static final String TWO_STATE = "two";
public static final String THREE_STATE = "three";
public static final String FOUR_STATE = "four";
public static final String FIVE_STATE = "five";
@FSM | StatefulFSM<User> fsm; |
statefulj/statefulj | statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/StateImpl.java | // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Transition.java
// public interface Transition<T> {
//
// /**
// * Return the {@link org.statefulj.fsm.model.StateActionPair}
// *
// * @param stateful the Stateful Entity
// *
// * @return the {@link org.statefulj.fsm.model.StateActionPair}
// * @param event The occurring Event
// * @param args Optional parameters that was passed into the FSM
// *
// * @throws RetryException is thrown if there is an error determining the next State and Action and the FSM should
// * re-process the event
// */
// StateActionPair<T> getStateActionPair(T stateful, String event, Object ... args) throws RetryException;
// }
| import java.util.HashMap;
import java.util.Map;
import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.Transition; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.fsm.model.impl;
public class StateImpl<T> implements State<T> {
private String name; | // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Transition.java
// public interface Transition<T> {
//
// /**
// * Return the {@link org.statefulj.fsm.model.StateActionPair}
// *
// * @param stateful the Stateful Entity
// *
// * @return the {@link org.statefulj.fsm.model.StateActionPair}
// * @param event The occurring Event
// * @param args Optional parameters that was passed into the FSM
// *
// * @throws RetryException is thrown if there is an error determining the next State and Action and the FSM should
// * re-process the event
// */
// StateActionPair<T> getStateActionPair(T stateful, String event, Object ... args) throws RetryException;
// }
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/StateImpl.java
import java.util.HashMap;
import java.util.Map;
import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.Transition;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.fsm.model.impl;
public class StateImpl<T> implements State<T> {
private String name; | private Map<String, Transition<T>> transitions = new HashMap<String, Transition<T>>(); |
statefulj/statefulj | statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/StateImpl.java | // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Transition.java
// public interface Transition<T> {
//
// /**
// * Return the {@link org.statefulj.fsm.model.StateActionPair}
// *
// * @param stateful the Stateful Entity
// *
// * @return the {@link org.statefulj.fsm.model.StateActionPair}
// * @param event The occurring Event
// * @param args Optional parameters that was passed into the FSM
// *
// * @throws RetryException is thrown if there is an error determining the next State and Action and the FSM should
// * re-process the event
// */
// StateActionPair<T> getStateActionPair(T stateful, String event, Object ... args) throws RetryException;
// }
| import java.util.HashMap;
import java.util.Map;
import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.Transition; | public void setName(String name) {
this.name = name;
}
public Transition<T> getTransition(String event) {
return transitions.get(event);
}
public Map<String, Transition<T>> getTransitions() {
return transitions;
}
public void setTransitions(Map<String, Transition<T>> transitions) {
this.transitions = transitions;
}
public boolean isEndState() {
return isEndState;
}
public void setEndState(boolean isEndState) {
this.isEndState = isEndState;
}
@Override
public void addTransition(String event, State<T> next) {
this.transitions.put(event, new DeterministicTransitionImpl<T>(next, null));
}
@Override | // Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Transition.java
// public interface Transition<T> {
//
// /**
// * Return the {@link org.statefulj.fsm.model.StateActionPair}
// *
// * @param stateful the Stateful Entity
// *
// * @return the {@link org.statefulj.fsm.model.StateActionPair}
// * @param event The occurring Event
// * @param args Optional parameters that was passed into the FSM
// *
// * @throws RetryException is thrown if there is an error determining the next State and Action and the FSM should
// * re-process the event
// */
// StateActionPair<T> getStateActionPair(T stateful, String event, Object ... args) throws RetryException;
// }
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/StateImpl.java
import java.util.HashMap;
import java.util.Map;
import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.Transition;
public void setName(String name) {
this.name = name;
}
public Transition<T> getTransition(String event) {
return transitions.get(event);
}
public Map<String, Transition<T>> getTransitions() {
return transitions;
}
public void setTransitions(Map<String, Transition<T>> transitions) {
this.transitions = transitions;
}
public boolean isEndState() {
return isEndState;
}
public void setEndState(boolean isEndState) {
this.isEndState = isEndState;
}
@Override
public void addTransition(String event, State<T> next) {
this.transitions.put(event, new DeterministicTransitionImpl<T>(next, null));
}
@Override | public void addTransition(String event, State<T> next, Action<T> action) { |
statefulj/statefulj | statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/controllers/MemoryController.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/model/User.java
// public class User {
//
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
| import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.core.model.User; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.core.controllers;
@StatefulController(
clazz=User.class,
startState=MemoryController.ONE_STATE
)
public class MemoryController {
// States
//
public static final String ONE_STATE = "one";
public static final String TWO_STATE = "two";
@FSM | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/model/User.java
// public class User {
//
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
// Path: statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/controllers/MemoryController.java
import org.statefulj.framework.core.annotations.FSM;
import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.framework.core.model.User;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.core.controllers;
@StatefulController(
clazz=User.class,
startState=MemoryController.ONE_STATE
)
public class MemoryController {
// States
//
public static final String ONE_STATE = "one";
public static final String TWO_STATE = "two";
@FSM | StatefulFSM<User> fsm; |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/controllers/UserController.java | // Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/dao/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
| import javax.annotation.Resource;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.tests.dao.UserRepository;
import org.statefulj.framework.tests.model.User;
import static org.statefulj.framework.tests.model.User.*; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests.controllers;
@StatefulController(
clazz=User.class,
startState=ONE_STATE,
blockingStates={SIX_STATE},
noops={
@Transition(event="springmvc:/{id}/four", to=FOUR_STATE),
@Transition(event="five", to=FIVE_STATE),
@Transition(event="camel:six", to=SIX_STATE),
@Transition(event="unblock", to=SEVEN_STATE),
}
)
public class UserController {
@Resource | // Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/dao/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
//
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
// @Entity
// @Table(name="users")
// public class User extends StatefulEntity {
//
// // States
// //
// public static final String ONE_STATE = "one";
// public static final String TWO_STATE = "two";
// public static final String THREE_STATE = "three";
// public static final String FOUR_STATE = "four";
// public static final String FIVE_STATE = "five";
// public static final String SIX_STATE = "six";
// public static final String SEVEN_STATE = "seven";
//
// @Id
// @GeneratedValue(strategy=GenerationType.SEQUENCE)
// Long id;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/controllers/UserController.java
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.statefulj.framework.core.annotations.StatefulController;
import org.statefulj.framework.core.annotations.Transition;
import org.statefulj.framework.tests.dao.UserRepository;
import org.statefulj.framework.tests.model.User;
import static org.statefulj.framework.tests.model.User.*;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests.controllers;
@StatefulController(
clazz=User.class,
startState=ONE_STATE,
blockingStates={SIX_STATE},
noops={
@Transition(event="springmvc:/{id}/four", to=FOUR_STATE),
@Transition(event="five", to=FIVE_STATE),
@Transition(event="camel:six", to=SIX_STATE),
@Transition(event="unblock", to=SEVEN_STATE),
}
)
public class UserController {
@Resource | UserRepository userRepository; |
statefulj/statefulj | statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/mocks/MockBinder.java | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/EndpointBinder.java
// public interface EndpointBinder {
//
// /**
// * Returns the "key" for this EndpointBinder. The key is the first part of the tuple in an Event.
// * For example, the key for the SpringMVC binder is "springmvc".
// *
// * @return The first part of the tuple in an Event
// */
// String getKey();
//
// /**
// * Invoked by the StatefulController to construct an EndpointBinder Class
// *
// * @param beanName The Spring Bean Name for the Endpoint Binder
// * @param stateControllerClass The class of the associated {@link org.statefulj.framework.core.annotations.StatefulController}
// * @param idType The Class Type of the id field for the associated StatefulEntity
// * @param isDomainEntity A flag indicating the StatefulEntity and the {@link org.statefulj.framework.core.annotations.StatefulController} are one in the same
// * @param eventMapping Association of Event to the Action Method
// * @param refFactory The {@link org.statefulj.framework.core.model.ReferenceFactory} that generates all Spring Bean ids
// * @return The generated Class of the EndpointBinder
// * @throws CannotCompileException
// * @throws NotFoundException
// * @throws IllegalArgumentException
// * @throws IllegalAccessException
// * @throws InvocationTargetException
// */
// Class<?> bindEndpoints(
// String beanName,
// Class<?> stateControllerClass,
// Class<?> idType,
// boolean isDomainEntity,
// Map<String, Method> eventMapping,
// ReferenceFactory refFactory) throws CannotCompileException, NotFoundException, IllegalArgumentException, IllegalAccessException, InvocationTargetException;
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/ReferenceFactory.java
// public interface ReferenceFactory {
//
// String getBinderId(String key);
//
// String getFinderId();
//
// String getFSMHarnessId();
//
// String getPersisterId();
//
// String getFactoryId();
//
// String getStatefulFSMId();
//
// String getFSMId();
//
// String getStateId(String state);
//
// String getTransitionId(int cnt);
//
// String getActionId(Method method);
//
// }
| import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import javassist.CannotCompileException;
import javassist.NotFoundException;
import org.statefulj.framework.core.model.EndpointBinder;
import org.statefulj.framework.core.model.ReferenceFactory; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.core.mocks;
public class MockBinder implements EndpointBinder {
@Override
public String getKey() {
return "mock";
}
@Override
public Class<?> bindEndpoints(
String beanId,
Class<?> stateControllerClass,
Class<?> idType,
boolean isDomainEntity,
Map<String, Method> eventMapping, | // Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/EndpointBinder.java
// public interface EndpointBinder {
//
// /**
// * Returns the "key" for this EndpointBinder. The key is the first part of the tuple in an Event.
// * For example, the key for the SpringMVC binder is "springmvc".
// *
// * @return The first part of the tuple in an Event
// */
// String getKey();
//
// /**
// * Invoked by the StatefulController to construct an EndpointBinder Class
// *
// * @param beanName The Spring Bean Name for the Endpoint Binder
// * @param stateControllerClass The class of the associated {@link org.statefulj.framework.core.annotations.StatefulController}
// * @param idType The Class Type of the id field for the associated StatefulEntity
// * @param isDomainEntity A flag indicating the StatefulEntity and the {@link org.statefulj.framework.core.annotations.StatefulController} are one in the same
// * @param eventMapping Association of Event to the Action Method
// * @param refFactory The {@link org.statefulj.framework.core.model.ReferenceFactory} that generates all Spring Bean ids
// * @return The generated Class of the EndpointBinder
// * @throws CannotCompileException
// * @throws NotFoundException
// * @throws IllegalArgumentException
// * @throws IllegalAccessException
// * @throws InvocationTargetException
// */
// Class<?> bindEndpoints(
// String beanName,
// Class<?> stateControllerClass,
// Class<?> idType,
// boolean isDomainEntity,
// Map<String, Method> eventMapping,
// ReferenceFactory refFactory) throws CannotCompileException, NotFoundException, IllegalArgumentException, IllegalAccessException, InvocationTargetException;
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/ReferenceFactory.java
// public interface ReferenceFactory {
//
// String getBinderId(String key);
//
// String getFinderId();
//
// String getFSMHarnessId();
//
// String getPersisterId();
//
// String getFactoryId();
//
// String getStatefulFSMId();
//
// String getFSMId();
//
// String getStateId(String state);
//
// String getTransitionId(int cnt);
//
// String getActionId(Method method);
//
// }
// Path: statefulj-framework/statefulj-framework-core/src/test/java/org/statefulj/framework/core/mocks/MockBinder.java
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import javassist.CannotCompileException;
import javassist.NotFoundException;
import org.statefulj.framework.core.model.EndpointBinder;
import org.statefulj.framework.core.model.ReferenceFactory;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.core.mocks;
public class MockBinder implements EndpointBinder {
@Override
public String getKey() {
return "mock";
}
@Override
public Class<?> bindEndpoints(
String beanId,
Class<?> stateControllerClass,
Class<?> idType,
boolean isDomainEntity,
Map<String, Method> eventMapping, | ReferenceFactory refFactory) |
statefulj/statefulj | statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java | // Path: statefulj-persistence/statefulj-persistence-jpa/src/main/java/org/statefulj/persistence/jpa/model/StatefulEntity.java
// @MappedSuperclass
// public abstract class StatefulEntity {
//
// /**
// * Field be set on insert. But updates must be done through the JPAPersister
// *
// */
// @State
// @Column(insertable=true, updatable=false)
// private String state;
//
// public String getState() {
// return state;
// }
// }
| import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.statefulj.persistence.jpa.model.StatefulEntity; | /***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests.model;
@Entity
@Table(name="users") | // Path: statefulj-persistence/statefulj-persistence-jpa/src/main/java/org/statefulj/persistence/jpa/model/StatefulEntity.java
// @MappedSuperclass
// public abstract class StatefulEntity {
//
// /**
// * Field be set on insert. But updates must be done through the JPAPersister
// *
// */
// @State
// @Column(insertable=true, updatable=false)
// private String state;
//
// public String getState() {
// return state;
// }
// }
// Path: statefulj-framework/statefulj-framework-tests/src/test/java/org/statefulj/framework/tests/model/User.java
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.statefulj.persistence.jpa.model.StatefulEntity;
/***
*
* Copyright 2014 Andrew Hall
*
* 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 org.statefulj.framework.tests.model;
@Entity
@Table(name="users") | public class User extends StatefulEntity { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.