Skip to content

Commit

Permalink
cleaned up and formated code
Browse files Browse the repository at this point in the history
- Added `RemoteResourceInfo`, `LocalResourceInfo`, and `VirtualResourceInfo` contracts
- Added methods to `TestContext` to get local, remote, and virtual resources.
- Added `DefaultRemoteResourceInfo`, `DefaultLocalResourceInfo`, and `DefaultVirtualResourceInfo` implementations to replace `DefaultResourceInstance`
- Renamed `ResourceInstance` contract to `ResourceInfo`
- Removed `DefaultResourceInstance`
  • Loading branch information
saden1 committed Sep 14, 2017
1 parent 53efc68 commit d8f2b79
Show file tree
Hide file tree
Showing 534 changed files with 4,386 additions and 2,656 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ was added, changed, deprecated, removed, fix and security fixes.
- Added `ClientInstanceBuilder` class to build client instances.
- Added the ability to get local, virtual and remote resources from the `TestContext`
- Added a method to get application annotation from `ServerInstance` contract
- Added a default implementation of `ServiceInstance` contract that can be used in unit tests
- Added a default implementation `DefaultServiceInstance` of `ServiceInstance` contract that can be used in unit tests
- Added `RemoteResourceInfo`, `LocalResourceInfo`, and `VirtualResourceInfo` contracts
- Added methods to `TestContext` to get local, remote, and virtual resources.
- Added `DefaultRemoteResourceInfo`, `DefaultLocalResourceInfo`, and `DefaultVirtualResourceInfo` implementations to replace `DefaultResourceInstance`

### Changed
- Renamed `getDefinedName` method `FieldDescriptor` and `MethodDescriptor` to `getDeclaredName`
Expand All @@ -35,9 +38,11 @@ was added, changed, deprecated, removed, fix and security fixes.
- Changed ClientInstance contract to return client and clientProvider instances. Also added methods to get `fqn` and `annotation`.
- Renamed `PropertiesWriter#addListElement` and `PropertiesReader#findList`
- Changed return types of methods that return `List` to `Collection`
- Renamed `ResourceInstance` contract to `ResourceInfo`

### Removed
- Removed `name` attribute from `@Fake`, `@Virtual` and `@Real`. `@Named` can be used on the field as a replacement.
- Removed `DefaultResourceInstance`

## [0.9.8] - 2017-08-12
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import org.testifyproject.trait.PropertiesWriter;

/**
* A contract that defines methods for retrieving information about an
* application.
* A contract that defines methods for retrieving information about an application.
*
* @author saden
*/
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/org/testifyproject/ClientInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
package org.testifyproject;

import java.util.Optional;

import org.testifyproject.annotation.Application;
import org.testifyproject.trait.PropertiesReader;

/**
* A contract that defines methods for retrieving information about a client and
* communicating with the application under test.
* A contract that defines methods for retrieving information about a client and communicating with
* the application under test.
*
* @author saden
* @param <C> the client
Expand Down
11 changes: 6 additions & 5 deletions api/src/main/java/org/testifyproject/ClientProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
package org.testifyproject;

import java.net.URI;

import org.testifyproject.annotation.Application;

/**
* A contract that defines methods for configuring, initializing and destroying
* a client used to communicate with the server.
* A contract that defines methods for configuring, initializing and destroying a client used to
* communicate with the server.
*
* @author saden
* @param <T> the client configuration type
Expand All @@ -39,16 +40,16 @@ public interface ClientProvider<T, C> {
T configure(TestContext testContext, Application application, URI baseURI);

/**
* Create and initialize the client instance using the given base URI and
* configuration object.
* Create and initialize the client instance using the given base URI and configuration object.
*
* @param testContext the test context
* @param application the application annotation
* @param baseURI the base server URI
* @param configuration client configuration object
* @return a client instance.
*/
ClientInstance<C> create(TestContext testContext, Application application, URI baseURI, T configuration);
ClientInstance<C> create(TestContext testContext, Application application, URI baseURI,
T configuration);

