mercredi 3 janvier 2018

Building blocks of event-driven architecture

In pipeline processing of data, we use,

  • Generator(s)

  • Intermediate processor engine(s)(Aggregate operations)

  • Terminators

For example,

enter image description here


Can Generator(s)-IntermediateProcessor(s)-Terminator(s) be considered as building blocks of event-driven-architecture?

Access the variable in Has-A relation

I'm using Page Factory design pattern where I have implemented Has-A relation bellow classes :

public class PaginationHelper 
{

    WebDriver driver;

    @FindBy(xpath="//li/button[@ng-click='next()']")    
    public WebElement nextPageButton;

    @FindBy(xpath="//li/button[@ng-click='goToLastPage()']")    
    public WebElement lastPageButton;

    @FindBy(xpath="//li/button[@ng-click='goToFirstPage()']")   
    public WebElement firstPageButton;

    @FindBy(xpath="//li/button[@ng-click='prev()']")    
    public WebElement previousPageButton;

    @FindBy(xpath="//ul[@class='pagination']/li[contains(@class,'ng-scope' )]") 
    public List<WebElement> allPages;

    public PaginationHelper(WebDriver driver)
    {

        PageFactory.initElements(new AjaxElementLocatorFactory(driver, 10), this);
        this.driver=driver;
    }

    public void clickNextPage()
    {
        nextPageButton.click();
    }

    public void clickLastPage()
    {
        lastPageButton.click();
    }

    public void clickFirstPage()
    {
        firstPageButton.click();
    }

    public void clickPreviousPage()
    {
        previousPageButton.click();
    }

    public List<WebElement> getAllPages()
    {
        return allPages;
    }
}

Another class where relation implemented :

import com.rconweb.helper.PaginationHelper;

public class RCON_D_ContactsPage 
{
    WebDriver driver;   
    PaginationHelper pagination;


    public RCON_D_ContactsPage(WebDriver driver)
    {

        PageFactory.initElements(new AjaxElementLocatorFactory(driver, 10), this);
        this.driver=driver;
        pagination =  new PaginationHelper(driver);
    }

    public void clickNextPage()
    {
        pagination.clickNextPage();
        //nextPageButton.click();
    }

    public void clickLastPage()
    {
        pagination.clickLastPage();
    }

    public void clickFirstPage()
    {
        pagination.clickFirstPage();
    }

    public void clickPreviousPage()
    {
        pagination.clickPreviousPage();
    }

    public List<WebElement> getAllPages()
    {
        return pagination.getAllPages();
    }

}

And this is how I'm using the element to write the test

public class D_TC_Contacts_RcontactsTestCase extends DriverSetup
{
    RCONLoginPage loginpage;
    RCONHomePage homepage;
    RCON_D_ContactsPage contacts;


    @BeforeClass
    public void initilization() throws IOException
    {
        homepage = new RCONHomePage(driver);
        loginpage = new RCONLoginPage(driver);
        contacts = new RCON_D_ContactsPage(driver);
    }

    @Test
    public void pagesNavigation() throws IOException, InterruptedException
    {
        // Problem Statement 
        while(contacts.nextPageButton.isEnabled())
        {
            contacts.clickNextPage();
            CommonMethods.waitUntilLoaderGetInvisible(driver);
            TakeScreenshot.passedScreenShot("Next Page");
            LogWriter.logger.info("Clicked Next Page"); 
        }

        while(contacts.previousPageButton.isEnabled())
        {
            contacts.clickPreviousPage();
            CommonMethods.waitUntilLoaderGetInvisible(driver);
            TakeScreenshot.passedScreenShot("Previous Page");
            LogWriter.logger.info("Clicked Previous Page"); 
        }

        while(contacts.lastPageButton.isEnabled())
        {
            contacts.clickLastPage();
            CommonMethods.waitUntilLoaderGetInvisible(driver);
            TakeScreenshot.passedScreenShot("Last Page");
            LogWriter.logger.info("Clicked Last Page"); 
        }

        while(contacts.firstPageButton.isEnabled())
        {
            contacts.clickFirstPage();
            CommonMethods.waitUntilLoaderGetInvisible(driver);
            TakeScreenshot.passedScreenShot("First Page");
            LogWriter.logger.info("Clicked First Page");    
        }

    }

}

My Question is, Is it possible or there is a way to access PaginationHelper class variable in D_TC_Contacts_RcontactsTestCase class without creating the PaginationHelper class object in D_TC_Contacts_RcontactsTestCase class ?

mardi 2 janvier 2018

A better way to render Vue.js component variations (besides context)

I'm looking for a less verbose, more elegant way to handle this scenario: we have a few different ways of rendering a post (e.g., full page, modal view, collapsed view, edit mode, etc.) Many methods are shared between them.

