Sunday, 5 March 2017

API and Web Service

API (application programming interface) is a list of methods and classes exposed by a programmer to use by other programmers, so eg if you use Twitter or Facebook API in your programs, you can make it cooperate with Twitter and Facebook, and do many useful things. :-)
There are many ways of exposing APIs (JAR files or RMI in Java, .net Assemblies, COM objects, DLL and .H files in C/C++, JSON over HTTP, XML over HTTP, many home-made methods).
Web Services are just yet another way of exposing API, in this case the actual execution of the exposed methods is done not on your computer, but on some other computer on the Internet (on the Web - hence name "WebServices")
What is an API?

An Application Programming Interface (API) at its core is a formal specification that acts as a guaranteed contract between two separate pieces of software
Modern computer systems are generally designed using the ‘layered architecture approach’:
Description: https://www.inflectra.com/GraphicsViewer.aspx?url=Rapise/Highlights/API-Testing.xml&name=wordml://03000001.png


This means that the core functionality of the system is contained within the “business logic” layer as a series of discrete but connected business components. They are responsible for taking information from the various user interfaces (UIs), performing calculations and transactions on the database layer and then presenting the results back to the user interface.
However, in addition to communicating with human beings via the UI layer, computers systems have to be able to communicate directly with each other. For example, your mobile ride sharing application will need to communicate with the mapping service, the traffic and weather services and other specialized applications used by the drivers providing the rides. In the modern, interconnected world, we take for granted that all these different systems can speak to each other seamlessly, in reality that would not be possible without APIs.
How is An API Defined?
As mentioned above, an API at its core is a formal specification that acts as a guaranteed contract between two separate pieces of software. The API provider defines the set of operations, data formats and protocols that it expects, and the consumer of the API (called the client) will use those rules on the understanding that, as long as it follows the rules, the client will always be able to use the API without having to worry about the internals of the API itself:
Description: https://www.inflectra.com/GraphicsViewer.aspx?url=Rapise/Highlights/API-Testing.xml&name=wordml://03000002.png


The importance of APIs is that it lets different organizations create software applications that rely on other application and services without having to constantly update their application when the internals of the dependent applications or services change. As long as the API itself remains stable, the internal implementation can change. This is an important feature of APIs, they consist of a part that doesn’t change – “the interface or contract” that specifies the operations, data formats and behaviors and the implementation that can change as needed.
Dealing with API Changes
So what happens when you want to change an API and expose new functionality? You basically have two choices:
  • Change the existing API to reflect the updated version. However, this is called “breaking compatibility” and means that all clients of the API will need to be updated. Sometimes this is necessary but it should be avoided if possible. This is especially true for applications that are widely used and have many applications dependent on them.
  • Create a New API Version and Leave the Old API. This is the recommended option where possible. You create a new API to expose the new functionality but leave the old API in place for existing clients. You may need to add a translation layer to ensure the old API behaves exactly the same as before.
Description: https://www.inflectra.com/GraphicsViewer.aspx?url=Rapise/Highlights/API-Testing.xml&name=wordml://03000003.png


API Testing
So now that we have established what an API is and why APIs are critical to modern interconnected, globally distributed applications and services, it is important to understand why API testing is critical.
API testing involves testing the application programming interfaces (APIs) directly and as part of integration testing to determine if they meet expectations for functionality, reliability, performance, and security. Since APIs lack a GUI, API testing is performed at the message layer. API testing is critical for automating testing because APIs now serve as the primary interface to application logic and because GUI tests are difficult to maintain with the short release cycles and frequent changes commonly used with Agile software development and DevOps.
Description: https://www.inflectra.com/GraphicsViewer.aspx?url=Rapise/Highlights/API-Testing.xml&name=wordml://03000004.png


When you release a new version of the system (e.g. changing some of the business components or internal data structures) you need to have a fast, easy to run set of API regression tests that verify that those internal changes did not break the API interfaces and therefore the client applications that rely on the APIs will continue to function as before.
Why is API Testing Important Now?
The move to cloud computing has highlighted the importance of Application Programming Interfaces (APIs). With the rise in cloud applications and interconnect platforms, API testing is a necessity. Many of the services that we use every day rely on hundreds of different interconnected APIs, if any one of them fails then the service will not work!
What Kind of APIs Can I Test?
Over the years, APIs have evolved from simple code libraries that applications could use to run code on the same computer, to remote APIs that can be used to allow code on one computer to call code hosted somewhere else.
Here is a quick list of the more common API technologies that exist in approximate chronological order:
  • TCP/IP Sockets
  • Remote Procedure Call (RPC)
  • Common Object Request Broker Architecture (CORBA)
  • Java Remote Method Invocation (RMI) and Enterprise Java Beans (EJBs)
  • Microsoft Distributed Component Object Model (DCOM) – also known as ActiveX
  • Web Services (SOAP then REST)
