SlideShare a Scribd company logo
Stateful mock servers to the
rescue on REST ecosystems
netponto - 2018-04-07
Nuno Caneco
Nuno Caneco
/@nuno.caneco
/nunocaneco
nuno.caneco@gmail.com
Engineering Manager / Cluster Lead
@nunocaneco
Raise your hands
The Monolith
A monolith is a geological feature consisting of a single massive stone or rock, such as some
mountains, or a single large piece of rock placed as, or within, a monument or building.
https://en.wikipedia.org/wiki/Monolith
A software system is called "monolithic" if it has a monolithic architecture, in which functionally
distinguishable aspects (for example data input and output, data processing, error handling, and the
user interface) are all interwoven, rather than containing architecturally separate components.
https://en.wikipedia.org/wiki/Monolithic_system
Monolithic architecture
Storefront
UI
Backoffice
UI
Catalog Service
User Service
Order Service
(...)
Database
Mobile
Web API
Microservices architecture
Storefront
UI
Backoffice
UI
User
Service
Mobile
Web API
Catalog
Service
Order
Service
REST
REST has become the default technology to support Microservices Architecture
● It's HTTP(S)
● Use HTTP Verbs for actions: GET, PUT, POST, DELETE, PATCH, ...
● Use HTTP Status Codes to provide meaningful and normalized responses to
clients
● Easily extensible using HTTP Headers
● Support multiple authentication mechanisms
● JSON is more simple and less verbose than XML
The growth of a
Microservice
Application
Ecosystem
User interfacePublic API
Backend Services
Publish / Subscribe
Databases
BLOB Storage
3rd party systems
Component Dependency
System Complexity ~= Business Complexity
Loose coupling ; High dependency
Dependency
level = 0
Dependency
level = 10
Dependency
level = 7
Teams & Components
Combine dependency level with
● Development environment
○ Setup
○ Maintain
● Keep services up to date
● Keep database schema and data
● Test
○ Time it takes to finish tests
○ Dependency from data
● CI/CD
○ Keep a stable environment for end-to-end tests
● Contract stability
● Communication between maintainers
Fakes to the
rescue
Terminology
Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists.
Fake objects actually have working implementations, but usually take some shortcut which makes them not
suitable for production (an in memory database is a good example).
Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside
what's programmed in for the test.
Spies are stubs that also record some information based on how they were called. One form of this might be an
email service that records how many messages it was sent.
Mocks are objects pre-programmed with expectations which form a specification of the calls they are expected to
receive.
https://martinfowler.com/articles/mocksArentStubs.html
Mock your dependencies
Dependencies with real implementations are
replaced by mocked implementations that
provide similar behavior at the interface level.
Example
Example
Fake Techniques - Client Fake
Client App
XptoAPIClient
Xpto Web API
HTTP
FakeXptoAPI
Client
IXptoApiClient
Quick to implement and simple to use
No new components on the system
Using a Mock framework allows control of
results on automated tests
Doesn't test the HTTP layer
Requires coding to implement statefulness
The Production Code is not stimulated
Potential risk to "Go Live" with the Fake
instead of Real implementation
Fake Techniques - Proxy
Client App
XptoAPIClient
Xpto Web API
HTTP
Quick to implement and simple to use
Saved responses are similar to the real API
No coding necessary (although possible)
Easy to implement with containers
Very flexible: easy to modify responses
Contract changes invalidate previous saved
responses
Requires coding to implement statefulness
Difficult to implement Expectations
mechanism to integrated with automated tests
Store
and
Forward
Proxy
HTTP
Responses
Fake Techniques - Fake Server
Client App
XptoAPIClient
Xpto Web API
HTTP Not so flexible to change responses
Requires coding
Need to implement Expectations to integrate
with automated tests
Code generation accelerates development
Easy support for contract changes:
(just regenerate the code and change implementation)
Easy to create and share containers
Easy to implement statefulness
Fake Xpto Web
API
Production&Integration
Development&Tests
HTTP
Demo I
Proxy
Demo - Proxy
Movie Rating UI
MovieRating
APIClient
Movie Rating Web API
HTTP
Store
and
Forward
Proxy
Responses
Omdb API
Demo II
Fake Server
Demo - Fake Server
Movie Rating UI
MovieRating
APIClient
Movie Rating Web
API
Fake Xpto Web
API
Omdb API
Wrapping up
Integrating with docker
Using docker to launch every 1st dependency allows easy
setup of the project.
$> git clone <repo>
$> docker-compose up deps
Open solution in Visual Studio and hit F5
No expensive setup of databases, messaging systems or other services
Docker images can be versioned alongside with the versions of the API
Can be used to run component tests (not integration tests)
Summary
● Fake the 1st level dependencies to avoid having the entire dependency tree
● Choose your strategy: Client Fake, Proxy, Stateful Fake or any other that suits
● Consider generating as much code as possible
● Potentially high upfront investment - big gains in the long run
● Make it easy for the developers to
○ Run the project
○ Manage the versions of the dependencies they are using
○ Write automated tests
● Make components tests running against Fakes instead
ANY QUESTIONS?
/@nuno.caneco
/nunocaneco
nuno.caneco@gmail.com
THANK YOU
@nunocaneco
Patrocinadores “GOLD”
Twitter: @PTMicrosoft http://www.microsoft.com/portugal
Patrocinadores “GOLD”
Twitter: @FindmoreC http://www.findmore.pt/pt
Patrocinadores “Silver”
Patrocinadores “Bronze”
http://bit.ly/netponto-aval-76
* Para quem não puder preencher durante a reunião,
iremos enviar um email com o link à tarde
Próximas reuniões presenciais
07/04/2018 – Lisboa
23/06/2018 – Lisboa
15/09/2018 – Lisboa
24/11/2018 – Lisboa
Reserva estes dias na agenda! :)

