Add support for NetBeans agent

Closes gh-290
This commit is contained in:
Stephane Nicoll 2016-09-20 14:20:54 +02:00
parent ddf3686612
commit 99fbe8a5ad
2 changed files with 16 additions and 0 deletions

View File

@ -63,6 +63,8 @@ class Agent {
INTELLIJ_IDEA('intellijidea', 'IntelliJ IDEA'),
NETBEANS('netbeans', 'NetBeans'),
BROWSER('browser', 'Browser')
final String id
@ -80,6 +82,8 @@ class Agent {
private static final STS_REGEX = 'STS (.*)'
private static final NETBEANS_REGEX = 'nb-springboot-plugin\\/(.*)'
static Agent parse(String userAgent) {
def matcher = (userAgent =~ TOOL_REGEX)
if (matcher.matches()) {
@ -95,6 +99,11 @@ class Agent {
if (matcher.matches()) {
return new Agent(AgentId.STS, matcher.group(1))
}
matcher = userAgent =~ NETBEANS_REGEX
if (matcher.matches()) {
return new Agent(AgentId.NETBEANS, matcher.group(1))
}
if (userAgent.equals(AgentId.INTELLIJ_IDEA.name)) {
return new Agent(AgentId.INTELLIJ_IDEA, null)
}

View File

@ -72,6 +72,13 @@ class AgentTests {
assertThat(agent.version, is('144.2'))
}
@Test
void checkNetBeans() {
Agent agent = Agent.fromUserAgent('nb-springboot-plugin/0.1')
assertThat(agent.id, equalTo(Agent.AgentId.NETBEANS))
assertThat(agent.version, is('0.1'))
}
@Test
void checkGenericBrowser() {
Agent agent = Agent.fromUserAgent(