Currently, we have a component called Post that when used passes a context:

<post context="edit" :onCancel="cancelUpdatePost">

and then in the Post.vue file we have all methods and the component tags rendering based on that context (using v-if)

<single-post
  :post="currPost"
  :canEditPost="canEditPost"
  :targetPageUrl="targetPageUrl"
  :mailToLink="mailToLink"
  :onAddComment="addComment"
  :onDeleteComment="deleteComment"
  :onShowMoreComments="showMoreComments"
  :onShowFewerComments="showFewerComments"
  :onGoToPost="goToPost"
  v-if="context === 'feed'"
/>

<post-full
  :post="currPost"
  :canEditPost="canEditPost"
  :targetPageUrl="targetPageUrl"
  :mailToLink="mailToLink"
  :postImage="postImage"
  :units="units"
  :divisionsByType="divisionsByType"
  v-if="context === 'permalink'"
/>

(many more versions)

... I'm new to Vue and Vuex, but it seems like there should be a less verbose, easier way?

What is naming convention for DTOs in a webservice

I'm designing a restful web service and I was wondering what should I name my DTOs. Can I use suffixes like Request and Response for them? for example for addUser service, there will be 2 DTOs named: AddUserRequest and AddUserResponse.

How should I use the HttpClient in an ASP.NET Core 2.0 API

I am working on an ASP.NET Core 2.0 API and my API needs to make calls to another, 3rd party, REST API to upload and retrieve files and get file lists and status information. I will be hosting the API in Azure and plan to do Blue-Green deployments between my staging and production slots.

It seems that the general consensus for best practice is to set up a Singleton instance of the HTTPClient via DI registration in Startup.cs-->ConfigureSerrvices method, in order to improve performance and avoid socket errors that can occur if I new up an dispose the HTTPClient connection with each use via a Using statement. This is noted in the following links;

http://ift.tt/2ub77Jo

http://ift.tt/2A7W9qz

http://ift.tt/2fhrQVR

But if I do that, then I can face an issue where the Singleton instance will not see any DNS change when I do a Blue-Green deployment in Azure. This is noted in the following links;

http://ift.tt/2a2CEGN

http://ift.tt/2AKqSLz

http://ift.tt/2fhrQVR

So.. the general consensus now is to use a static HTTPClient instance but control the ConnectionLeaseTimeout value of the ServicePoint class to set it to a shorter value that will force-close the connection to get a refresh of the DNS. This blog post even talks about a nice RestClient component in a nuget package (Easy.Common by Nima) that properly addresses ConnectionLeaseTimeout as well as the cached DNS values.

However, it seems that ASP.NET Core 2.0 does not fully implement the ServicePoint and so this approach is not really currently supported in ASP.Net Core 2.0.

Can anyone advise me as to the correct approach I should pursue for using HttpClient in my ASP.NET Core 2.0 API running on Azure? I want to be able to do Glue-Green deployments. So, should I just resort to the Using statement and new up the client with each use and just suffer the performance hit?

It just seems like there has to be a reliable and performant solution to this common need.

Where can I start learning Complex UI Application Block Pattern? [on hold]

I can't seem to find a good place to learn CAB pattern. I know it is a very old thing but I was asked to learn it for a Win Forms project.

Is it good design to loop through many users? - SpringBoot

I am looking into good design principles and would just like some feedback.

I want to go through every user in my application that is a patient, check their scheduled activities, see if there is one upcoming and send them an email. It looks a little like this:

 List<Patient> listOfAllPatients = patientRepositoryJPA.findAll();

    if (listOfAllPatients.size() != 0) {

        for (Patient patient : listOfAllPatients) {

            user = userRepositoryJPA.findByUsername(patient.getUsername());

            Timestamp currentTimeAndDate = new Timestamp(System.currentTimeMillis());
            Long closestDate = Integer.toUnsignedLong(31);;

            List<Activity> activities = activityRepositoryJPA.findByPatientAndStartDateTimeAfter(patient, currentTimeAndDate);

            for (Activity activity : activities) {

                Timestamp activityDateAndTime = activity.getStartDateTime();

                Long difference = getTimeDifferenceByMinutes(currentTimeAndDate, activityDateAndTime);

                if (difference < closestDate) {

                    LocalDateTime upcomingDate = activity.getStartDateTime().toLocalDateTime();

                    emailHandler.sendEmail(javaMailSender, "Upcoming Activity Reminder", "The activity, " + activity.getName() + " is starting soon! (" +
                            upcomingDate.getHour() + ":" + upcomingDate.getMinute() + ")", user);
                }

            }
        }

Now here I loop through every patient in the application and then through each of their activities. If there were many user (millions) surely there would be some bottlenecks or something here.

Does anybody have any advice on how big companies would handle data like this?

Or is what I am doing fine? Thanks.