More Related Content

What's hot

A simplest way to reconstruct .Net Framework - CRB Tech
A simplest way to reconstruct .Net Framework - CRB TechA simplest way to reconstruct .Net Framework - CRB Tech
A simplest way to reconstruct .Net Framework - CRB Tech
Pooja Gaikwad
 
PHP Symfony MicroServices Migration @MeeticTech
PHP Symfony MicroServices Migration @MeeticTechPHP Symfony MicroServices Migration @MeeticTech
PHP Symfony MicroServices Migration @MeeticTech
meeticTech
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniter
Jamshid Hashimi
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.net
suraj pandey
 
Implementing application security using the .net framework
Implementing application security using the .net frameworkImplementing application security using the .net framework
Implementing application security using the .net framework
Lalit Kale
 
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan PeshovJavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
dotMemory 4 - What's inside?
dotMemory 4 - What's inside?dotMemory 4 - What's inside?
dotMemory 4 - What's inside?
Maarten Balliauw
 
Lap around .net 4
Lap around .net 4Lap around .net 4
Lap around .net 4
Abdul Khan
 
Robot framework Gowthami Goli
Robot framework Gowthami GoliRobot framework Gowthami Goli
Robot framework Gowthami Goli
Gowthami Buddi
 
Continuous Integration and development environment approach
Continuous Integration and development environment approachContinuous Integration and development environment approach
Continuous Integration and development environment approach
Aleksandr Tsertkov
 
Practice of AppSec .NET
Practice of AppSec .NETPractice of AppSec .NET
Practice of AppSec .NET
Mikhail Shcherbakov
 
Use React tools for better Angular apps
Use React tools for better Angular appsUse React tools for better Angular apps
Use React tools for better Angular apps
Martin Hochel
 
Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)
Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)
Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)
Johannes Geppert
 
Testing with Spring 4.x
Testing with Spring 4.xTesting with Spring 4.x
Testing with Spring 4.x
Sam Brannen
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggets
Virtual Nuggets
 
