Tabnine Logo
MethodSensorTypeIdentDao.saveOrUpdate
Code IndexAdd Tabnine to your IDE (free)

How to use
saveOrUpdate
method
in
rocks.inspectit.server.dao.MethodSensorTypeIdentDao

Best Java code snippets using rocks.inspectit.server.dao.MethodSensorTypeIdentDao.saveOrUpdate (Showing top 3 results out of 315)

origin: inspectIT/inspectIT

/**
 * Test that the registration of the {@link MethodSensorTypeIdent} will be correct if
 * properties are provided.
 */
@SuppressWarnings("unchecked")
@Test
public void registerMethodSensorTypeWithSettings() {
  final long methodSensorId = 30;
  long platformId = 1;
  final String fqcName = "class";
  String regEx = "myRegEx";
  String regExTemplate = "myRegExTemplate";
  Map<String, Object> settings = MapUtils.putAll(new HashMap<String, Object>(), new String[][] { { "regEx", regEx }, { "regExTemplate", regExTemplate } });
  when(methodSensorTypeIdentDao.findIdByClassNameAndPlatformId(fqcName, platformId)).thenReturn(Collections.<Long> emptyList());
  Mockito.doAnswer(new Answer<Object>() {
    @Override
    public Object answer(InvocationOnMock invocation) throws Throwable {
      MethodSensorTypeIdent methodSensorIdent = (MethodSensorTypeIdent) invocation.getArguments()[0];
      methodSensorIdent.setId(Long.valueOf(methodSensorId));
      methodSensorIdent.setFullyQualifiedClassName(fqcName);
      return null;
    }
  }).when(methodSensorTypeIdentDao).saveOrUpdate((MethodSensorTypeIdent) anyObject());
  long registeredId = registrationService.registerMethodSensorTypeIdent(platformId, fqcName, settings);
  assertThat(registeredId, is(equalTo(methodSensorId)));
  verify(platformIdentCache, times(1)).markDirty(platformId);
  ArgumentCaptor<MethodSensorTypeIdent> methodSensorArgument = ArgumentCaptor.forClass(MethodSensorTypeIdent.class);
  verify(methodSensorTypeIdentDao, times(1)).saveOrUpdate(methodSensorArgument.capture());
  assertThat(methodSensorArgument.getValue().getSettings(), is(settings));
}
origin: inspectIT/inspectIT

/**
 * Test the registration of the method sensor type.
 */
@Test
public void registerMethodSensorType() {
  final long methodSensorId = 30;
  long platformId = 1;
  final String fqcName = "class";
  when(methodSensorTypeIdentDao.findIdByClassNameAndPlatformId(fqcName, platformId)).thenReturn(Collections.<Long> emptyList());
  Mockito.doAnswer(new Answer<Object>() {
    @Override
    public Object answer(InvocationOnMock invocation) throws Throwable {
      MethodSensorTypeIdent methodSensorIdent = (MethodSensorTypeIdent) invocation.getArguments()[0];
      methodSensorIdent.setId(Long.valueOf(methodSensorId));
      methodSensorIdent.setFullyQualifiedClassName(fqcName);
      return null;
    }
  }).when(methodSensorTypeIdentDao).saveOrUpdate((MethodSensorTypeIdent) anyObject());
  long registeredId = registrationService.registerMethodSensorTypeIdent(platformId, fqcName, Collections.<String, Object> emptyMap());
  assertThat(registeredId, is(equalTo(methodSensorId)));
  verify(platformIdentCache, times(1)).markDirty(platformId);
  ArgumentCaptor<MethodSensorTypeIdent> methodSensorArgument = ArgumentCaptor.forClass(MethodSensorTypeIdent.class);
  verify(methodSensorTypeIdentDao, times(1)).saveOrUpdate(methodSensorArgument.capture());
  assertThat(methodSensorArgument.getValue().getFullyQualifiedClassName(), is(equalTo(fqcName)));
  assertThat(methodSensorArgument.getValue().getPlatformIdent().getId(), is(equalTo(platformId)));
  verify(platformIdentCache, times(1)).markDirty(platformId);
}
origin: inspectIT/inspectIT

/**
 * {@inheritDoc}
 */
@Override
@MethodLog
public long registerMethodSensorTypeIdent(long platformId, String fullyQualifiedClassName, Map<String, Object> parameters) {
  MethodSensorTypeIdent methodSensorTypeIdent;
  try {
    List<Long> methodSensorTypeIdents = methodSensorTypeIdentDao.findIdByClassNameAndPlatformId(fullyQualifiedClassName, platformId);
    if (1 == methodSensorTypeIdents.size()) {
      Long id = methodSensorTypeIdents.get(0);
      methodSensorTypeIdentDao.updateParameters(id, parameters);
      return id;
    } else {
      // only if the new sensor is registered we need to update the platform ident
      PlatformIdent platformIdent = new PlatformIdent();
      platformIdent.setId(platformId);
      methodSensorTypeIdent = new MethodSensorTypeIdent();
      methodSensorTypeIdent.setPlatformIdent(platformIdent);
      methodSensorTypeIdent.setFullyQualifiedClassName(fullyQualifiedClassName);
      methodSensorTypeIdent.setSettings(parameters);
      methodSensorTypeIdentDao.saveOrUpdate(methodSensorTypeIdent);
      return methodSensorTypeIdent.getId();
    }
  } finally {
    platformIdentCache.markDirty(platformId);
  }
}
rocks.inspectit.server.daoMethodSensorTypeIdentDaosaveOrUpdate

Popular methods of MethodSensorTypeIdentDao

  • findIdByClassNameAndPlatformId
  • updateParameters

Popular in Java

  • Updating database using SQL prepared statement
  • onCreateOptionsMenu (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • BoxLayout (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now