I am very new to BDD, and having a bit of trouble outlining the scenarios for some code that I wrote. The code basically queries a Couchbase bucket for abandoned orders, and then calls a cancel order API to cancel those orders. For each call to the cancel order API, it calls another service to generate access token.
The entire code has been written in RxJava. In case of errors, I have fallback observables in place (for example, should anything go awry while querying Couchbase, it fallbacks to an empty observable). I have similar fallbacks in other places in the code as well.
I want to write Cucumber scenarios for my code. But I can't figure out how to go about it. For example, should I assume that the service has a valid access token and an orderId to cancel (querying CB returns a bunch of orderIds that need to be passed on to the cancel order API along with an access token)?
Ideally, I should be testing the following:
Querying Couchbase fails. In this case, I should get an empty observable.
Call to the access token API fails. In this case as well, I should get an empty observable.
Call to the cancel order API fails. In this case as well, I should get an empty observable.
Call to cancel order API returns some response code other than 200. Then assert on the response codes.
The happy case.
Now suppose I want to test the first case, that is, querying CB fails. What will be the background in this case? How should I simulate a query failure?
Related
I have an application developed using SmartGWT,Jaxrs,ejb &jpa.
I have one scenario where user wants to extract the data(called Search Screen) by entering either firstname,lastname or middlebane,ssn,email,etc
Database contains the huge number of records in millions, which takes lot of time to respond back.
for example, user search with firstname which takes lot of time to respond, in that case user wants to cancel/terminate/abort the request.
Is it possible either in smartgwt or jaxrs(web api) to terminate the request.
So that user can terminate the request and move further
PS:: i tried lot of option,but i didn't get the proper solution.
One solution is to put the business logic in stateful bean and put the bean in the http session ... now you have access to the currently used persistence context and the open transaction so you can call Session.cancelQuery() .... but this method has some limitation .. It works only if Result set is not yet returned , if this limitation harms you, check this answer please
There are other workarounds to synchronize the web client with the business method but this is the one I like most
One more thing you need to consider as this is your use case is to introduce a new lexical search engine like solr or elasticsearch which can be updated frequently with data from the database ... It fits perfectly in lexical search, gives the ability to stand typo mistakes and returns result very quickly
I was wondering about the proper way to store state between sequence invocations in WSO2ESB. In other words, if I have a scheduled task that invokes sequence S, at the end of iteration 0 I want to store some String variable (lets' call it ID), and then I want to read this ID at the start (or in the middle) of iteration 1, and so on.
To be more precise, I want to get a list of new SMS messages from an existing service, Twilio to be exact. However, Twilio only lets me get messages for selected days, i.e. there's no way for me to say give me only new messages (since I last checked / newer than certain message ID). Therefore, I'd like to create a scheduled task that will query Twilio and pass only new messages via REST call to my service. In order to do this, my sequence needs to query Twilio and then go through the returned list of messages, and discard messages that were already reported in the previous invocation. Now, to do this I need to store some state between different task/sequence invocations, i.e. at the end of the sequence I need to store the ID of the newest message in the current batch. This ID can then be used in subsequent invocation to determine which messages were already reported in the previous invocation.
I could use DBLookup and DB Report mediators, but it seems like an overkill (using a database to store a single string) and not very performance friendly. On the other hand, as far as I can see Class mediators are instantiated as singletons, therefore I could create a custom Class mediator that would manage this state and filter the list of messages to be sent to my service. I am quite sure that this will work, but I was wondering if this is the way to go, or there might be a more elegant solution that I missed.
We can think of 3 options here.
Using DBLookup/Report as you've suggested
Using the Carbon registry to store the values (this again uses DBs in the back end)
Using a Custom mediator to hold the state and read/write it from/to properties
Out of these three, obviously the third one will deliver the best performance since everything will be in-memory. It's also quite simple to implement and sometime back I did something similar and wrote a blog post here.
But on the other hand, the first two options can keep the state even when the server crashes, if it's a concern for your use case.
Since esb 490 you can persist and read properties from registry using property mediator.
https://docs.wso2.com/display/ESB490/Property+Mediator
I have a function inside another function that is supposedly getting called, according to my expect(Parse.User.Login).toHaveBeenCalled() line, but there are some console statements inside the callback to that which aren't showing up.
Is there some type of dependency I'm missing on my unit test causing the callback not to have called? I think it is getting to the server, because it tells me I need a Parse.initialize with the application keys if that's not present.
How do I resolve it?
It just occurred to me, maybe that's something in Parse.js telling me I need the Parse.initialize(keys,keys). I changed the parse keys to nonsense, and its not telling me they're wrong, so it must be that parse isn't being touched at all. No request is being sent to the server.
I've been putting up a few questions about this, but now I guess this can't be done with Karma-jasmine -- at least the way the app is set up right now. It's depending on a web service to give the errors, instead of having an angular directive set up up front to detect the errors in the fields beforehand.
I'm a newbie at this obviously, or I would have recognized this sooner:
This type of testing, where you are depending on responses from the server and that's that, should be delegated to E2E tests.
Meaning, here what am I supposed to test that wouldn't be just hardcoding the desired response right into the jasmine Spy? What would that do to just set the rootScope to a user attribute? Maybe, if state.go changed the view to another page, and then acted on the $rootScope data, this would make sense. But for now, there's no point. I'm not designing the next step, nor do I know what it is at the moment, so I can only sit back.
I am writing a provider hosted SharePoint 2013 application. I'm using SharePoint online.
Since the people picker isn't supported in this scenario, I need to build my own. I found the SearchPrincipals method. That seems like exactly what I'm looking for, but no matter what I try, the method is returning with 0 results.
What little information I've found around this method suggests that the problem is usually a permissions issue, but the user that I'm logged in as is a Site Collection Administrator (ClientContext.Web.CurrentUser.IsSiteAdmin is true), so that shouldn't be the case with me.
I've tried passing in virtually every combination of PrincipalType and PrincipalSource, even ones that didn't make sense. I've also tried passing in ClientContext.Web.SiteUsers for the scope, and also null, both of which I've seen used in my searches, and that didn't turn up any results either.
Any help would be appreciated!
I figured it out. The ClientContext of the CSOM (Client Side Object Model) allows the developer to make multiple --unrelated -- queries. It queues up these queries and does not execute them until ExecuteQuery is called. Even though SearchPrincipals is a static method off of the Utility class, it still translates the method call into a query and queues it up. The method will always return an empty collection, but once you call ExecuteQuery on the ClientContext, that collection is then filled with the results of the search.
Also, another problem that I ran into immediately afterwards was that I was getting an error that seemed completely unrelated to my query when I called ExecuteQuery. It turns out that there was code that previously executed that queued up some queries, but it never executed them, so when I called ExecuteQuery, it executed those queries as well, and one of those was erroring. If you are getting an unexpected error, it's a good idea to see if there are other queued queries that haven't been executed yet. You can check the boolean property HasPendingRequest to help determine this.
Hopefully this answer saves other people a lot of time!
How can I get 2 or multiple responses back from a CXF based RESTFul webservice for a single call.
For example : For this http://localhost:8080/report/annual, I would like to get 2 JSON reponses back. The first one will give me the information about the report details & some other information. The second reponse will give me the actual report JSON. If these 2 be delivered async that will be really good.
I'm with #flesk, this really isn't a REST approach, this is more of an async messaging approach.
The first call should return "someinfo" after it starts the "actualReport" processing (in a separate thread/process since "actualReport" is time consuming). Then make a second call for "actualReport" and make sure the timeout value on that call is set high enough to let the report processing complete.
You could get fancy and loop on the second call, returning a 404 until the report is complete.
There are a number of ways to get what you want, just not with one RESTful call.
You can't. Why would you want to do that anyway, when you can just return something like
{"someInfo": {...}, "actualReport": {...}}