Javantura v4 - Spring Boot and JavaFX - can they play together - Josip Kovaček
Javantura v4 - Spring Boot and JavaFX - can they play together - Josip KovačekJavantura v4 - Spring Boot and JavaFX - can they play together - Josip Kovaček
Javantura v4 - Spring Boot and JavaFX - can they play together - Josip Kovaček
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
12 factor app - Core Guidelines To Cloud Ready Solutions
12 factor app - Core Guidelines To Cloud Ready Solutions12 factor app - Core Guidelines To Cloud Ready Solutions
12 factor app - Core Guidelines To Cloud Ready Solutions
Kashif Ali Siddiqui
 
Talking architecture shop - Exploring open source success at scale
Talking architecture shop - Exploring open source success at scaleTalking architecture shop - Exploring open source success at scale
Talking architecture shop - Exploring open source success at scale
Eric D. Schabell
 
Appium & Robot Framework
Appium & Robot FrameworkAppium & Robot Framework
Appium & Robot Framework
Furkan Ertürk
 

What's hot (19)

A simplest way to reconstruct .Net Framework - CRB Tech
A simplest way to reconstruct .Net Framework - CRB TechA simplest way to reconstruct .Net Framework - CRB Tech
A simplest way to reconstruct .Net Framework - CRB Tech
 
PHP Symfony MicroServices Migration @MeeticTech
PHP Symfony MicroServices Migration @MeeticTechPHP Symfony MicroServices Migration @MeeticTech
PHP Symfony MicroServices Migration @MeeticTech
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniter
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.net
 
Implementing application security using the .net framework
Implementing application security using the .net frameworkImplementing application security using the .net framework
Implementing application security using the .net framework
 
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan PeshovJavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
 
dotMemory 4 - What's inside?
dotMemory 4 - What's inside?dotMemory 4 - What's inside?
dotMemory 4 - What's inside?
 
Lap around .net 4
Lap around .net 4Lap around .net 4
Lap around .net 4
 
Robot framework Gowthami Goli
Robot framework Gowthami GoliRobot framework Gowthami Goli
Robot framework Gowthami Goli
 
Continuous Integration and development environment approach
Continuous Integration and development environment approachContinuous Integration and development environment approach
Continuous Integration and development environment approach
 
Practice of AppSec .NET
Practice of AppSec .NETPractice of AppSec .NET
Practice of AppSec .NET
 
Use React tools for better Angular apps
Use React tools for better Angular appsUse React tools for better Angular apps
Use React tools for better Angular apps
 
Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)
Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)
Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)
 
Testing with Spring 4.x
Testing with Spring 4.xTesting with Spring 4.x
Testing with Spring 4.x
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggets
 
Javantura v4 - Spring Boot and JavaFX - can they play together - Josip Kovaček
Javantura v4 - Spring Boot and JavaFX - can they play together - Josip KovačekJavantura v4 - Spring Boot and JavaFX - can they play together - Josip Kovaček
Javantura v4 - Spring Boot and JavaFX - can they play together - Josip Kovaček
 
12 factor app - Core Guidelines To Cloud Ready Solutions
12 factor app - Core Guidelines To Cloud Ready Solutions12 factor app - Core Guidelines To Cloud Ready Solutions
12 factor app - Core Guidelines To Cloud Ready Solutions
 
Talking architecture shop - Exploring open source success at scale
Talking architecture shop - Exploring open source success at scaleTalking architecture shop - Exploring open source success at scale
Talking architecture shop - Exploring open source success at scale
 
Appium & Robot Framework
Appium & Robot FrameworkAppium & Robot Framework
Appium & Robot Framework
 

Similar to Stateful mock servers to the rescue on REST ecosystems

Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)
Steve Lange
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source Frameworks
Sunil Patil
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworks
Sunil Patil
 
Widgets - the Wookie project
Widgets - the Wookie projectWidgets - the Wookie project
Widgets - the Wookie project
scottw
 
Actively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net DeveloperActively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net Developer
Karthik Reddy
 
