Skip to content

Improve environment#594

Merged
alexander-yevsyukov merged 19 commits intomasterfrom
improve-environment
Nov 26, 2020
Merged

Improve environment#594
alexander-yevsyukov merged 19 commits intomasterfrom
improve-environment

Conversation

@alexander-yevsyukov
Copy link
Contributor

@alexander-yevsyukov alexander-yevsyukov commented Nov 25, 2020

This PR improves the API of working with the Environment, making it consistent with how ServerEnvironment works in core-java.

Notable changes:

  • CustomEnvironmentType was introduced primarily for helping understand the concept of a custom type, and avoid ambiguity when speaking about “mutual exclusivity”. Previously, all the types were descending from EnvironmentType and two of them being Tests and Production were always present, and, thus, one of them could not be mutually exclusive with a custom one. Yes, they were standard ones, but it still raised the question, and because of that...
  • StandardEnvironmentType was introduced. It's package-private with the primary purpose of groping Tests and Production types together.
  • Registering a type now accepts Class<? extends CustomEnvironmentType>, not an instance of a type. This plays nicer with ServerEnvironment.when(Class). As we mimic enums let's be operating with classes, not instances.
  • Deprecated methods in Environment were removed.
  • The publicly exposed constant with a list of unit testing packages were hidden because of a security warning. The list is now returned by a method, with its Javadoc enumerating the returned values.

@codecov
Copy link

codecov bot commented Nov 25, 2020

Codecov Report

Merging #594 (c0193f4) into master (954c181) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master     #594      +/-   ##
============================================
+ Coverage     77.73%   77.77%   +0.04%     
  Complexity     3036     3036              
============================================
  Files           509      510       +1     
  Lines         11538    11529       -9     
  Branches        669      670       +1     
============================================
- Hits           8969     8967       -2     
+ Misses         2341     2335       -6     
+ Partials        228      227       -1     

@armiol
Copy link
Collaborator

armiol commented Nov 26, 2020

@alexander-yevsyukov LGMT as soon as the builds pass.

Also, I remembered why we had .register(instance), not .register(type). That's because we wanted the developer to be able to feed some dependencies (such as clients to Google Cloud or AWS APIs) into the environment types.

However, now I think that was an over-complication as there was no such cases at the moment. Still, we will probably face such a need some time in future. Once we do, we'll design a solution for it.

@alexander-yevsyukov alexander-yevsyukov merged commit 9760704 into master Nov 26, 2020
@alexander-yevsyukov alexander-yevsyukov deleted the improve-environment branch November 26, 2020 14:24
This was referenced Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants