Angular.js and Play Framework 2.1 Integration with helper functions - angularjs

I want to use Angular.js with the Play Framework view helper functions (e.g #helper.form(...))
How do I insert an Angular directive (e.g: ng-controller)

As I'm sure you discovered, you can't directly make a Scala Symbol with a dash like 'some-word. Instead, just wrap it:
scala> Symbol("ng-controller")
res4: Symbol = 'ng-controller

We're currently using Play Framework 2 and AngularJS.
We added a special method to handle this:
implicit class SymbolString( str: String ) {
def s = Symbol(str)
}
And then we just call it as such:
"ng-model".s -> "datasetName"

Related

how to implement iTestContext listener without adding to method argument testng(from XML) for PDFBox utility

I am automating a salesforce application using Selenium TestNG. I am implementing a utility using apache PDFBox where i paste all my screenshots into a PDF to make client happy .
My logic is i create screenshots in each method with 1.png , 2.png etc until n.png and paste them in pdf using pdfbox methods.
The problem is my number of screenshots are variable so i implemented iTestContext where i set a variable counter to maximum number pass them to my after method where i retrieve the counter , and those number of screenshots are pasted- something like this
Class Login {
#Test
mymethod(ItestContext context){
commonfunctions.savescreenshot(1.png);
commonfunctions.savescreenshot(2.png);
commonfunctions.savescreenshot(n.png);
context.setAttribute("Counter", "n");
}
#AfterMethod
myaftermethod(){
String PATH = //Path of my test method
String MethodCounter = (String)context.getAttribute("Counter");
PDFUtility.addImagetoPDF(PATH,Integer.parseInt(MethodCounter) );
}
}
The problem is i have many methods that i need to implement and i dont want ITestContext listener as argument to each method.Can i pass it in xml file and use it for all methods?
Hope i have provided all details
If you need to get hold of the current ITestContext object (which is a representation of the current <test> tag being executed), you don't need to pass it as a parameter to your #Test method.
You can get access to it from within a #Test annotated test method via something like this:
org.testng.ITestContext context =
org.testng.Reporter.getCurrentTestResult().getTestContext();
This way you dont need to pass the org.testng.ITestContext object as a parameter to your #Test method.
Can i pass it in xml file and use it for all methods?
No you cannot pass the ITestContext object via the xml file.

how to use #step annotation for lambda expression in allure-junit-adaptor

use:
ru.yandex.qatools.allure:allure-junit-adaptor 1.5.0
want use #Step annotation for field with lambda expression:
#Step("Assert screens")
protected AssertScreenshotsInterface compareScreenshots = () -> assertThat(compareImages(getEtalonScreenshotPath(), getCurrentScreenshotPath(),
getDifferentScreenshotPath())).isTrue();
ide show hint: "#Step not applicable to field". I use it function in every test, how to support lambda in allure report?
It's not possible at moment, as Steps's target is METHOD.
But you can create a feature request in allure-java project, if it's really important for you.

Ambiguous use of play of MPMusicPlayerController in iOS11, swift4

I'm running the Apple iOS11 example Adding Content to Apple Music on Xcode Version 9.0 beta 3 (9M174d).
I get a Ambiguous use of 'play() in
/adding-content-to-apple-music/AppleMusicSample/Controllers/MusicPlayerManager.swift:78:9: Ambiguous use of 'play()'
The suggested solutions to explicitly define the selector in order to avoid the ambiguity like:
let play = #selector(musicPlayerController.play)
did not work in this case.
The MPMusicPlayerController instance in the MusicPlayerManager class is defined as
let musicPlayerController = MPMusicPlayerController.systemMusicPlayer
and then referred like
func beginPlayback(itemID: String) {
musicPlayerController.setQueue(with: [itemID])
musicPlayerController.play()
}
I have put the code for the MusicPlayerManager class here.
Write
(musicPlayerController as MPMediaPlayback).play()

Finatra FeatureTests: How to manually deserialize returned json

I read the Finatra getting started guide and I was able to write the HelloWorld Service and its feature test.
Currently my feature test looks like
server.httpPost(
path = "/hi",
postBody = """{"name": "Foo", "dob": 136190040000}""",
andExpect = Ok,
withBody = """{"msg":"Hello Foo. You are 15780 days old today"}""")
This works fine and my tests pass. However my requirement is that I extract the json returned by the server and then manually perform asserts on the object returned.
I changed my code to
val response = server.httpPost(
path = "/hi",
postBody = """{"name": "Abhishek", "dob": 136190040000}""",
andExpect = Ok,
withBody = """{"msg":"Hello Abhishek. You are 15780 days old today"}""")
val json = response.contentString
This also works and I can see the json returned in side the variable json.
My question is that if I have to deserialize this json into an object. Should I just pull in any json library like circe? and then deserialize the object?
or can I use the jackson framework which comes inside of Finatra.
In all examples I could find, I see that Finatra "automatically" handles the json serialization and deserialization. But in my case I want to perform this manually.
You can use the FinatraObjectMapper by calling (using your example) server.mapper. That wraps a Jackson ObjectMapper that you could use if you wanted to use the Jackson library without any of the Finatra add ons.
Or you can import your a different JSON library. If you are using SBT, you can restrict libraries to certain areas of your code, so if you wanted to use circe only in the test code, you could add the following to your build.sbt
"org.scalatest" %% "scalatest" % "2.2.6" % "test"

How to access NHibernate.IQueryOver<T,T> within ActiveRecord?

I use DetachedCriteria primarily, it has a static method For to construct an instance. But it seems IQueryOver is more favourable, I want to use it.
The normal way to get an instance of IQueryOver is Isession.Query, and I want get it with ActiveRecord gracefully, anyone knows the way? Thanks.
First, QueryOver.Of<T> return an instance of QueryOver<T, T>, then you build conditions with QueryOver API.
After that, query.DetachedCriteria return the equivalent DetachedCriteria, which can be used with ActiveRecord gracefully.
var query = QueryOver.Of<PaidProduct>()
.Where(paid =>
paid.Account.OrderNumber == orderNumber
&& paid.ProductDelivery.Product == product)
.OrderBy(paid=>paid.ProductDelivery.DeliveredDate).Desc;
return ActiveRecordMediator<PaidProduct>.FindAll(query.DetachedCriteria);
As far as I know, there is no direct support for QueryOver. I encourage you to create an item in the issue tracker, then fork the repository and implement it. I'd start by looking at the implementation of ActiveRecordLinqBase, it should be similar. But instead of a separate class, you could just implement this in ActiveRecordBase. Then wrap it in ActiveRecordMediator to that it can also be used in classes that don't inherit ActiveRecordBase.

Resources