Actively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net DeveloperActively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net Developer
Karthik Reddy
 
Best practices for creating modular Web applications
Best practices for creating modular Web applicationsBest practices for creating modular Web applications
Best practices for creating modular Web applications
peychevi
 
Techdays 2011 - Things I will remember
Techdays 2011 - Things I will rememberTechdays 2011 - Things I will remember
Techdays 2011 - Things I will remember
Alexander Vanwynsberghe
 
Paremus service fabric
Paremus service fabricParemus service fabric
Paremus service fabric
pjhInovex
 
Pentesting With Web Services in 2012
Pentesting With Web Services in 2012Pentesting With Web Services in 2012
Pentesting With Web Services in 2012
Ishan Girdhar
 
What's New in InTouch Machine Edition (ITME)
What's New in InTouch Machine Edition (ITME)What's New in InTouch Machine Edition (ITME)
What's New in InTouch Machine Edition (ITME)
Wonderware InTouch Machine Edition
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
Matthias Noback
 
Online lg prodect
Online lg prodectOnline lg prodect
Online lg prodect
Yesu Raj
 
soa1.ppt
soa1.pptsoa1.ppt
soa1.ppt
ShanmugamS34
 
Path to continuous delivery
Path to continuous deliveryPath to continuous delivery
Path to continuous delivery
Anirudh Bhatnagar
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Enea Gabriel
 
COMPRO- WEB ALBUM & MOTION ANALYZER
COMPRO- WEB ALBUM  & MOTION ANALYZERCOMPRO- WEB ALBUM  & MOTION ANALYZER
COMPRO- WEB ALBUM & MOTION ANALYZER
Ashish Tanwer
 
Von Bayern in die Cloud
Von Bayern in die CloudVon Bayern in die Cloud
Von Bayern in die Cloud
Alexey Gravanov
 
DWX2015 - Von Bayern in die Cloud
DWX2015 - Von Bayern in die CloudDWX2015 - Von Bayern in die Cloud
DWX2015 - Von Bayern in die Cloud
philippgarbe
 
The Twelve Factor Apps
The Twelve Factor AppsThe Twelve Factor Apps
The Twelve Factor Apps
tomi vanek
 

Similar to Stateful mock servers to the rescue on REST ecosystems (20)

Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source Frameworks
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworks
 
Widgets - the Wookie project
Widgets - the Wookie projectWidgets - the Wookie project
Widgets - the Wookie project
 
Actively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net DeveloperActively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net Developer
 
Actively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net DeveloperActively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net Developer
 
Best practices for creating modular Web applications
Best practices for creating modular Web applicationsBest practices for creating modular Web applications
Best practices for creating modular Web applications
 
Techdays 2011 - Things I will remember
Techdays 2011 - Things I will rememberTechdays 2011 - Things I will remember
Techdays 2011 - Things I will remember
 
Paremus service fabric
Paremus service fabricParemus service fabric
Paremus service fabric
 
Pentesting With Web Services in 2012
Pentesting With Web Services in 2012Pentesting With Web Services in 2012
Pentesting With Web Services in 2012
 
What's New in InTouch Machine Edition (ITME)
What's New in InTouch Machine Edition (ITME)What's New in InTouch Machine Edition (ITME)
What's New in InTouch Machine Edition (ITME)
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
 
Online lg prodect
Online lg prodectOnline lg prodect
Online lg prodect
 
soa1.ppt
soa1.pptsoa1.ppt
soa1.ppt
 
Path to continuous delivery
Path to continuous deliveryPath to continuous delivery
Path to continuous delivery
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
 
COMPRO- WEB ALBUM & MOTION ANALYZER
COMPRO- WEB ALBUM  & MOTION ANALYZERCOMPRO- WEB ALBUM  & MOTION ANALYZER
COMPRO- WEB ALBUM & MOTION ANALYZER
 
Von Bayern in die Cloud
Von Bayern in die CloudVon Bayern in die Cloud
Von Bayern in die Cloud
 
