You are on page 1of 20

DEDE Testing Strategy

DEDE QE: Souhaila


Moalla

TM

10/08/15, p1, eBay Inc. Proprietary & Confidential

Agenda
DEDE Overview
DEDE within eBox Architecture
DEDE Architecture: Flow
Persistent Entities
Main steps to use DEDE Plugin
Sample JPA Annotated DO
Demo
JPA Annotation
Association
DEDE main features
DEDE Plugin Testing Area
DEDE Plugin Automation Strategy

Best Practices
References
TM

10/08/15, p2, eBay Inc. Proprietary & Confidential

DEDE Overview
DEDE :DAL Eclipse Development Environment
DEDE is an Eclipse plug-in designed to assist the developer in
providing persistence through the eBay Data Access Layer,
the DAL.
DEDE is similar to Object/Relational mapping tools like
Hibernate. It enables you to write object trees and retrieve
them from persistent storage.
DEDE partially automates the process of interfacing a Java
application to eBay's Data Access Layer, the DAL.
TM

10/08/15, p3, eBay Inc. Proprietary & Confidential

DEDE within eBox Architecture


eBox framework is essentially a set of software
components that provide limited access to eBays
internal services.
eBox application
SOA TOOL

V4 TOOL

DEDE TOOL

V4
SOA

DAL

kernel

TM

10/08/15, p4, eBay Inc. Proprietary & Confidential

DEDE Architecture: Flow


DO1 DO2 DO3

DOn

DAO Wizard
Generate
CGDIMPL
CGDIMPL
CGDIMPL
CGDIMPL n

DoImpl
DoImpl
DoImpl
DoImpl n

Generate

DAO1 DAO2 DAO3

DAO n

Cache Cache Cache

Cache

Provide: insert/Delete/Update/Find methods

Query
Engine

Databases

Create instance of the DAOs

Business Object
10/08/15, p5, eBay Inc. Proprietary & Confidential

TM

Persistent Entities
A persistent entity can be thought of being made up of three
logical components: DO, DAO, and CodeGenDoImpl .
DO (Data Object): generally maps a POJO to a single row in a DB
table. Java properties in the DO generally correspond to columns in
the table.
DAO (Data Access Object): provides the functionality to perform basic
database operations - to retrieve objects (as DOs) from the database,
to insert DOs into the database, and to update or delete entities. The
DAO is a singleton, and is implemented as a single class.
CodeGenDoImpl: implements the DO interface, including getters and
setters. It also implements some DAL functionality such as dirty
tracking and lazy loading.
DEDE can also generate a DoImpl implementation class, a subclass
of CodeGenDoImpl
10/08/15, p6, eBay Inc. Proprietary & Confidential

TM

Main steps to use DEDE Plugin

Create the DB tables.


Create the DO file (Java interface) .
Populate the DO with getters and setters for the columns in the database
table
add DEDE-specific annotations to the interface definition line and each of the
getters
Now we are ready to invoke DEDE. So we right-click on the interface name in
Project Explorer, then click on DAO Wizard > Generate DAO and
CodeGenDoImpl for this class.
At this point we have generated two classes, CodeGenDoImpl and the DAO
class . These do all the work necessary to write objects to and retrieve them
from the database.

TM

10/08/15, p7, eBay Inc. Proprietary & Confidential

Sample JPA Annotated DO


package com.ebay.cookbook.person;
import javax.persistence.*;

