Tabnine Logo
RoutingService
Code IndexAdd Tabnine to your IDE (free)

How to use
RoutingService
in
com.epam.wilma.router

Best Java code snippets using com.epam.wilma.router.RoutingService (Showing top 20 results out of 315)

origin: epam/Wilma

  /**
   * Modify the ordering in the stubDescriptors of routingService.
   * @param direction is the way where we want to move the selected stub descriptor
   * @param groupName is the groupname of selected stub descriptor
   * @param request is only needed for {@link UrlAccessLogMessageAssembler}
   * @throws ClassNotFoundException in case of problem
   */
  public void doChange(final int direction, final String groupName, final HttpServletRequest request) throws ClassNotFoundException {
    routingService.performModification(new ChangeOrderCommand(direction, groupName, request, urlAccessLogMessageAssembler));
  }
}
origin: epam/Wilma

@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
  response.setContentType("application/json");
  PrintWriter out = response.getWriter();
  Map<String, StubDescriptor> stubDescriptors = routingService.getStubDescriptors();
  writeAllDialogDescriptors(out, stubDescriptors);
  out.flush();
  out.close();
}
origin: epam/Wilma

@Override
public ResponseDescriptorDTO getResponseDescriptor(final String key) {
  return routingService.getResponseDescriptorDTOAndRemove(key);
}
origin: epam/Wilma

@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
  logger.info(urlAccessLogMessageAssembler.assembleMessage(req, "Set Operation Mode: STUB."));
  proxyModeToggle.switchProxyModeOff();
  routingService.setOperationMode(OperationMode.STUB);
}
origin: epam/Wilma

/**
* Redirects requests by changing their URI.
* @param request the request that is redirected
*/
public void reroute(final WilmaHttpRequest request) {
  if (routingService.redirectRequestToStub(request)) {
    try {
      request.setUri(getURI());
    } catch (URISyntaxException e) {
      logger.error(e.getMessage());
    }
  }
}
origin: epam/Wilma

@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
  resp.setContentType("application/json");
  PrintWriter out = resp.getWriter();
  boolean proxyModeOn = proxyModeToggle.isProxyModeOn();
  boolean stubModeOn = routingService.isStubModeOn();
  boolean wilmaModeOn = !proxyModeOn && !stubModeOn;
  out.write("{\"proxyMode\":" + proxyModeOn + ",\"stubMode\":" + stubModeOn + ",\"wilmaMode\":" + wilmaModeOn + "}");
  out.flush();
  out.close();
}
origin: epam/Wilma

@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
  logger.info(urlAccessLogMessageAssembler.assembleMessage(req, "Set Operation Mode: PROXY."));
  proxyModeToggle.switchProxyModeOn();
  routingService.setOperationMode(OperationMode.PROXY);
}
origin: epam/Wilma

@Test
public void testRerouteWhenUriNotCorrectShouldLogError() throws URISyntaxException {
  //GIVEN
  doThrow(new URISyntaxException("", "")).when(underTest).getURI();
  given(routingService.redirectRequestToStub(request)).willReturn(true);
  //WHEN
  underTest.reroute(request);
  //THEN
  verify(logger).error(Mockito.anyString());
}
origin: epam/Wilma

@Test
public void testDoGetShouldWriteStatusToResponse() throws ServletException, IOException {
  //GIVEN
  given(proxyModeToggle.isProxyModeOn()).willReturn(true);
  given(routingService.isStubModeOn()).willReturn(false);
  //WHEN
  underTest.doGet(request, response);
  //THEN
  verify(printWriter).write("{\"proxyMode\":true,\"stubMode\":false,\"wilmaMode\":false}");
}
origin: epam/Wilma

  /**
   * Call the changeStubConfigurationStatus what set the enabled/disabled status at the selected stub descriptor and then applies the change at {@link RoutingService}.
   * @param nextStatus is the new status of the selected stub descriptor
   * @param groupName is the groupname of selected stub descriptor
   * @param request is only needed for {@link UrlAccessLogMessageAssembler}
   * @throws ClassNotFoundException in case of problem
   */
  public void changeStatus(final boolean nextStatus, final String groupName, final HttpServletRequest request) throws ClassNotFoundException {
    routingService.performModification(new ChangeStatusCommand(nextStatus, groupName, request, urlAccessLogMessageAssembler));
  }
}
origin: epam/Wilma

@Override
public void process(final WilmaHttpEntity entity) throws ApplicationException {
  Map<String, StubDescriptor> stubDescriptors = routingService.getStubDescriptors();
  for (String groupName : stubDescriptors.keySet()) {
    StubDescriptor stubDescriptor = stubDescriptors.get(groupName);
    List<InterceptorDescriptor> interceptorDescriptors = stubDescriptor.getInterceptorDescriptors();
    for (InterceptorDescriptor interceptorDescriptor : interceptorDescriptors) {
      ResponseInterceptor interceptor = interceptorDescriptor.getResponseInterceptor();
      callInterceptor(interceptor, entity, interceptorDescriptor);
    }
  }
}
origin: epam/Wilma