DWX2015 - Von Bayern in die Cloud
DWX2015 - Von Bayern in die CloudDWX2015 - Von Bayern in die Cloud
DWX2015 - Von Bayern in die Cloud
 
The Twelve Factor Apps
The Twelve Factor AppsThe Twelve Factor Apps
The Twelve Factor Apps
 

More from Nuno Caneco

Building resilient applications
Building resilient applicationsBuilding resilient applications
Building resilient applications
Nuno Caneco
 
Git from the trenches
Git from the trenchesGit from the trenches
Git from the trenches
Nuno Caneco
 
Tuga IT 2017 - Redis
Tuga IT 2017 - RedisTuga IT 2017 - Redis
Tuga IT 2017 - Redis
Nuno Caneco
 
Tuga it 2017 - Event processing with Apache Storm
Tuga it 2017 - Event processing with Apache StormTuga it 2017 - Event processing with Apache Storm
Tuga it 2017 - Event processing with Apache Storm
Nuno Caneco
 
Fullstack LX - Improving your application performance
Fullstack LX - Improving your application performanceFullstack LX - Improving your application performance
Fullstack LX - Improving your application performance
Nuno Caneco
 
Running agile on a non-agile environment
Running agile on a non-agile environmentRunning agile on a non-agile environment
Running agile on a non-agile environment
Nuno Caneco
 
Introducing redis
Introducing redisIntroducing redis
Introducing redis
Nuno Caneco
 
Tuga it 2016 improving your application performance
Tuga it 2016   improving your application performanceTuga it 2016   improving your application performance
Tuga it 2016 improving your application performance
Nuno Caneco
 

More from Nuno Caneco (8)

Building resilient applications
Building resilient applicationsBuilding resilient applications
Building resilient applications
 
Git from the trenches
Git from the trenchesGit from the trenches
Git from the trenches
 
Tuga IT 2017 - Redis
Tuga IT 2017 - RedisTuga IT 2017 - Redis
Tuga IT 2017 - Redis
 
Tuga it 2017 - Event processing with Apache Storm
Tuga it 2017 - Event processing with Apache StormTuga it 2017 - Event processing with Apache Storm
Tuga it 2017 - Event processing with Apache Storm
 
Fullstack LX - Improving your application performance
Fullstack LX - Improving your application performanceFullstack LX - Improving your application performance
Fullstack LX - Improving your application performance
 
Running agile on a non-agile environment
Running agile on a non-agile environmentRunning agile on a non-agile environment
Running agile on a non-agile environment
 
Introducing redis
Introducing redisIntroducing redis
Introducing redis
 
Tuga it 2016 improving your application performance
Tuga it 2016   improving your application performanceTuga it 2016   improving your application performance
Tuga it 2016 improving your application performance
 

Recently uploaded

Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
Aditya Rajan Patra
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
mamamaam477
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 

Recently uploaded (20)

Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 