package com.ebay.cookbook.department;
import javax.persistence.*;
import com.ebay.cookbook.person.Person;
@Entity
@Entity
@Table(name = "person")
@Table(name = "department")
@com.ebay.persistence.ConstantToupleProvider("ebox")
@com.ebay.persistence.Table(alias = "per")
@com.ebay.persistence.ConstantToupleProvider("ebox")
public interface Person {
@com.ebay.persistence.Table(alias = "dep")
public interface Department {
@Id
@Id
public int getId();
public int getId();
public void setId(int id);
@AlternateId
public void setId(int id);
@Column(name = "DriverLicense")
@Column(name = "name")
public String getDL();
public String getDepartmentName();
public void setDepartmentName(String
department);
@ManyToOne
@JoinColumn(name = "dept_id", referencedColumnName = "id")
public Department getDepart();
public void setDepart(Department department);

@OneToMany (mappedBy = "depart")


public List<Person> getPersons();
public void setPersons(List<Person> persons);

TM

10/08/15, p8, eBay Inc. Proprietary & Confidential

DEDE

Demo

TM

10/08/15, p9, eBay Inc. Proprietary & Confidential

JPA Annotation
@Entity means that the interface has a DEDE-managed mapping to a database table.
@Id identifies the Entity PK
@Table tells DEDE what name should be used for the table. (Optional)
@Column refers to the table column name. if no name is given, DEDE will use the usual JavaBean conventions to
determine the column name
@SecondaryTable Used when properties from a single DO are contained in two (or more) database tables. It causes
the Joins Page of the DAO editor to appear.
@GeneratedValue Specified on a property getter method that is also annotated with @Id. It indicates that the value
of this field will be set by the database engine
@AlternateID indicates that a field is an alternate key
@DerivedValue indicates that the field should not be automatically added to generated read and update sets
@Version -Only one field per entity can be annotated with @Version. The underlying column must be of a numeric
type
@Transient causes generation of simple property getter and setter methods, but hides field from DAL (no
FullFieldMapping is generated)

TM

10/08/15, p10, eBay Inc. Proprietary & Confidential

JPA Annotation
@Hint / @HashHint Indicates field does not map to a database column, but will still have a mapping created for it so
that it will be visible
@Hint annotation is placed on individual Java property
@HashHint is placed on the interface

Multiple hash hints must be grouped within an enclosing @HashHints annotation:


@HashHints({
@HashHint(attrName="minValue",defaultType=HashHint.TYPE_INT,
sql="r.PREPTIME>:this"),
@HashHint(attrName="maxValue",defaultType=HashHint.TYPE_INT,
sql="r.PREPTIME<:this")})
@Embeddable is used in place of @Entity on an object that is a contained subobject.
@Embedded is used in place of @OneToOne on a Java property getter method in the container to indicate that the
subobject is a contained subobject.

TM

10/08/15, p11, eBay Inc. Proprietary & Confidential

JPA Annotation
@SelectExpression, @InsertExpression, @UpdateExpression provide values that will be
inserted into templatized SQL statements in place of the simple item name

@Column(name = "lastmodified")
@InsertExpression("sysdate()")
@UpdateExpression("lastmodified=sysdate()")
public Date getLastModifiedDate();
@com.ebay.persistence.Column(name = "preptime", alias = "avgprep")
@SelectExpression("avg(preptime)")
@DerivedValue
public int getAveragePreparationTime();
@JoinColumn is used with the association @OneToOne or @ManyToOne to provide non-default
names for the database columns
@JoinColumns grouping annotation is used when there is a composite key for the foreign entity
@ConstantToupleProvider
TM

10/08/15, p12, eBay Inc. Proprietary & Confidential

@ConstantToupleProvider & DDR


@ConstantToupleProvider takes only a single argument, the logical host name.
Data-Dependent Routing: Multiple hosts, and a very flexible mechanism for routing
queries to hosts depending on protoDO values and hints

TM

10/08/15, p13, eBay Inc. Proprietary & Confidential

Association
@OneToOne is used to indicate an association with 1:1 multiplicity
@ManyToOne is used on the one side of a one-to-many association. It may
be accompanied by @JoinColumn / @JoinColumns to set names for the
database columns.
@OneToMany is used on the many side of a one-to-many association. In
our implementation, one-to-many relationships are always owned by the
one side (that is, there must be a column in the one side that holds the
foreign key value of the many side).
@ManyToMany
- DEDE does not support the JPA @ManyToMany annotation
-With JPA many-to-many, the join table is implicit, and is managed completely
by the JPA implementation
- For DEDE, many-to-many relationships can be modeled by explicitly
declaring the join table as an entity (creating a DO for it), with the JoinTable
having many-to-one relationships with both of the tables that participate in
the many-to-many relationship

TM

10/08/15, p14, eBay Inc. Proprietary & Confidential

DEDE main features


The user is allowed to:
Create DAO,CodegenDoImpl file.
Allow the user to add some manual code to the generated extension
classes for the CodeGenDoImpl file
Create queries( Insert, Delete, Update, and Select) from DAO Editor
Create Read/Update sets, hintGroups
Access to the DAL methods.
Create and manipulate persistent objects
Define the association between different DAO files
Generates Junit Test class and Test Suite
COLD and Resident Cache Generation
BO Generation
TM

10/08/15, p15, eBay Inc. Proprietary & Confidential

DEDE Plugin Testing Area


Covered all the JPA annotations supported by DEDE using JUnit.
Validate that the negative test cases are handled properly
(Exceptions, Error messages)
Covered most of the DAL types and My*SQL types Combination.
Covered all the relationship between the tables (@OneToOne,
@OneToMany, @ManyToOne, @ManyToMany)
Covered the Case where the DO files are in different packages
Covered the case where the same DO file is used in different
packages
Covered the Case where the DO files share the same ID name
Tested Complex PK with all the association types
Covered the Extended subclasses and make sure that the Dev code
in the subclasses is reflected in the application
Tested the Referential Integrity
TM

10/08/15, p16, eBay Inc. Proprietary & Confidential

DEDE Plugin Automation Strategy


Create a Test fragment that takes DEDE plug-in as a host. Write Junit
Tests that calls DEDE APIs and run them as Junit Plugin Tests (This will
launch another instance of Eclipse)
Automatically setup the new workspace using AST:
1- Create a new Project
2- Populate the Project from the Test packages checked in the
current view
3- Set up the CLASSPATH
4- Call the generation Test suite
5- BUILD
Created a validation method to check for compilation errors in the
generated classes and produce reports
Execute the .sql files to setup the DB
Created an ANT Script that runs the Runtime Junit tests to validate
the generated code
TODO: Call the ANT Script from the Generation Test suite
TODO: Write another ANT script to run the Generation Test suite in a
headlessp17,
mode
10/08/15,
eBay Inc. Proprietary & Confidential

TM

Best Practices
Encourage the plugin developer to separatethe code into
(typically) three plug-ins:
1. CORE plug-in that contains the model and factory classes
2. PRESENTATION plug-in that contains the presentation
adapters, commands, etc.
3. UI plug-in that contains wizards, editors, menus, etc.

With this design approach, we guarantee the code


portability andreusability
Facilitate the QE work
TM

10/08/15, p18, eBay Inc. Proprietary & Confidential

References
https://wiki2.arch.ebay.com/confluence/display/EBOX/Overall+testing+strategy

TM

10/08/15, p19, eBay Inc. Proprietary & Confidential

Questions

TM

10/08/15, p20, eBay Inc. Proprietary & Confidential

You might also like