src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
Portfolio { public final void addIndexes(final List<Index> indexes) { if (indexes.size() > 0) { String index = indexes.get(0).getYahooId(); this.indexes.put(index, indexes); } } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double ... | @Test public void testAddIndexes() { final List<Index> indexes = new ArrayList<>(); final Index index = Index.builder().yahooId(CAC40).build(); indexes.add(index); portfolio.addIndexes(indexes); final Map<String, List<Index>> actual = portfolio.getIndexes(); assertNotNull(actual); assertThat(actual.size(), is(1)); asse... |
Portfolio { public final String getPortfolioReview() { final StringBuilder sb = new StringBuilder(); sb.append("<table class=\"shareValueTableDetails\">"); for (final Equity equity : getEquities()) { sb.append("<tr><td width=200px><b>") .append(equity.getCurrentName()) .append("</b></td><td width=180px>") .append(equit... | @Test public void testGetPortfolioReview() { portfolio.setEquities(createEquities()); final String actual = portfolio.getPortfolioReview(); assertNotNull(actual); } |
TokenUtils { public static KeyPair generateKeyPair(int keySize) throws NoSuchAlgorithmException { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); keyPairGenerator.initialize(keySize); KeyPair keyPair = keyPairGenerator.genKeyPair(); return keyPair; } private TokenUtils(); static String generat... | @Test public void testKeyPairGeneration() throws Exception { KeyPair keyPair = TokenUtils.generateKeyPair(2048); PrivateKey privateKey = keyPair.getPrivate(); PublicKey publicKey = keyPair.getPublic(); byte[] privateKeyEnc = privateKey.getEncoded(); byte[] privateKeyPem = Base64.getEncoder().encode(privateKeyEnc); Stri... |
TokenUtils { public static PrivateKey readPrivateKey(String pemResName) throws Exception { InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName); byte[] tmp = new byte[4096]; int length = contentIS.read(tmp); PrivateKey privateKey = decodePrivateKey(new String(tmp, 0, length)); return privateKey; } p... | @Test public void testReadPrivateKey() throws Exception { PrivateKey privateKey = TokenUtils.readPrivateKey("/privateKey.pem"); System.out.println(privateKey); } |
TokenUtils { public static PublicKey readPublicKey(String pemResName) throws Exception { InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName); byte[] tmp = new byte[4096]; int length = contentIS.read(tmp); PublicKey publicKey = decodePublicKey(new String(tmp, 0, length)); return publicKey; } private... | @Test public void testReadPublicKey() throws Exception { RSAPublicKey publicKey = (RSAPublicKey) TokenUtils.readPublicKey("/publicKey.pem"); System.out.println(publicKey); System.out.printf("RSAPublicKey.bitLength: %s\n", publicKey.getModulus().bitLength()); } |
MicrometerMetricsRegistry implements MetricsRegistry { @Override public <T> Gauge gauge(String name, Collection<Tag> tags, T obj, ToDoubleFunction<T> f) { return new MicrometerGauge<T>(io.micrometer.core.instrument.Gauge.builder(name, obj, f).tags(toTags(tags)).register(registry)); } MicrometerMetricsRegistry(MeterRegi... | @Test public void gaugeOnNullValue() { Gauge gauge = registry.gauge("gauge", emptyList(), null, obj -> 1.0); assertEquals(gauge.value(), Double.NaN, 0); } |
Span implements io.opentracing.Span { @Override public void finish() { finishTrace(clock.microTime()); } Span(Tracer tracer, Clock clock, String operationName, SpanContext context, long startTime, Map<String, Object> tags, List<Reference> references); @Override String toString(); @Override void finish(); @Override void... | @Test public void testFinishAfterFinish() { InMemoryDispatcher dispatcher = new InMemoryDispatcher.Builder(metrics).build(); tracer = new Tracer.Builder(metrics, "remote-dispatcher", dispatcher).build(); Span span = tracer.buildSpan("operation").start(); span.finish(); try { span.finish(); Assert.fail(); } catch (Illeg... |
GRPCAgentClient extends BaseGrpcClient<Span> { @Override public boolean send(Span span) throws ClientException { try (Sample timer = sendTimer.start()) { stub.dispatch(format.format(span), observer); } catch (Exception e) { sendExceptionCounter.increment(); throw new ClientException(e.getMessage(), e); } return true; }... | @Test public void testDispatch() throws Exception { final Span span = tracer.buildSpan("happy-path").start(); span.finish(); final ArgumentCaptor<com.expedia.open.tracing.Span> spanCapture = ArgumentCaptor.forClass(com.expedia.open.tracing.Span.class); client.send(span); verify(serviceImpl, times(1)).dispatch(spanCaptu... |
HttpCollectorClient extends BaseHttpClient implements Client<Span> { @Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); } HttpCollectorClient(String endpoint, Map<String, String> headers); HttpCollectorClient(Strin... | @Test public void testDispatch() throws Exception { final Span span = tracer.buildSpan("happy-path").asChildOf(spanContext).start(); span.finish(); final ArgumentCaptor<HttpPost> httpPostCapture = ArgumentCaptor.forClass(HttpPost.class); final CloseableHttpClient http = Mockito.mock(CloseableHttpClient.class); final Cl... |
RemoteDispatcher implements Dispatcher { @Override public void dispatch(Span span) { try (Sample timer = dispatchTimer.start()) { if (running.get()) { final boolean accepted = acceptQueue.offer(span); if (!accepted) { dispatchRejectedCounter.increment(); LOGGER.warn("Send queue is rejecting new spans"); } } else { disp... | @Test public void testFlushTimer() { Span span = tracer.buildSpan("happy-path").start(); dispatcher.dispatch(span); Awaitility.await() .atMost(flushInterval * 2, TimeUnit.MILLISECONDS) .until(() -> client.getFlushedSpans().size() > 0); Assert.assertEquals(0, client.getReceivedSpans().size()); Assert.assertEquals(1, cli... |
TextMapPropagator implements Injector<TextMap>, Extractor<TextMap> { @Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put... | @Test public void propagatorInjectsSpanContextIdentitiesAsExpected() { final KeyConvention keyConvention = new DefaultKeyConvention(); final TextMapPropagator propagator = new TextMapPropagator.Builder().withKeyConvention(keyConvention).build(); final MapBackedTextMap carrier = new MapBackedTextMap(); final SpanContext... |
Span implements io.opentracing.Span { public String getServiceName() { synchronized (this) { return getTracer().getServiceName(); } } Span(Tracer tracer, Clock clock, String operationName, SpanContext context, long startTime, Map<String, Object> tags, List<Reference> references); @Override String toString(); @Override ... | @Test public void testServiceName() { String expected = "service-name"; Span span = new Tracer.Builder(metrics, expected, dispatcher).build().buildSpan(expected).start(); Assert.assertEquals(expected, span.getServiceName()); } |
Span implements io.opentracing.Span { public Map<String, Object> getTags() { synchronized (this) { return Collections.unmodifiableMap(tags); } } Span(Tracer tracer, Clock clock, String operationName, SpanContext context, long startTime, Map<String, Object> tags, List<Reference> references); @Override String toString();... | @Test public void testTagForTagType() { String key = "typed-key-name"; String value = "typed-tag-value-value"; StringTag stringTag = new StringTag(key); stringTag.set(span, value); Assert.assertEquals(value, span.getTags().get(key)); } |
EventJobExecutionController { @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not fo... | @Test public void testExecuteJobErrCndtn() { EventJobDTO eventDTO = createEventJobDTO(); eventDTO.getEventMonkeyList().get(0).setMonkeyScriptType(""); EventJobDTO returnDTO = (EventJobDTO) eventJobController.executeJob(eventDTO).getBody(); System.out.println("return "); assertEquals("Monkey Script Type is blank for Mon... |
ScenarioRestController { @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perfo... | @Test public void testDeleteAllScenarios() { ResponseEntity<Object> response = scenarioController.deleteAllScenarios(); assertEquals(HttpStatus.OK, response.getStatusCode()); verify(scenarioRepository, times(1)).deleteAll(); } |
ScenarioRestController { @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform ... | @Test public void testBulkDeleteScenarioErrCndtn() { List<Scenario> sceList = new ArrayList<>(); Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); scenario.setId(""); sceList.add(scenario); ScenarioAdapter sceAdapter = new ScenarioAdapter(); sceAdapter.setScenarios(sceList); MessageWrapper apiError = (Message... |
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @... | @Test public void testGetMonkeyStrategyByNameErrCndtn() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findByMonkeyStrategyNameAndTeamName(MON... |
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Mon... | @Test public void testGetDefaultMonkeyStrategy() { setSecuirtyContext(TEAMNAME, USERNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<MonkeyStrategy> monkeyStrategies = new ArrayList<>(); monkeyStrategies.add(mon... |
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey ... | @Test public void testGetMonkeyStrategyByNameAndVersion() { setSecuirtyContext(TEAMNAME, USERNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenR... |
MonkeyStrategyRestController { @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 40... | @Test public void testCountByTeamName() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(monkeyStrategyRepository.countByTeamName(TEAMNAME)).thenReturn((long) 1); when(monkeyStrategyRepository.count()).thenReturn((long) 2); when(teamUserRepository.findByUserNa... |
MonkeyStrategyRestController { @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not autho... | @Test public void testAddMonkeyStrategyErrCndtn() { MonkeyStrategy monkeyStrategy = null; UriComponentsBuilder ucBuilder = UriComponentsBuilder.newInstance(); MessageWrapper apiError = (MessageWrapper) monkeyStrategyController .addMonkeyStrategy(req, monkeyStrategy, ucBuilder).getBody(); assertEquals(HttpStatus.BAD_REQ... |
MonkeyStrategyRestController { @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not autho... | @Test public void testUpdateMonkeyStrategyErrCndtn() { MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); setSecuirtyContext(OTHERTEAM, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, OTHERTEAM); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenRetu... |
MonkeyStrategyRestController { @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not autho... | @Test public void testDeletemonkeystrategyErrCndtn() { MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepositor... |
MonkeyStrategyRestController { @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and te... | @Test public void testGetFailurePointByApplicationEnvironmentAndTeamNameErrCndtn() { TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); Application app = new Application(); app.setTeamName("TEST"); app.setApplicationName("testApp"); Environment qaEnvronment = new Envir... |
FailurePointRestController { @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view r... | @Test public void testListAllFailurePoints() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); List<FailurePoint> fpList = new ArrayList<>(); fpList.add(fp); when(failurePointRepository.findAll()).thenReturn(fpList); @SuppressWarnings("unchecked") List<FailurePoint> failurePointList = (List<FailurePoint>) failu... |
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiRespons... | @Test public void testGetFailurePoint() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findOne(fp.getId())).thenReturn(fp); FailurePoint failurePoint = (FailurePoint) failurePointController.getFailurePoint(fp.getId()).getBody(); assertEquals(MonkeyType.CHAOS, failurePoint.getMonke... |
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(co... | @Test public void testGetFailurePointsByName() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findByName(fp.getName())).thenReturn(fp); FailurePoint failurePoint = (FailurePoint) failurePointController.getFailurePointsByName(fp.getName()) .getBody(); assertEquals(MonkeyType.CHAOS,... |
MonkeyStrategyRestController { @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized t... | @Test public void testListAllMonkeyStrategies() { MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); List<MonkeyStrategy> monkeyStrategies = new ArrayList<>(); monkeyStrategies.add(monkeyStrategy); when(monkeyStrategyRepository.findAll()).thenReturn(monkeyStrategies); @SuppressWarnings(... |
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse... | @Test public void testGetFailurePointByCategory() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); List<FailurePoint> fpList = new ArrayList<>(); fpList.add(fp); when(failurePointRepository.findByCategory(fp.getCategory())).thenReturn(fpList); @SuppressWarnings("unchecked") List<FailurePoint> failurePointList ... |
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = ... | @Test public void testGetFailurePointByRole() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); List<FailurePoint> fpList = new ArrayList<>(); fpList.add(fp); when(failurePointRepository.findByRole(fp.getRole())).thenReturn(fpList); @SuppressWarnings("unchecked") List<FailurePoint> failurePointList = (List<Fail... |
FailurePointRestController { @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to... | @Test public void testAddFailurePoint() { UriComponentsBuilder ucBuilder = UriComponentsBuilder.newInstance(); FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findByName(fp.getName())).thenReturn(null); when(failurePointRepository.save(fp)).thenReturn(fp); ResponseEntity<Object> resp... |
FailurePointRestController { @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is n... | @Test public void testBulkAddFailurePoint() { FailurePoint fp1 = createFailurePoint(FPNAME, TEAMNAME); FailurePoint fp2 = createFailurePoint("fpName2", TEAMNAME); List<FailurePoint> fpList = new ArrayList<>(); fpList.add(fp1); fpList.add(fp2); FailurePointAdapter fpAdapter = new FailurePointAdapter(); fpAdapter.setFail... |
FailurePointRestController { @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResp... | @Test public void testUpdateFailurePoint() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findOne(fp.getId())).thenReturn(fp); when(failurePointRepository.save(fp)).thenReturn(fp); ResponseEntity<Object> response = failurePointController.updateFailurePoint(fp.getId(), fp); assertE... |
FailurePointRestController { @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiRespo... | @Test public void testDeleteFailurePoint() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findOne(fp.getId())).thenReturn(fp); ResponseEntity<Object> response = failurePointController.deleteFailurePoint(fp.getId()); assertEquals(HttpStatus.OK, response.getStatusCode()); verify(fai... |
FailurePointRestController { @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authori... | @Test public void testDeleteAllFailurePoint() { ResponseEntity<Object> response = failurePointController.deleteAllFailurePoints(); assertEquals(HttpStatus.OK, response.getStatusCode()); verify(failurePointRepository, times(1)).deleteAll(); } |
TeamUserController { @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"... | @Test public void testGetAllUsers() { TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<TeamUser> teamUserList = new ArrayList<>(); teamUserList.add(teamUser); when(teamUserRepository.findAll()).thenReturn(teamUserList); @SuppressWarnings("unchecked") List<TeamUser> getAllUsers = (List<TeamUser>) teamU... |
TeamUserController { @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized t... | @Test public void testGetCurrentTeamOfUser() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); TeamUser user = (TeamUser) teamUserController.getCurrentTeamOfUser(req).getBody(... |
TeamUserController { @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is ... | @Test public void testUpdateTeamOfUserErrCndtn() { MessageWrapper apiError = (MessageWrapper) teamUserController.updateTeamOfUser(req, "").getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("TeamUser cannot be modified as new Team Name is null", apiError.getStatusMessage()); String newTea... |
EventRestController { @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @A... | @Test public void testListEvents() { EventRecorder eventRecorder = createEvent(TEAMNAME); List<EventRecorder> events = new ArrayList<>(); events.add(eventRecorder); when(eventRepository.findAll()).thenReturn(events); @SuppressWarnings("unchecked") List<EventRecorder> eventLists = (List<EventRecorder>) eventController.l... |
MonkeyStrategyRestController { @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 40... | @Test public void testListAllMonkeyStrategy() { setSecuirtyContext(TEAMNAME, USERNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<MonkeyStrategy> monkeyStrategies = new ArrayList<>(); monkeyStrategies.add(monkey... |
EventRestController { @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not... | @Test public void testListAllEvents() { setSecuirtyContext(TEAMNAME, USERNAME); EventRecorder eventRecorder = createEvent(TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<EventRecorder> events = new ArrayList<>(); events.add(eventRecorder); Page<EventRecorder> eventRecorderPage = new PageIm... |
EventRestController { @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message ... | @Test public void testListLatestEventsByAppName() { setSecuirtyContext(TEAMNAME, USERNAME); EventRecorder eventRecorder = createEvent(TEAMNAME); EventRecorder eventSecondRecorder = createEvent(TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<EventRecorder> events = new ArrayList<>(); events... |
EventRestController { @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is no... | @Test public void testListEvent() { setSecuirtyContext(TEAMNAME, USERNAME); EventRecorder eventRecorder = createEvent(TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(eventRepository.findOneForTeam(ev... |
EventRestController { @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is no... | @Test public void testGetstatusupdateforevent() { setSecuirtyContext(TEAMNAME, USERNAME); EventRecorder eventRecorder = createEvent(TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(eventRepository.fin... |
EventRestController { @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given team name"), @ApiResponse(code = 401, message = "U... | @Test public void testCountByTeamName() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(eventRepository.countByTeamName(TEAMNAME)).thenReturn((long) 1); when(eventRepository.count()).thenReturn((long) 2); when(teamUserRepository.findByUserNameAndDefaultFlag(U... |
ApplicationRestController { @ApiOperation(value = "This API returns all Application Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requ... | @Test public void testGetAllApplication() { Application app = createApplication(APPNAME, TEAMNAME); List<Application> applications = new ArrayList<>(); applications.add(app); when(applicationRepository.findAll()).thenReturn(applications); @SuppressWarnings("unchecked") List<Application> appList = (List<Application>) ap... |
ApplicationRestController { @ApiOperation(value = "This API returns count of Application objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Application objects for team name"), @ApiResponse(code = 401, messag... | @Test public void testCountByTeamName() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(applicationRepository.countByTeamName(TEAMNAME)).thenReturn((long) 1); when(applicationRepository.count()).thenReturn((long) 1); when(teamUserRepository.findByUserNameAndD... |
ApplicationRestController { @ApiOperation(value = "This API returns list of all Application objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Objects for given team"), @ApiResponse(code = 401, message ... | @Test public void testGetAllApplicationsForTeam() { setSecuirtyContext(TEAMNAME, USERNAME); Application app = createApplication(APPNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<Application> applications = new ArrayList<>(); applications.add(app); Page<Application> appPage = new Pag... |
ApplicationRestController { @ApiOperation(value = "This API returns single Application Object present in Elastic Search for given App ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Application Object for given App ID"), @ApiResponse(code = 401, message ... | @Test public void testgetApplication() { setSecuirtyContext(TEAMNAME, USERNAME); Application app = createApplication(APPNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.fin... |
ApplicationRestController { @ApiOperation(value = "This API returns single Application Object present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Application Object for given App Name"), @ApiResponse(code = 401, message = "... | @Test public void testGetApplicationsByName() { setSecuirtyContext(TEAMNAME, USERNAME); Application app = createApplication(APPNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationReposit... |
ApplicationRestController { @ApiOperation(value = "This API returns Application Objects present in Elastic Search for given App ID and App Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Application Object for given App ID and App Category"), @ApiResponse... | @Test public void testGetApplicationByNameAndCategory() { setSecuirtyContext(TEAMNAME, USERNAME); Application app = createApplication(APPNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicat... |
MonkeyStrategyRestController { @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(cod... | @Test public void testListAllMonkeyTypes() { @SuppressWarnings("unchecked") List<String> monkeyTypeList = (List<String>) monkeyStrategyController.listAllMonkeyTypes().getBody(); assertEquals(8, monkeyTypeList.size()); assertEquals(MonkeyType.CHAOS, monkeyTypeList.get(0)); } |
ApplicationRestController { @ApiOperation(value = "This API inserts an Application Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Application object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to p... | @Test public void testAddApplicationErrCndtn() { Application addApp = null; UriComponentsBuilder ucBuilder = UriComponentsBuilder.newInstance(); MessageWrapper apiError = (MessageWrapper) appController.addApplication(req, addApp, ucBuilder).getBody(); assertEquals(HttpStatus.BAD_REQUEST, apiError.getStatus()); assertEq... |
ApplicationRestController { @ApiOperation(value = "This API updates an Application Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Application objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to ... | @Test public void testUpdateApplicationErrCndtn() { Application addApp = createApplication(APPNAME, TEAMNAME); setSecuirtyContext(OTHERTEAM, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, OTHERTEAM); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicati... |
ApplicationRestController { @ApiOperation(value = "This API deletes an Application Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Application object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to p... | @Test public void testDeleteApplicationErrCndtn() { Application addApp = createApplication(APPNAME, TEAMNAME); setSecuirtyContext(OTHERTEAM, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, OTHERTEAM); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicati... |
ScenarioRestController { @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested obj... | @Test public void testListScenarios() { Scenario sce = createScenario(SCENARIONAME, TEAMNAME); List<Scenario> sceList = new ArrayList<>(); sceList.add(sce); when(scenarioRepository.findAll()).thenReturn(sceList); List<Scenario> scenarioList = (List<Scenario>) scenarioController.listScenarios().getBody(); assertEquals(1... |
ScenarioRestController { @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User i... | @Test public void testListAllScenarios() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); Scenario sce = createScenario(SCENARIONAME, TEAMNAME); List<Scenario> sceList = new ArrayList<>(); sceList.add(sce); Page<Scenario> scePage = new PageImpl<>(sceList); when(tea... |
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID")... | @Test public void testGetMonkeyStrategy() { setSecuirtyContext(TEAMNAME, USERNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser);... |
ScenarioRestController { @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario objects for team name"), @ApiResponse(code = 401, message = "User... | @Test public void testCountByTeamName() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(scenarioRepository.countByTeamName(TEAMNAME)).thenReturn((long) 1); when(scenarioRepository.count()).thenReturn((long) 2); when(teamUserRepository.findByUserNameAndDefault... |
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message... | @Test public void testGetScenario() { Scenario sce = createScenario(SCENARIONAME, TEAMNAME); when(scenarioRepository.findOne(sce.getId())).thenReturn(sce); Scenario scenario = (Scenario) scenarioController.getScenario(sce.getId()).getBody(); assertEquals(TESTSCENARIOID, scenario.getId()); assertEquals(SCENARIONAME, sce... |
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, mes... | @Test public void testGetScenarioByName() { Scenario sce = createScenario(SCENARIONAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.find... |
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not au... | @Test public void testListAllScenariosByApplicationName() { Scenario sce = createScenario(SCENARIONAME, TEAMNAME); List<Scenario> sceList = new ArrayList<>(); sceList.add(sce); Page<Scenario> scePage = new PageImpl<>(sceList); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, US... |
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiRe... | @Test public void testGetScenarioListByName() { Scenario sce = createScenario(SCENARIONAME, TEAMNAME); List<Scenario> sceList = new ArrayList<>(); sceList.add(sce); Page<Scenario> scePage = new PageImpl<>(sceList); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); whe... |
ScenarioRestController { @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add... | @Test public void testaddScenarioErrCndtn() { UriComponentsBuilder ucBuilder = UriComponentsBuilder.newInstance(); Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDe... |
ScenarioRestController { @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized t... | @Test public void testBulkAddScenarioErrCndtn() { List<Scenario> sceList = new ArrayList<>(); Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); sceList.add(scenario); ScenarioAdapter sceAdapter = new ScenarioAdapter(); sceAdapter.setScenarios(sceList); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNA... |
ScenarioRestController { @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Up... | @Test public void testUpdateScenarioErrCndtn() { Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(scenarioRepository.findOne(scenario.getId())).thenReturn(null); MessageWrapper apiError = (MessageWrappe... |
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, mess... | @Test public void testDeleteScenarioErrCndtn() { Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); when(scenarioRepository.findOne(scenario.getId())).thenReturn(null); MessageWrapper apiError = (MessageWrapper) scenarioController.deleteScenario(scenario.getId()).getBody(); assertEquals(HttpStatus.NOT_FOUND, a... |
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = ... | @Test public void testDeleteScenarioForApplicationErrCndtn() { Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); List<Scenario> sceList = new ArrayList<>(); Page<Scenario> scePage = new PageImpl<>(sceList); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); w... |
Customer extends Person { public void setEmail(String email) { this.email = email; } Customer(); Customer(String firstName, String lastName, String email, String phoneNumber); String getEmail(); void setEmail(String email); String getPhoneNumber(); void setPhoneNumber(String phoneNumber); Integer getAge(); void setAge... | @Test public void shouldShowDifferentLifeCyclePhases() throws Exception { Customer customer = new Customer("John", "Smith", "jsmith@gmail.com", "1234565"); assertFalse(em.contains(customer)); System.out.println("\nPERSIST"); tx.begin(); em.persist(customer); tx.commit(); assertTrue(em.contains(customer), "should be in ... |
Item { public Long getId() { return id; } Item(); Item(String title, Float price, String description); Long getId(); String getTitle(); void setTitle(String title); Float getPrice(); void setPrice(Float price); String getDescription(); void setDescription(String description); } | @Test public void shouldCreateSeveralItems() throws Exception { Item item = new Item("Junk", 52.50f, "A piece of junk"); CD cd01 = new CD("St Pepper", 12.80f, "Beatles master piece", "Apple", 1, 53.32f, "Pop/Rock"); CD cd02 = new CD("Love SUpreme", 20f, "John Coltrane love moment", "Blue Note", 2, 87.45f, "Jazz"); Book... |
CreditCard { public String getNumber() { return number; } CreditCard(); CreditCard(String number, String expiryDate, Integer controlNumber, CreditCardType creditCardType); String getNumber(); void setNumber(String number); String getExpiryDate(); void setExpiryDate(String expiryDate); Integer getControlNumber(); void ... | @Test public void shouldCreateACreditCard() throws Exception { CreditCard creditCard = new CreditCard("123412341234", "12/12", 1253, AMERICAN_EXPRESS); tx.begin(); em.persist(creditCard); tx.commit(); assertNotNull(creditCard.getNumber(), "Id should not be null"); String dbCreditCardType = (String) em.createNativeQuery... |
Address { public Long getId() { return id; } Address(); Address(Long id, String street1, String street2, String city, String state, String zipcode, String country); Long getId(); void setId(Long id); String getStreet1(); void setStreet1(String street1); String getStreet2(); void setStreet2(String street2); String getC... | @Test public void shouldCreateAnAddress() throws Exception { Address address = new Address(getRandomId(), "65B Ritherdon Rd", "At James place", "London", "LDN", "7QE554", "UK"); tx.begin(); em.persist(address); tx.commit(); assertNotNull(address.getId(), "Id should not be null"); } |
Book { public Long getId() { return id; } Book(); Book(Long id, String title, Float price, String description, String isbn, Integer nbOfPages, Boolean illustrations); Long getId(); void setId(Long id); String getTitle(); void setTitle(String title); Float getPrice(); void setPrice(Float price); String getDescription()... | @Test public void shouldCreateABook() throws Exception { Book book = new Book(getRandomId(), "The Hitchhiker's Guide to the Galaxy", 12.5F, "The Hitchhiker's Guide to the Galaxy is a science fiction comedy series created by Douglas Adams.", "1-84023-742-2", 354, false); tx.begin(); em.persist(book); tx.commit(); assert... |
Book { public Long getId() { return id; } Book(); Book(String title, Float price, String description, String isbn, Integer nbOfPages, Boolean illustrations); Long getId(); void setId(Long id); String getTitle(); void setTitle(String title); Float getPrice(); void setPrice(Float price); String getDescription(); void se... | @Test public void shouldCreateABook() throws Exception { Book book = new Book("The Hitchhiker's Guide to the Galaxy", 12.5F, "The Hitchhiker's Guide to the Galaxy is a science fiction comedy series created by Douglas Adams.", "1-84023-742-2", 354, false); tx.begin(); em.persist(book); tx.commit(); assertNotNull(book.ge... |
News { public String getContent() { return content; } News(); News(NewsId id, String content); NewsId getId(); void setId(NewsId id); String getContent(); void setContent(String content); } | @Test public void shouldCreateANews() throws Exception { News news = new News(new NewsId("Richard Wright has died", "EN"), "The keyboard of Pink Floyd has died today"); tx.begin(); em.persist(news); tx.commit(); news = em.find(News.class, new NewsId("Richard Wright has died", "EN")); assertEquals("The keyboard of Pink ... |
AddressEndpoint { @PostMapping("/addresses") public Address createAddress(@RequestBody Address address) { return addressRepository.save(address); } AddressEndpoint(AddressRepository addressRepository); @PostMapping("/addresses") Address createAddress(@RequestBody Address address); @GetMapping(value = "/addresses/count"... | @Test @Transactional public void createAddress() throws Exception { mockAddressEndpoint.perform(get("/addresses/count")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(content().string(ALL_ADDRESSES)); Address address = new Address().street1("233 Spring S... |
Customer { public Long getId() { return id; } Customer(); Customer(String firstName, String lastName, String email, String phoneNumber, Date dateOfBirth, Date creationDate); Long getId(); String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); String getEmai... | @Test public void shoulCreateACustomer() throws Exception { Customer customer = new Customer("John", "Smith", "jsmith@gmail.com", "1234565", new Date(), new Date()); tx.begin(); em.persist(customer); tx.commit(); Assertions.assertNotNull(customer.getId(), "Id should not be null"); } |
BookService { public void createBook() { EntityManagerFactory emf = Persistence.createEntityManagerFactory("cdbookstorePU"); EntityManager em = emf.createEntityManager(); EntityTransaction tx = em.getTransaction(); Book book = new Book().title("H2G2").price(12.5F).isbn("1-84023-742-2").nbOfPages(354); tx.begin(); em.pe... | @Test void shouldCreateABook() { BookService bookService = new BookService(); bookService.createBook(); } |
Customer { public void setAddress(Address address) { this.address = address; } Customer(); Customer(String firstName, String lastName, String email); Long getId(); String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); String getEmail(); void setEmail(Strin... | @Test public void shouldPersistWithFlush() throws Exception { Customer customer = new Customer("Anthony", "Balla", "aballa@mail.com"); Address address = new Address("Ritherdon Rd", "London", "8QE", "UK"); customer.setAddress(address); assertThrows(IllegalStateException.class, () -> { tx.begin(); em.persist(customer); e... |
Customer { public Long getId() { return id; } Customer(); Customer(String firstName, String lastName, String email); Long getId(); String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); String getEmail(); void setEmail(String email); Address getAddress(); v... | @Test public void shouldPersistACustomer() throws Exception { Customer customer = new Customer("Anthony", "Balla", "aballa@mail.com"); tx.begin(); em.persist(customer); tx.commit(); assertNotNull(customer.getId()); }
@Test public void shouldPersistAnAddress() throws Exception { Address address = new Address("Ritherdon ... |
Customer { public Long getId() { return id; } Customer(); Customer(String firstName, String lastName, String email, String phoneNumber); Long getId(); void setId(Long id); String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); String getEmail(); void setEma... | @Test public void shouldCreateACustomer() throws Exception { Customer customer = new Customer("John", "Smith", "jsmith@gmail.com", "1234565"); tx.begin(); em.persist(customer); tx.commit(); Assertions.assertNotNull(customer.getId(), "Id should not be null"); } |
Customer { public Long getId() { return id; } Customer(); Customer(String firstName, String lastName, String email, String phoneNumber); Long getId(); void setId(Long id); String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); String getEmail(); void setEma... | @Test public void shouldCreateACustomer() throws Exception { Customer customer = new Customer("John", "Smith", "jsmith@gmail.com", "1234565"); tx.begin(); em.persist(customer); tx.commit(); Assertions.assertNotNull(customer.getId(), "Id should not be null"); } |
Customer { @Id @GeneratedValue public Long getId() { return id; } Customer(); Customer(String firstName, String lastName, String email, String phoneNumber); void setId(Long id); void setFirstName(String firstName); void setLastName(String lastName); void setEmail(String email); void setPhoneNumber(String phoneNumber);... | @Test public void shouldCreateACustomer() throws Exception { Customer customer = new Customer("John", "Smith", "jsmith@gmail.com", "1234565"); tx.begin(); em.persist(customer); tx.commit(); Assertions.assertNotNull(customer.getId(), "Id should not be null"); } |
AddressEndpoint { @GetMapping(value = "/addresses/country/{country}") public List<Address> getAddressesByCountry(@PathVariable String country) { return addressRepository.findAllByCountry(country); } AddressEndpoint(AddressRepository addressRepository); @PostMapping("/addresses") Address createAddress(@RequestBody Addre... | @Test @Transactional public void getAddressesByCountry() throws Exception { mockAddressEndpoint.perform(get("/addresses/count")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(content().string(ALL_ADDRESSES)); mockAddressEndpoint.perform(get("/addresses/c... |
Author { public Author firstName(String firstName) { this.firstName = firstName; return this; } Long getId(); void setId(Long id); String getFirstName(); void setFirstName(String firstName); Author firstName(String firstName); String getLastName(); void setLastName(String lastName); Author lastName(String lastName); S... | @Test void shouldNotCreateAnAuthorWithNullFirstname() { Author author = new Author().firstName(null); tx.begin(); em.persist(author); assertThrows(RollbackException.class, () -> tx.commit()); } |
AddressEndpoint { @GetMapping(value = "/addresses/like/{zip}") public List<Address> getAddressesLikeZip(@PathVariable String zip) { return addressRepository.findAllLikeZip(zip); } AddressEndpoint(AddressRepository addressRepository); @PostMapping("/addresses") Address createAddress(@RequestBody Address address); @GetMa... | @Test @Transactional public void getAddressesLikeZip() throws Exception { mockAddressEndpoint.perform(get("/addresses/count")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(content().string(ALL_ADDRESSES)); mockAddressEndpoint.perform(get("/addresses/lik... |
Artist { public Artist firstName(String firstName) { this.firstName = firstName; return this; } Artist(); Artist(String firstName, String lastName, String email, String bio, LocalDate dateOfBirth); Long getId(); String getFirstName(); void setFirstName(String firstName); Artist firstName(String firstName); String getL... | @Test void shouldNotCreateAnArtistWithNullFirstname() { Artist artist = new Artist().firstName(null); tx.begin(); em.persist(artist); assertThrows(RollbackException.class, () -> tx.commit()); } |
Customer { public Long getId() { return id; } Customer(); Customer(String firstName, String lastName, String email, String phoneNumber, LocalDate dateOfBirth, LocalDateTime creationDate); Long getId(); String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); ... | @Test public void shoulCreateACustomer() throws Exception { Customer customer = new Customer("John", "Smith", "jsmith@gmail.com", "1234565", LocalDate.now(), LocalDateTime.now()); tx.begin(); em.persist(customer); tx.commit(); Assertions.assertNotNull(customer.getId(), "Id should not be null"); } |
Book { public Long getId() { return id; } Book(); Book(String title, Float price, String description, String isbn, Integer nbOfPages, Boolean illustrations); Long getId(); String getTitle(); void setTitle(String title); Float getPrice(); void setPrice(Float price); String getDescription(); void setDescription(String d... | @Test public void shouldCreateABook() throws Exception { Book book = new Book("The Hitchhiker's Guide to the Galaxy", 12.5F, "The Hitchhiker's Guide to the Galaxy is a science fiction comedy series created by Douglas Adams.", "1-84023-742-2", 354, false); tx.begin(); em.persist(book); tx.commit(); assertNotNull(book.ge... |
Track { public Long getId() { return id; } Track(); Track(String title, Float duration, String description); Long getId(); String getTitle(); void setTitle(String title); Float getDuration(); void setDuration(Float duration); byte[] getWav(); void setWav(byte[] wav); String getDescription(); void setDescription(String... | @Test public void shouldCreateATrack() throws Exception { Track track = new Track("Sgt Pepper Lonely Heart Club Ban", 4.53f, "Listen to the trumpet carefully, it's George Harrison playing"); tx.begin(); em.persist(track); tx.commit(); assertNotNull(track.getId(), "Id should not be null"); } |
News { public String getTitle() { return title; } News(); News(String title, String language, String content); String getTitle(); void setTitle(String title); String getLanguage(); void setLanguage(String language); String getContent(); void setContent(String content); } | @Test public void shouldCreateANews() throws Exception { News news = new News("Richard Wright has died", "EN", "The keyboard of Pink Floyd has died today"); tx.begin(); em.persist(news); tx.commit(); assertNotNull(news.getTitle(), "Id should not be null"); } |
NamedExtension implements Extension<T> { @Override public String getKey() { return key; } NamedExtension(String key); @Override String getKey(); @Override boolean equals(Object o); boolean equals(NamedExtension<?> o); @Override int hashCode(); @Override String toString(); } | @Test public void named_extensions_returns_its_own_key() { assertEquals("my.extension", Extension.key("my.extension").getKey()); }
@Test(expected = UnsupportedOperationException.class) public void anonymous_throws_if_try_to_get_the_key() { Extension.anonymous().getKey(); } |
LocalRrCache implements Storage, Debuggable { @Override public List<Integer> getCacheIds() { List<Integer> ids = new ArrayList<>(); for (CacheElement cacheElement : cacheStorage) { if (cacheElement != null) { ids.add(cacheElement.getId()); } } return ids; } LocalRrCache(Storage backendStore, int cacheSize); @Override b... | @Test public void testStorage() { storeAndLoad(1000); storeAndLoad(1001); storeAndLoad(1002); Assertions.assertEquals(Arrays.asList(1000, 1001, 1002), localRrCache.getCacheIds()); storeAndLoad(1003); storeAndLoad(1004); Assertions.assertEquals(Arrays.asList(1000, 1001, 1002, 1003, 1004), localRrCache.getCacheIds()); fo... |
Part02Transform { public Mono<Order> combineValues(Mono<String> phoneNumber, Mono<String> deliveryAddress) { return Mono.zip(phoneNumber, deliveryAddress, (p, d) -> new Order(p, d)); } Flux<Tuple2<String, Integer>> pairValues(Flux<String> flux1, Flux<Integer> flux2); Mono<Order> combineValues(Mono<String> phoneNumber,... | @Test public void combineValues() { Mono<String> phoneNumber = Mono.just("076123456"); Mono<String> deliveryAddress = Mono.just("Paradeplatz Zurich"); Mono<Order> order = workshop.combineValues(phoneNumber, deliveryAddress); StepVerifier.create(order).expectNext(new Order("076123456", "Paradeplatz Zurich")); order = wo... |
Part03Filtering { Flux<Integer> filterEven(Flux<Integer> flux) { return flux.filter(i -> i % 2 == 0).log(); } } | @Test public void filterEven() { Flux<Integer> flux = workshop.filterEven(Flux.just(1, 2, 3, 4, 5)); StepVerifier.create(flux) .expectNext(2, 4) .verifyComplete(); } |
Part03Filtering { Flux<Integer> ignoreDuplicates(Flux<Integer> flux) { return flux.distinct().log(); } } | @Test public void ignoreDuplicates() { Flux<Integer> flux = workshop.ignoreDuplicates(Flux.just(1, 1, 2, 2, 3, 4)); StepVerifier.create(flux) .expectNext(1, 2, 3, 4) .verifyComplete(); } |
Part03Filtering { Mono<Integer> emitLast(Flux<Integer> flux) { return flux.last(100).log(); } } | @Test public void takeAtMostOne() { Mono<Integer> mono = workshop.emitLast(Flux.just(51, 61, 12)); StepVerifier.create(mono) .expectNext(12) .verifyComplete(); mono = workshop.emitLast(Flux.empty()); StepVerifier.create(mono).expectNext(100).verifyComplete(); } |
Part03Filtering { Flux<Integer> ignoreUntil(Flux<Integer> flux) { return flux.skipUntil(integer -> integer > 10).log(); } } | @Test public void ignoreUntil() { Flux<Integer> flux = workshop.ignoreUntil(Flux.just(1, 3, 15, 5, 10)); StepVerifier.create(flux) .expectNext(15, 5, 10) .verifyComplete(); StepVerifier.create(workshop.ignoreUntil(Flux.just(1, 3, 5))).verifyComplete(); StepVerifier.create(workshop.ignoreUntil(Flux.empty())).verifyCompl... |
Part03Filtering { Mono<Integer> expectAtMostOneOrEmpty(Flux<Integer> flux) { return flux.singleOrEmpty().log(); } } | @Test public void expectAtMostOneOrEmpty() { Mono<Integer> mono = workshop.expectAtMostOneOrEmpty(Flux.just(1, 2, 3)); StepVerifier.create(mono) .expectError() .verify(); StepVerifier.create(Flux.just(1)).expectNext(1).verifyComplete(); StepVerifier.create(Flux.empty()).verifyComplete(); } |
Part03Filtering { Mono<Boolean> asyncFilter(Integer integer) { return Mono.just(integer % 2 == 0).delayElement(Duration.ofMillis(500)); } } | @Test public void asyncFilter() { Flux<Integer> flux = workshop.asyncComputedFilter(Flux.just(1, 2, 3, 4, 5)); StepVerifier.create(flux) .expectNext(2, 4) .verifyComplete(); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.