Stateful mock servers to the rescue on REST ecosystems

  • 1. Stateful mock servers to the rescue on REST ecosystems netponto - 2018-04-07 Nuno Caneco
  • 4.
  • 5. The Monolith A monolith is a geological feature consisting of a single massive stone or rock, such as some mountains, or a single large piece of rock placed as, or within, a monument or building. https://en.wikipedia.org/wiki/Monolith A software system is called "monolithic" if it has a monolithic architecture, in which functionally distinguishable aspects (for example data input and output, data processing, error handling, and the user interface) are all interwoven, rather than containing architecturally separate components. https://en.wikipedia.org/wiki/Monolithic_system
  • 6. Monolithic architecture Storefront UI Backoffice UI Catalog Service User Service Order Service (...) Database Mobile Web API
  • 8. REST REST has become the default technology to support Microservices Architecture ● It's HTTP(S) ● Use HTTP Verbs for actions: GET, PUT, POST, DELETE, PATCH, ... ● Use HTTP Status Codes to provide meaningful and normalized responses to clients ● Easily extensible using HTTP Headers ● Support multiple authentication mechanisms ● JSON is more simple and less verbose than XML
  • 9. The growth of a Microservice Application
  • 10. Ecosystem User interfacePublic API Backend Services Publish / Subscribe Databases BLOB Storage 3rd party systems
  • 11. Component Dependency System Complexity ~= Business Complexity Loose coupling ; High dependency
  • 12. Dependency level = 0 Dependency level = 10 Dependency level = 7 Teams & Components
  • 13. Combine dependency level with ● Development environment ○ Setup ○ Maintain ● Keep services up to date ● Keep database schema and data ● Test ○ Time it takes to finish tests ○ Dependency from data ● CI/CD ○ Keep a stable environment for end-to-end tests ● Contract stability ● Communication between maintainers
  • 15. Terminology Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists. Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production (an in memory database is a good example). Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test. Spies are stubs that also record some information based on how they were called. One form of this might be an email service that records how many messages it was sent. Mocks are objects pre-programmed with expectations which form a specification of the calls they are expected to receive. https://martinfowler.com/articles/mocksArentStubs.html
  • 16. Mock your dependencies Dependencies with real implementations are replaced by mocked implementations that provide similar behavior at the interface level.
  • 19. Fake Techniques - Client Fake Client App XptoAPIClient Xpto Web API HTTP FakeXptoAPI Client IXptoApiClient Quick to implement and simple to use No new components on the system Using a Mock framework allows control of results on automated tests Doesn't test the HTTP layer Requires coding to implement statefulness The Production Code is not stimulated Potential risk to "Go Live" with the Fake instead of Real implementation
  • 20. Fake Techniques - Proxy Client App XptoAPIClient Xpto Web API HTTP Quick to implement and simple to use Saved responses are similar to the real API No coding necessary (although possible) Easy to implement with containers Very flexible: easy to modify responses Contract changes invalidate previous saved responses Requires coding to implement statefulness Difficult to implement Expectations mechanism to integrated with automated tests Store and Forward Proxy HTTP Responses
  • 21. Fake Techniques - Fake Server Client App XptoAPIClient Xpto Web API HTTP Not so flexible to change responses Requires coding Need to implement Expectations to integrate with automated tests Code generation accelerates development Easy support for contract changes: (just regenerate the code and change implementation) Easy to create and share containers Easy to implement statefulness Fake Xpto Web API Production&Integration Development&Tests HTTP
  • 23. Demo - Proxy Movie Rating UI MovieRating APIClient Movie Rating Web API HTTP Store and Forward Proxy Responses Omdb API
  • 25. Demo - Fake Server Movie Rating UI MovieRating APIClient Movie Rating Web API Fake Xpto Web API Omdb API
  • 27. Integrating with docker Using docker to launch every 1st dependency allows easy setup of the project. $> git clone <repo> $> docker-compose up deps Open solution in Visual Studio and hit F5 No expensive setup of databases, messaging systems or other services Docker images can be versioned alongside with the versions of the API Can be used to run component tests (not integration tests)
  • 28. Summary ● Fake the 1st level dependencies to avoid having the entire dependency tree ● Choose your strategy: Client Fake, Proxy, Stateful Fake or any other that suits ● Consider generating as much code as possible ● Potentially high upfront investment - big gains in the long run ● Make it easy for the developers to ○ Run the project ○ Manage the versions of the dependencies they are using ○ Write automated tests ● Make components tests running against Fakes instead
  • 31. Patrocinadores “GOLD” Twitter: @PTMicrosoft http://www.microsoft.com/portugal
  • 35. http://bit.ly/netponto-aval-76 * Para quem não puder preencher durante a reunião, iremos enviar um email com o link à tarde
  • 36. Próximas reuniões presenciais 07/04/2018 – Lisboa 23/06/2018 – Lisboa 15/09/2018 – Lisboa 24/11/2018 – Lisboa Reserva estes dias na agenda! :)