When looking at an API testing tool, it is important to understand which API technologies you will be using and how best to test them. Nowadays most APIs you will come across will be of the Web Service variety (either REST or SOAP), but you may come across other technologies such as Java EJBs or Microsoft DCOM/ActiveX DLLs.
Web Service Testing
Web service is a unit of managed code that can be remotely invoked using HTTP, that is, it can be activated using HTTP requests. So, Web Services allows you to expose the functionality of your existing code over the network. Once it is exposed on the network, other application can use the functionality of your program.
There are two broad classes of web service:
  • Simple Object Access Protocol (SOAP)
  • REpresentational State Transfer (REST)
Testing SOAP Web Services
SOAP web services make use of the Web Service Definition Language (WSDL) and communicate using HTTP POST requests. They are essentially a serialization of RPC object calls into XML that can then be passed to the web service. The XML passed to the SOAP web services needs to match the format specified in the WSDL.
SOAP web services are fully self-descripting, so most clients do not directly work with the SOAP XML language, but instead use a client-side proxy generator that creates client object representations of the web service (e.g. Java, .NET objects). The web service consumers interact with these language-specific representations of the SOAP web service.
Description: https://www.inflectra.com/GraphicsViewer.aspx?url=Rapise/Highlights/API-Testing.xml&name=wordml://03000005.png


However, when you are testing SOAP services as well as having a nice interface for viewing the provide services and invoking test operations, you need to always have a way to verify the raw SOAP request and response packets being sent in XML:
Description: https://www.inflectra.com/GraphicsViewer.aspx?url=Rapise/Highlights/API-Testing.xml&name=wordml://03000006.png


This feature in particular distinguishes a true SOAP solution from merely a SOAP client library. The former helps you test the service and understand failures, whereas the latter is just a way of making SOAP web service calls more easily from different programming languages.
The following features should be looked for in a SOAP web service testing tool:
  • The ability to download a remote Web Service Description Language (WSDL) file and visually inspect all of its functions and data structures.
  • There should be a way to graphically create the SOAP request by taking the functions and populating the required parameters and then viewing the response back from the API. It should handle both simple values (called primitives, such as integers, dates, strings) and more complex structured objects (e.g. a new user object)
  • There should be a way to see the raw SOAP XML structure for both the sent request and the retrieved response. Ideally there should be a way to see the XML data nicely formatted so that it’s easier to understand the interactions.
  • If possible the tool should support the different versions of SOAP (1.0, 1.1, 1.2) and also handle vendor-specific extension such as Microsoft Windows Communication Foundation (WCP) and ASP.NET Web Services (ASMX).
Testing REST Web Services
A RESTful web API (also called a RESTful web service) is a web API implemented using HTTP and REST principles. Unlike SOAP-based web services, there is no "official" standard for RESTful web APIs. This is because REST is an architectural style, unlike SOAP, which is a protocol.
Description: https://www.inflectra.com/GraphicsViewer.aspx?url=Rapise/Highlights/API-Testing.xml&name=wordml://03000007.png


Typically REST web services expose their operations as a series of unique "resources" which correspond to a specific URL. Each of the standard HTTP methods (POST, GET, PUT and DELETE) then maps into the four basic CRUD (Create, Read, Update and Delete) operations on each resource.
Description: https://www.inflectra.com/GraphicsViewer.aspx?url=Rapise/Highlights/API-Testing.xml&name=wordml://03000008.png


REST web services can use different data serialization methods (XML, JSON, RSS, etc.).
Traditionally the format used for REST Web Services was XML. This is partly because it was used extensively in SOAP web services and is therefore familiar, but also when bandwidth is not a limiting factor, it is self-describing, with the fields and data clearly described:
Description: https://www.inflectra.com/GraphicsViewer.aspx?url=Rapise/Highlights/API-Testing.xml&name=wordml://03000009.png


A common format used in web browser based APIs is JSON since it returns the data asJavaScript Object Notation (JSON) object which can be used directly in a web browser since it matches the format used by JavaScript to store arrays and objects. It is also a very compact format, making it ideal for communications on mobile networks with limited bandwidth.
Description: https://www.inflectra.com/GraphicsViewer.aspx?url=Rapise/Highlights/API-Testing.xml&name=wordml://0300000A.png