/**
* This method will dispose of client instance that was created.
Expand Down
17 changes: 7 additions & 10 deletions api/src/main/java/org/testifyproject/FieldDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,22 @@
import org.testifyproject.trait.FieldTrait;

/**
* A contract that defines methods to access properties of or perform operations
* on a field.
* A contract that defines methods to access properties of or perform operations on a field.
*
* @author saden
*/
public interface FieldDescriptor extends FieldTrait, FieldAnnotationTrait {

/**
* <p>
* Get the explicitly defined field name. Please note that field names are
* explicitly defined by annotating the field with
* {@link org.testifyproject.annotation.Name}.
* Get the explicitly defined field name. Please note that field names are explicitly defined by
* annotating the field with {@link org.testifyproject.annotation.Name}.
* </p>
* <p>
* In the event a field name is not explicitly defined the value returned by
* calling {@link java.lang.reflect.Field#getName()} will be returned.
* Please note that name detection only works if your code is compiled with
* parameter names or debug information (javac -parameters or javac
* -g:vars).
* In the event a field name is not explicitly defined the value returned by calling
* {@link java.lang.reflect.Field#getName()} will be returned. Please note that name detection
* only works if your code is compiled with parameter names or debug information (javac
* -parameters or javac -g:vars).
* </p>
*
* @return the field name
Expand Down
18 changes: 9 additions & 9 deletions api/src/main/java/org/testifyproject/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
*/
package org.testifyproject;

import java.util.Optional;
import static java.util.Optional.empty;

import java.util.Optional;

/**
* A contract that defines an instance object. An instance represents the
* properties of an object in the dependency injection framework in use and how
* the object is made available for injection into test classes and fixtures.
* A contract that defines an instance object. An instance represents the properties of an object in
* the dependency injection framework in use and how the object is made available for injection into
* test classes and fixtures.
*
* @author saden
* @param <T> the instance object type
Expand All @@ -36,8 +37,8 @@ public interface Instance<T> {
T getValue();

/**
* Get the name of instance. If present it represents the service name
* associated with the instance and may be used to qualify the service.
* Get the name of instance. If present it represents the service name associated with the
* instance and may be used to qualify the service.
*
* @return optional with instance name, empty optional otherwise
*/
Expand All @@ -46,9 +47,8 @@ default Optional<String> getName() {
}

/**
* The contract implemented by the instance. If present any existing
* implementations of the contract in the dependency injection framework
* will be replaced by this instance.
* The contract implemented by the instance. If present any existing implementations of the
* contract in the dependency injection framework will be replaced by this instance.
*
* @return optional with instance contract type, empty optional otherwise
*/
Expand Down
28 changes: 28 additions & 0 deletions api/src/main/java/org/testifyproject/LocalResourceInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2016-2017 Testify Project.
*
* 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.testifyproject;

import org.testifyproject.annotation.LocalResource;

/**
* A contract that defines a local resource instance.
*
* @author saden
*/
public interface LocalResourceInfo extends
ResourceInfo<LocalResource, LocalResourceProvider, LocalResourceInstance> {

}
11 changes: 5 additions & 6 deletions api/src/main/java/org/testifyproject/LocalResourceInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
package org.testifyproject;

import java.util.Optional;

import org.testifyproject.annotation.LocalResource;
import org.testifyproject.trait.PropertiesReader;

/**
* A contract that defines methods to get information about a local resource
* instance. A local resource instance consists of a resource, an optional
* client that can be used to communicate with the local resource, and
* properties associated with the local resource instance.
* A contract that defines methods to get information about a local resource instance. A local
* resource instance consists of a resource, an optional client that can be used to communicate with
* the local resource, and properties associated with the local resource instance.
*
* @author saden
* @param <R> the underlying local resource type
Expand All @@ -40,8 +40,7 @@ public interface LocalResourceInstance<R, C> extends PropertiesReader {
String getFqn();

/**
* Get the local resource annotation associated with the local resource
* instance.
* Get the local resource annotation associated with the local resource instance.
*
* @return the local resource annotation
*/
Expand Down
44 changes: 22 additions & 22 deletions api/src/main/java/org/testifyproject/LocalResourceProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.testifyproject;

import java.util.Set;

import org.testifyproject.annotation.LocalResource;
import org.testifyproject.trait.PropertiesReader;

Expand All @@ -31,34 +32,31 @@ public interface LocalResourceProvider<T, R, C> {

/**
* <p>
* A method to configure a local resource. Configuring a local resource
* typically involves creating a default configuration object that can be
* further configured by a
* A method to configure a local resource. Configuring a local resource typically involves
* creating a default configuration object that can be further configured by a
* {@link org.testifyproject.annotation.ConfigHandler} method.
* </p>
* <p>
* Note:
* </p>
* <ul>
* <li>Implementation of this method should not do any work beyond returning
* configuration object. It should be stateless and should not perform
* instantiation of the local resource as that should be handled in
* {@link #start(org.testifyproject.TestContext, org.testifyproject.annotation.LocalResource, java.lang.Object) }
* <li>Implementation of this method should not do any work beyond returning configuration
* object. It should be stateless and should not perform instantiation of the local resource as
* that should be handled in
* {@link #start(org.testifyproject.TestContext, org.testifyproject.annotation.LocalResource, java.lang.Object)}
* method.
* </li>
* <li>
* The value of PropertiesReader by default encapsulates
* {@code .testify.yml} configuration properties. A specific section in
* {@code .testify.yml} can be specified through {@link LocalResource#configKey()
* The value of PropertiesReader by default encapsulates {@code .testify.yml} configuration
* properties. A specific section in {@code .testify.yml} can be specified through {@link LocalResource#configKey()
* }.
* </li>
* <li>
* The configuration object returned by this method is simply default
* configuration. It can be updated or replaced with entirely new
* configuration object by the
* {@link org.testifyproject.annotation.ConfigHandler} method before it is
* passed to {@link #start(org.testifyproject.TestContext, org.testifyproject.annotation.LocalResource, java.lang.Object)
* } method
* The configuration object returned by this method is simply default configuration. It can be
* updated or replaced with entirely new configuration object by the
* {@link org.testifyproject.annotation.ConfigHandler} method before it is passed to
* {@link #start(org.testifyproject.TestContext, org.testifyproject.annotation.LocalResource, java.lang.Object)}
* method
* </li>
* </ul>
*
Expand All @@ -67,7 +65,8 @@ public interface LocalResourceProvider<T, R, C> {
* @param configReader the value of configReader
* @return the T
*/
T configure(TestContext testContext, LocalResource localResource, PropertiesReader configReader);
T configure(TestContext testContext, LocalResource localResource,
PropertiesReader configReader);

/**
* Start the local resource with the given testContext and configuration.
Expand All @@ -78,13 +77,13 @@ public interface LocalResourceProvider<T, R, C> {
* @return a local resource instance
* @throws java.lang.Exception an exception thrown while starting
*/
LocalResourceInstance<R, C> start(TestContext testContext, LocalResource localResource, T config)
LocalResourceInstance<R, C> start(TestContext testContext, LocalResource localResource,
T config)
throws Exception;

/**
* Load the given list of data file into the local resource prior to the
* resource being used. Note that by default this method does not have to be
* implemented.
* Load the given list of data file into the local resource prior to the resource being used.
* Note that by default this method does not have to be implemented.
*
* @param testContext the test context
* @param localResource test class local resource annotation
Expand All @@ -107,7 +106,8 @@ default void load(TestContext testContext,
* @param instance the local resource instance
* @throws java.lang.Exception an exception thrown while stopping
*/
void stop(TestContext testContext, LocalResource localResource, LocalResourceInstance<R, C> instance)
void stop(TestContext testContext, LocalResource localResource,
LocalResourceInstance<R, C> instance)
throws Exception;

}
18 changes: 8 additions & 10 deletions api/src/main/java/org/testifyproject/MethodDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
package org.testifyproject;

import java.util.Optional;

import org.testifyproject.trait.MethodTrait;

/**
* A contract that defines methods to access properties of or perform operations
* on a method.
* A contract that defines methods to access properties of or perform operations on a method.
*
* @author saden
*/
Expand All @@ -35,16 +35,14 @@ public interface MethodDescriptor extends MethodTrait {

/**
* <p>
* Get the explicitly defined method name. Please note that method names are
* explicitly defined by annotating the method with
* {@link org.testifyproject.annotation.Name}.
* Get the explicitly defined method name. Please note that method names are explicitly defined
* by annotating the method with {@link org.testifyproject.annotation.Name}.
* </p>
* <p>
* In the event a method name is not explicitly defined the value returned
* by calling {@link java.lang.reflect.Method#getName()} will be returned.
* Please note that name detection only works if your code is compiled with
* parameter names or debug information (javac -parameters or javac
* -g:vars).
* In the event a method name is not explicitly defined the value returned by calling
* {@link java.lang.reflect.Method#getName()} will be returned. Please note that name detection
* only works if your code is compiled with parameter names or debug information (javac
* -parameters or javac -g:vars).
* </p>
*
* @return the method name
Expand Down
9 changes: 3 additions & 6 deletions api/src/main/java/org/testifyproject/MockProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public interface MockProvider {
<T> T createFake(Class<? extends T> type);

/**
* Create a virtual instance of the given type that delegates to the given
* instance.
* Create a virtual instance of the given type that delegates to the given instance.
*
* @param <T> the type of the object being virtualized
* @param type the class of the type being virtualized
Expand All @@ -43,8 +42,7 @@ public interface MockProvider {
<T> T createVirtual(Class<? extends T> type, T delegate);

/**
* Create a virtual instance of the given type that delegates to the given
* instance.
* Create a virtual instance of the given type that delegates to the given instance.
*
* @param <T> the type of the object being virtualized
* @param type the class of the type being virtualized
Expand All @@ -56,8 +54,7 @@ default <T> T createVirtualSut(Class<? extends T> type, T delegate) {
}

/**
* Verify all interaction between the system under test and its
* collaborators.
* Verify all interaction between the system under test and its collaborators.
*
* @param collaborators an array of collaborators that will be verified
*/
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/org/testifyproject/ParameterDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
package org.testifyproject;

import java.lang.reflect.Parameter;

import org.testifyproject.trait.AnnotationTrait;
import org.testifyproject.trait.TypeTrait;

/**
* A contract that defines methods to access properties of or perform operations
* on a system under test (SUT) constructor parameters.
* A contract that defines methods to access properties of or perform operations on a system under
* test (SUT) constructor parameters.
*
* @author saden
*/
Expand Down
Loading

0 comments on commit d8f2b79

Please sign in to comment.