@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
  logger.info(urlAccessLogMessageAssembler.assembleMessage(req, "Set Operation Mode: WILMA (proxy+stub)."));
  proxyModeToggle.switchProxyModeOff();
  routingService.setOperationMode(OperationMode.WILMA);
}
origin: epam/Wilma

@Test
public void testGetResponseDescriptorDTOAndRemoveShouldReturnNullWhenKeyNotFound() {
  //GIVEN
  Map<String, ResponseDescriptor> responseDescriptorMap = new HashMap<>();
  String key = "key";
  Whitebox.setInternalState(underTest, "responseDescriptorMap", responseDescriptorMap);
  //WHEN
  ResponseDescriptorDTO actual = underTest.getResponseDescriptorDTOAndRemove(key);
  //THEN
  assertNull(actual);
}
origin: epam/Wilma

@Test
public void testRerouteShouldNotSetNewUri() throws URISyntaxException {
  //GIVEN
  uri = new URI("http://127.0.0.1:" + internalPort + "/stub/");
  given(routingService.redirectRequestToStub(request)).willReturn(false);
  //WHEN
  underTest.reroute(request);
  //TEST
  verify(request, times(0)).setUri(uri);
}
origin: epam/Wilma

  @Test
  public void testDoPostShouldWriteStatusToResponse() throws ServletException, IOException {
    //GIVEN
    given(proxyModeToggle.isProxyModeOn()).willReturn(true);
    given(routingService.isStubModeOn()).willReturn(false);
    //WHEN
    underTest.doPost(request, response);
    //THEN
    verify(printWriter).write("{\"proxyMode\":true,\"stubMode\":false,\"wilmaMode\":false}");
  }
}
origin: epam/Wilma

private void createStubDescriptor(final String jsonFilePath) {
  try {
    StubDescriptorModificationCommand command;
    command = newStubDescriptorJsonCommandFactory.create(jsonFilePath, stubConfigurationJsonBuilder, sequenceDescriptorHolder);
    routingService.performModification(command);
  } catch (ClassNotFoundException | FileNotFoundException e) {
    throw new DescriptorCannotBeParsedException("One of the stub descriptor files cannot be found!", e);
  }
}
origin: epam/Wilma

/**
 * This method deletes all old files from the cache folder.
 * Then it gets all stub descriptors from {@link RoutingService} and call {@link StubConfigurationSaver} to save all of the descriptors.
 * @throws JsonTransformationException is thrown when a document can not be written
 */
public void saveStubConfigurations() throws JsonTransformationException {
  cleaner.cleanCache();
  Map<String, StubDescriptor> descriptors = routingService.getStubDescriptors();
  saver.saveAllStubConfigurations(descriptors);
}
origin: epam/Wilma

@Test
public void testDoGetShouldSetOpModeAndToggleInRoutingService() throws ServletException, IOException {
  //GIVEN
  OperationMode operationMode = OperationMode.STUB;
  //WHEN
  underTest.doGet(request, response);
  //THEN
  verify(routingService).setOperationMode(operationMode);
}
origin: epam/Wilma

@Test
public void testGetResponseDescriptorShouldCallRoutingService() {
  //GIVEN
  String key = "key";
  //WHEN
  underTest.getResponseDescriptor(key);
  //THEN
  verify(routingService).getResponseDescriptorDTOAndRemove(key);
}
origin: epam/Wilma

@Test
public void testRerouteShouldSetNewUri() throws URISyntaxException {
  //GIVEN
  uri = new URI("http://127.0.0.1:" + internalPort + "/stub/");
  given(routingService.redirectRequestToStub(request)).willReturn(true);
  //WHEN
  underTest.reroute(request);
  //TEST
  verify(request).setUri(uri);
}
com.epam.wilma.routerRoutingService

Javadoc

Contains route logic of request messages.

Most used methods

  • performModification
    This method execute the given command. The given command is any operation which works with the stubD
  • getStubDescriptors
  • getResponseDescriptorDTOAndRemove
    Reads a value matched to a key from the response descriptor map and if the value is found it deletes
  • setOperationMode
    Sets the new operation mode.
  • isStubModeOn
  • redirectRequestToStub
    Redirects requests based on their content. If a request needs to be redirected to the stub, it will
  • getOperationMode
  • saveInResponseDescriptorMap

Popular in Java

  • Updating database using SQL prepared statement
  • compareTo (BigDecimal)
  • scheduleAtFixedRate (Timer)
  • onCreateOptionsMenu (Activity)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Menu (java.awt)
  • Permission (java.security)
    Legacy security code; do not use.
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • BoxLayout (javax.swing)
  • 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