When choosing a tool to perform REST web service testing, you should look for:
  • The ability to prototype and preview the HTTP request, with the ability to specify the HTTP headers, body, method and standard HTTP credentials.
  • The ability to see the request and response bodies in a variety of formats, including JSON and XML. The best tools offer automated formatters to make the data easier to enter and view.
  • The ability to record your actions and generate a programmatic test script that can be executed automatically for regression and API testing. If possible the tools should provide a way to convert the request and responses into software “objects” that make dealing with the data easier.
  • If possible, there should be a way to parameterize the REST requests so that you can create generic REST test functions that can be used in the test script in different ways without having to rewrite each time.
Microsoft DCOM/ActiveX Testing
Microsoft's Component Object Model (COM) also known as ActiveX is a standard for communication between separately engineered software components (source). Any object with a COM interface can be created and used remotely:
var doc = new ActiveXObject("Word.Application");
doc.Documents.Open(wordFileName);
Using this approach, any API packaged as a COM or .NET accessible Dynamic Linked Library (DLLs) can be tested natively by testing tools such as Rapise.
Rapise from Inflectra provides support for testing the following different types of DLL API:
  • Managed DLLs – written using the .NET Framework, Rapise provides special access classes for testing these APIs.
  • Unmanaged DLLs – written using native Intel x86 code, Rapise provides a special DynamicWrapper than makes it easy to access these APIs


Friday, 3 March 2017

Salesforce Interview Questions & Answers


Top Salesforce Interview Questions & Answers

1) Explain what is salesforce?

Salesforce is a CRM delivered as a software-as-a-service (SaaS).
2) Explain what is a custom object in sales force?
Custom objects are nothing but database tables. It stores data related to your company in Salesforce.com. Once you have defined custom object you can do following things like
  • Create custom fields
  • Associate the custom object with other records
  • In custom related lists, it display the custom object data
  • For custom object, records track events and tasks
  • Build page layouts
  • For the custom object create a custom tab
  • To analyze custom object data create dashboards and reports
  • Share your custom tabs, custom apps, custom objects and any other related components
3) Explain what is object relationship overview?
Object relationship overview in Salesforce is used to link custom object records to standard object records in a related list. In simple words, it is helpful to track product defects associated with customer cases. You can define different types of relationship by creating custom relationship fields on an object.
4) Mention changing what may cause data loss?
Data loss may cause due to following reasons
  • Changing data and date-time
  • Altering to percent,number and currency from other data types
  • Changing from multi-select picklist, checkbox, auto number to other types
  • Altering to multi-select picklist from any type except picklist
  • Changing to auto-number except from text
  • Changing from text-area to e-mail, phone, URL and text
5) How SaaS can be helpful to Sales force?
  • As SaaS is a subscription based, customers can always choose not to renew if they are dissatisfied
  • Customers can avoid a large initial investment in an IT infrastructure and day to day hustle of maintaining infrastructure
  • SaaS customer provides same provider infrastructure and also easy integration
  • SaaS applications use a simple internet interface that makes easier for customer to use.
  • SaaS always provide a latest platform to the customer with innovation.
6) How sales force is useful in tracking sales?
Sales force records all the basic details like the number of customers served daily, daily sales volume, sales manager detailed reports, sales numbers in each month or quarter.  Also, it keeps a track on the repeat customer, which is key to success for any sales organization.
7) Mention how many relationship is included in SFDC and what are they?
There are two types of relationships
  • Master detail relationship
  • Lookup relationship
8) Mention what is the difference between isNull and isBlank?
  • isNull: It supports for number field
  • isBlank: It supports for Text field
9) Explain what is the trigger?
Trigger is a code that is executed before or after the record is updated or inserted
10) Mention what is the use of the static resource in Salesforce?
With the help of static resources, you can upload zip files, images, jar files, JavaScript and CSS files that can be referred in a visual force page. The optimum size of static resources for an organization is 250 mB.
11) Mention what is the difference between force.com and Salesforce.com?
Force.com is PaaS (Platform as a Service) while Salesforce.com is SaaS ( Software as a Service).
12) Mention what are the actions available in workflow?
Actions available in workflow are
  • Email Alert
  • Task
  • Field Update
  • Outbound Message
13) Explain what is the limit of data.com records that can be added to Salesforce?
User can see their limit form setup, by clicking data.com administration/Users.  From the data.com users section, user can see their monthly limit and how many records are exported during the month.
14) Mention what are the different types of custom settings in Salesforce?
Different types of custom settings in Salesforce includes
  • Hierarchy type
  • List type
15) Mention what are the three types of object relations in Salesforce?
Different types of object relations in Salesforce includes
  • One to many
  • Many to many
  • Master detail
16) Mention what are the different types of reports available in Salesforce?
Different types of reports available in Salesforce are
  • Tabular report: It displays the grand total in the table form
  • Matrix report: It is a detailed report in which the grouping is done based on both rows and columns
  • Summary report: It is a detailed form of the report in which the grouping is done based on columns
  • Joined report: With this two or more reports can be joined in the single reports
17) Is it possible to schedule a dynamic dashboard in Salesforce?
No, it is not possible to schedule a dynamic dashboard in Salesforce.
18) What does it indicate if an error state this “list has no rows for assignment”?
The error that tells “list has no rows for assignment” indicates that the list you are trying to access has no values in it.
19) Explain what the junction object is and what is the use?
Junction objects are used to build many-to-many relationships between objects.  You can take a recruiting application example, where a position for a job can be linked to many candidates and in the same manner a candidate can be linked to the different positions. So, to connect this data model, you need a third party object, this object is referred as junction object.  Here “job application” is the junction object.
20) Explain what is Audit trail?
Audit trail function is helpful in knowing the information or track all the recent setup changes that the administration does to the organization.  It can store last 6 months data.
21) Explain what is dashboard?
Dashboard is the pictorial representation of the report, and we can add up to 20 reports in a single dashboard.
22) Explain how many controllers can be used in a visual force page?
As Salesforce comes under SaaS, one can use only one controller and as many extension controller.


1.) Suppose you are the standard user, you have all the CRED permissions on CAMPAIGN object but you don't have access to create a record, why?
Ans:) marketing user option should be checked for that user to access the CAMPAIGN object.

2.) In approval process, suppose three persons has to approve, if majority people approve then it should approve otherwise it should not be approve?
Ans:) Using standard approval process it is not possible, using dynamic approval process it is possible. In standard approval process all users should approve then only record will get approve.

3.) If the OWD for account object is private then is it possible to access the account record by other users apart form the owner?
Ans:) 1. All the people above the role hierarchy, they can access the records.
          2. By using sharing rules, we can share those records to other users.
          3. Account Team members they can access these records.

4.) If I put "renderas" attribute as "PDF" then it displays PDF document,But i want the same in MSword format.Then how you will do this?
A)<apex:page contentType="application/msWord" cache="true">
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  This is your new Page
  <apex:form>
  <apex:pageBlock>
  <apex:commandButton value="Button" action="{!method1}"/>
  </apex:pageBlock>
  </apex:form>
  <!-- End Default Content REMOVE THIS -->
</apex:page> 
Without "cache" attribute also it works, But in some browsers it doesn't work without "cache" attribute.


5.) If there is a validation rule if amount = 100 then it should display error msg, Then I saved the record by giving value as 1000 then I had written a workflow if amount > 100 then I am updating amount field value with 100. Then what will be the result?
 A) First validation rules will get execute then workflow rules will be execute so the answer is 100 (Even though there is validation rule because of the workflow it will accept 100 in amount field.

6.) What is the difference between task and event?
A) 
Task: Task is nothing but work assigned to a particular person, it doesn't have certain time limit.
Event: It has certain time limit in that time only all persons should assemble after the time limit over, event will get complete. 

7.) What the record criteria meets for a time dependent workflow email has submitted in queue which will trigger the email in one month later somebody modified the record which won't meet the time dependent workflow rule criteria, what will happen?
A) 
Email won't be triggered since workflow criteria is not satisfied for the record, salesforce will remove the action to send the email from the queue.

7.) How many ways we can make field mandatory, if the field is mandatory at page layout level and if we try to inert records through data loader with out populating those mandatory fields what will happen?
A) 
In following ways we can make fields mandatory:
1. At Field Level.
2. At the page layout level.
3. Through validation rules.

If the field is mandatory at page layout level then only while inserting records from page layout level if we won't populate the fields with values it will trow error. If we insert records from data loader it won't throw. Even if we mention the record type while inserting record through program it will trow error message.
23) Mention what is the difference between SOQL and SOSL?
  SOQL ( Salesforce Object Query Language)SOSL (Salesforce Object Search Language)
  • Only one object at a time can be searched
  • Query all type of fields
  • It can be used in triggers and classes
  • DML operation can be performed on query results
  •  Many objects can be searched at a time
  • Query only e-mail, phone and text
  • It can be used in classes but not in triggers
  • DML operation cannot be performed on search result