src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
Movement implements Action { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Movement other = (Movement) obj; if (mLeftWheelVelocity != other.mLeftWheelVelocity) return false; if (mRightWheelVelocity != other.mRig... | @Test public void testEqualsWithDifferentRightWheelVelocity() { Movement movement1 = new Movement(51,50); Movement movement2 = new Movement(49,50); assertThat(movement1.equals(movement2)).isEqualTo(false); }
@Test public void testEqualsWithSameValues() { Movement movement1 = new Movement(50,50); Movement movement2 = ne... |
RawWorldData implements WorldData { public void setBallPosition(BallPosition ballPos){ mBallPosition = ballPos != null ? ballPos : new BallPosition(); } static RawWorldData createRawWorldDataFromXML( String aXMLData ); @XmlTransient double getPlayTime(); @XmlTransient PlayMode getPlayMode(); @XmlTransient Score getSco... | @Test public void setBallPositionTest() { BallPosition bp = new BallPosition(30, 40, true); rawWorldDataSpy.setBallPosition(bp); assert(rawWorldDataSpy.getBallPosition().equals(bp)); } |
RawWorldData implements WorldData { @XmlTransient public List<ReferencePoint> getReferencePoints() { return mReferencePoints; } static RawWorldData createRawWorldDataFromXML( String aXMLData ); @XmlTransient double getPlayTime(); @XmlTransient PlayMode getPlayMode(); @XmlTransient Score getScore(); @XmlTransient int g... | @Test public void getReferencePointsTest() { List<ReferencePoint> refPoints = rawWorldData.getReferencePoints(); assert(refPoints==null); } |
RawWorldData implements WorldData { public ReferencePoint getReferencePoint( ReferencePointName aName ) { if( mReferencePoints.get( aName.getPosition() ).getPointName() == aName ){ return mReferencePoints.get( aName.getPosition() ); } for( ReferencePoint vPoint : mReferencePoints ){ if( vPoint.getPointName() == aName )... | @Test public void getReferencePointTestNA() { ReferencePoint mockedBottomCenter = mock(ReferencePoint.class); rawWorldData.mReferencePoints = new ArrayList<>(); rawWorldData.mReferencePoints.add(0, new ReferencePoint()); rawWorldData.mReferencePoints.add(0, new ReferencePoint()); when(mockedBottomCenter.getPointName())... |
FellowPlayer extends ReferencePoint { @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; FellowPlayer other = (FellowPlayer) obj; if (mId != other.mId) return false; if (mNickname == null) { if (other.mNickname != null) return false; } else if (!mNickname.e... | @Test public void equalsTestEqual() { fellowPlayerCompare = new FellowPlayer(5, "Bob", true, 130.7, 70.3, 0); assert(fellowPlayerOriginal.equals(fellowPlayerCompare)); }
@Test public void equalsTestSameInstance() { assert(fellowPlayerOriginal.equals(fellowPlayerOriginal)); }
@Test public void equalsTestWrongClass() { R... |
BotInformation implements Serializable { public synchronized String toString() { String vBotInformationString = "Bot " + getBotname() + "(" + getRcId() + "/" + getVtId() + ")\n"; vBotInformationString += "with Address: " + getBotIP().toString() + " Port: " + getBotPort(); vBotInformationString += getReconnect()?" (Reco... | @Test public void testGetAllGamevalueNamesAsAString() { String gvString = new String(); for ( BotInformation.GamevalueNames vGamevalueName : BotInformation.GamevalueNames.values() ) { gvString += vGamevalueName.toString() + " "; } assertThat(BotInformation.GamevalueNames.getAllGamevalueNamesAsAString()).isEqualTo(gvStr... |
FellowPlayer extends ReferencePoint { @Override void setPointName( ReferencePointName aPointName ) { super.setPointName( ReferencePointName.Player ); mId = IDCOUNTER++; } FellowPlayer(); FellowPlayer(int aId, String aNickname, Boolean aStatus, double aDistanceToPlayer, double aAngleToPlayer, double aOrientation); @Xml... | @Test public void setPointNameText() { FellowPlayer fellowPlayer = new FellowPlayer(); int IDCountBefore = FellowPlayer.IDCOUNTER ; fellowPlayer.setPointName(ReferencePointName.Ball); int IDCountAfter = FellowPlayer.IDCOUNTER; assert(IDCountBefore+1==IDCountAfter); } |
ReferencePoint { public void setXOfPoint( double aXValue ) { mX = aXValue; set( mX, mY, false ); } ReferencePoint( ); @Deprecated ReferencePoint( double aDistanceToPoint, double aAngleToPoint ); ReferencePoint( double aFirstValue, double aSecondValue, boolean aPolarcoordinates ); ReferencePoint( ReferencePoint aRefe... | @Test public void testSetXOfPoint() { ReferencePoint referencePoint = new ReferencePoint(); referencePoint.setXOfPoint(10); assertThat(referencePoint.getXOfPoint()).isCloseTo(10, Percentage.withPercentage(1)); } |
ReferencePoint { public void setYOfPoint( double aYValue ) { mY = aYValue; set( mX, mY, false ); } ReferencePoint( ); @Deprecated ReferencePoint( double aDistanceToPoint, double aAngleToPoint ); ReferencePoint( double aFirstValue, double aSecondValue, boolean aPolarcoordinates ); ReferencePoint( ReferencePoint aRefe... | @Test public void testSetYOfPoint() { ReferencePoint referencePoint = new ReferencePoint(); referencePoint.setYOfPoint(10); assertThat(referencePoint.getYOfPoint()).isCloseTo(10, Percentage.withPercentage(1)); } |
ReferencePoint { public ReferencePoint copy () { return new ReferencePoint( this ); } ReferencePoint( ); @Deprecated ReferencePoint( double aDistanceToPoint, double aAngleToPoint ); ReferencePoint( double aFirstValue, double aSecondValue, boolean aPolarcoordinates ); ReferencePoint( ReferencePoint aReferencePoint );... | @Test public void testCopy() { ReferencePoint referencePoint = new ReferencePoint(10,15,false); ReferencePoint copyOfReferencePoint = referencePoint.copy(); assertThat(copyOfReferencePoint).isNotNull(); assertThat(copyOfReferencePoint).isInstanceOf(ReferencePoint.class); assertThat(copyOfReferencePoint.getXOfPoint()).i... |
ReferencePoint { public ReferencePoint set ( ReferencePoint aReferencePoint ) { mDistanceToPoint = aReferencePoint.getDistanceToPoint(); mAngleToPoint = aReferencePoint.getAngleToPoint(); mX = aReferencePoint.getXOfPoint(); mY = aReferencePoint.getYOfPoint(); mPointName = ReferencePointName.NoFixedName; return this; } ... | @Test(expected = IllegalArgumentException.class) public void testSetWithPolarcoordinatesWithNegativeDistance() { ReferencePoint referencePoint = new ReferencePoint(); referencePoint.set(-5,25,true); }
@Test(expected = IllegalArgumentException.class) public void testSetWithPolarcoordinatesWithToSmallAngle() { ReferenceP... |
ReferencePoint { public ReferencePoint add( ReferencePoint aReferencePoint ) { mX += aReferencePoint.mX; mY += aReferencePoint.mY; return set( mX, mY, false ); } ReferencePoint( ); @Deprecated ReferencePoint( double aDistanceToPoint, double aAngleToPoint ); ReferencePoint( double aFirstValue, double aSecondValue, boo... | @Test public void testAdd() { ReferencePoint referencePoint = new ReferencePoint(50,20,false); ReferencePoint plusReferencePoint = new ReferencePoint(10,10, false); referencePoint.add(plusReferencePoint); assertThat(referencePoint.getXOfPoint()).isCloseTo(60,Percentage.withPercentage(1)); assertThat(referencePoint.getY... |
ReferencePoint { public ReferencePoint multiply( double scalar ) { mX *= scalar; mY *= scalar; return set( mX, mY, false ); } ReferencePoint( ); @Deprecated ReferencePoint( double aDistanceToPoint, double aAngleToPoint ); ReferencePoint( double aFirstValue, double aSecondValue, boolean aPolarcoordinates ); Reference... | @Test public void testMultiply() { ReferencePoint referencePoint = new ReferencePoint(50,20, false); referencePoint.multiply(2.0); assertThat(referencePoint.getXOfPoint()).isCloseTo(100, Percentage.withPercentage(1)); assertThat(referencePoint.getYOfPoint()).isCloseTo(40,Percentage.withPercentage(1)); } |
ReferencePoint { public boolean epsilonEquals ( ReferencePoint aReferencePoint, double aEpsilon ) { return aReferencePoint != null && (Math.abs(aReferencePoint.getXOfPoint() - mX) <= aEpsilon) && (Math.abs(aReferencePoint.getYOfPoint() - mY) <= aEpsilon); } ReferencePoint( ); @Deprecated ReferencePoint( double aDistan... | @Test public void testEpsilonEqualsReferencePointExactCorrect() { ReferencePoint referencePoint = new ReferencePoint(50,20,false); Boolean result = referencePoint.epsilonEquals(new ReferencePoint(50,20,false),0); assertThat(result).isEqualTo(true); }
@Test public void testEpsilonEqualsReferencePointNotExactCorrect() { ... |
Kick implements Action { @Override public String getXMLString() { return "<command> <kick> <angle>" + mAngle + "</angle> <force>" + mForce + "</force> </kick> </command>"; } Kick( double aAngle, float aForce); @Override String getXMLString(); double getAngle(); float getForce(); } | @Test public void getXMLString() throws Exception { Kick kick = new Kick(90.1, (float) 21.0); assertThat(kick.getXMLString()).isEqualTo("<command> <kick> <angle>90.1</angle> <force>21.0</force> </kick> </command>"); } |
ReferencePoint { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ReferencePoint other = (ReferencePoint) obj; if (Double.doubleToLongBits(mAngleToPoint) != Double.doubleToLongBits(other.mAngleToPoint)) return fals... | @Test public void testEqualsSameObject() { ReferencePoint referencePoint = new ReferencePoint(); Boolean result = referencePoint.equals(referencePoint); assertThat(result).isEqualTo(true); }
@Test public void testEqualsObjectIsNull() { ReferencePoint referencePoint = new ReferencePoint(); Boolean result = referencePoin... |
Movement implements Action { @Override public String getXMLString() { return "<command> <wheel_velocities> <right>" + mRightWheelVelocity + "</right> <left>" + mLeftWheelVelocity + "</left> </wheel_velocities> </command>"; } Movement( int aRightWheelVelocity, int aLeftWheelVelocity ); int getmRightWheelVelocity(); int ... | @Test public void testGetXMLString() { Movement movement = new Movement(51,50); assertThat(movement.getXMLString()).isEqualTo("<command> <wheel_velocities> <right>51</right> <left>50</left> </wheel_velocities> </command>"); } |
ReferencePoint { @Override public String toString() { return "ReferencePoint [mPointName=" + mPointName + ", mDistanceToPoint=" + mDistanceToPoint + ", mAngleToPoint=" + mAngleToPoint + ", mX=" + mX + ", mY=" + mY + "]"; } ReferencePoint( ); @Deprecated ReferencePoint( double aDistanceToPoint, double aAngleToPoint ); ... | @Test public void testToString() { ReferencePoint referencePoint = new ReferencePoint(); referencePoint.setPointName(ReferencePointName.NoFixedName); double distance = 1.41421356; double angle = 45.0; referencePoint.setDistanceToPoint(distance); referencePoint.setAngleToPoint(angle); double x = referencePoint.getDistan... |
ObjectFactory { public RawWorldData createRawWorldData() { return new RawWorldData(); } RawWorldData createRawWorldData(); } | @Test public void testCreateRawWorldData() { ObjectFactory objectFactory = new ObjectFactory(); assertThat(objectFactory.createRawWorldData()).isInstanceOf(RawWorldData.class); } |
InitialConnectionData implements Action { public InitialConnectionData( BotInformation aBot ){ mConnection.type = "Client"; mConnection.protocol_version = 1.0; mConnection.nickname = aBot.getBotname(); mConnection.rc_id = aBot.getRcId(); mConnection.vt_id = aBot.getVtId(); } InitialConnectionData( BotInformation aBot )... | @Test public void testInitialConnectionData() { fail("Not yet implemented"); } |
InitialConnectionData implements Action { @Override public String getXMLString() { StringWriter vXMLDataStream = new StringWriter(); JAXB.marshal( mConnection, vXMLDataStream ); String vXMLDataString = vXMLDataStream.toString(); vXMLDataString = vXMLDataString.substring( vXMLDataString.indexOf('>') + 2 ); return vXMLDa... | @Test public void testGetXMLString() { InitialConnectionData initialConnectionData = new InitialConnectionData(botInformationMock); fail("Not yet implemented"); } |
NetworkCommunication { public void sendDatagramm( String aData ) throws IOException { mDataPaket.setData( aData.getBytes() ); mToServerSocket.send( mDataPaket ); } NetworkCommunication( InetAddress aServerAddress, int aServerPort ); NetworkCommunication( InetAddress aServerAddress, int aServerPort, int aClientPort); v... | @Test public void testSendDatagramm() { } |
CommandLineOptions { static boolean parseCommandLineArguments( String[] aArguments ) { Core.getLogger().trace( "Parsing commandline." ); CommandLineOptions commandLineOptions = new CommandLineOptions(); try { CommandLine commandLine = new CommandLine(commandLineOptions) .registerConverter(BotInformation.Teams.class, ne... | @Test public void testParseCommandLineArgumentsWithNoExceptionsWithRemoteStart() { String[] args = {"-bn","3","-tn","Northern Stars","-t","blau","-ids","13","-s","localhost:3310","-aiarc","../mrbotkiexample/bin/exampleai/brain","-aicl","exampleai.brain.Striker","-aiarg","0","-rs"}; boolean result = CommandLineOptions.p... |
Movement implements Action { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + mLeftWheelVelocity; result = prime * result + mRightWheelVelocity; return result; } Movement( int aRightWheelVelocity, int aLeftWheelVelocity ); int getmRightWheelVelocity(); int getmLeftWheelV... | @Test public void testHashCode() { Movement movement = new Movement(51,50); assertThat(movement.hashCode()).isEqualTo(2562); } |
CommandLineOptions { private void setOptions() throws UnknownHostException { BotInformation botInformation = Core.getInstance().getBotinformation(); botInformation.setAIClassname(this.aiClassname); botInformation.setAIArchive(this.aiArchive); botInformation.setAIArgs(Arrays.toString(this.aiArguments)); botInformation.s... | @Test public void testSetOptions() { String[] args = {"-bn","3","-tn","Northern Stars","-t","blau","-ids","13","-s","localhost:3310","-aiarc","../mrbotkiexample/bin/exampleai/brain","-aicl","exampleai.brain.Striker","-aiarg","0"}; CommandLineOptions.parseCommandLineArguments(args); BotInformation botInformation = Core.... |
TeamConverter implements CommandLine.ITypeConverter<BotInformation.Teams> { @Override public BotInformation.Teams convert(String value) throws Exception { if (value == "gelb" || value == "yellow" || value == "g" || value == "y") return Yellow; else if (value == "blau" || value == "blue" || value == "b") return Blue; el... | @Test public void testConvertWithValueIsGelb() throws Exception { TeamConverter teamConverter = new TeamConverter(); BotInformation.Teams result = teamConverter.convert("gelb"); assertThat(result).isEqualTo(BotInformation.Teams.Yellow); }
@Test public void testConvertWithValueIsYellow() throws Exception { TeamConverter... |
Main { public static void main( String[] aCommandline ) { System.setProperty("Bot", ManagementFactory.getRuntimeMXBean().getName() + "" ); Core.getLogger().info("Starting Bot(" + ManagementFactory.getRuntimeMXBean().getName() + ")" ); StringBuilder vParameters = new StringBuilder(); for ( String vParameter: aCommandlin... | @Test public void mainWithEmptyCommandline() { String[] vEmptyCommandline = new String[0]; doNothing().when(mCoreMock).startBot(vEmptyCommandline); Main.main(vEmptyCommandline); assertThat(System.getProperty("Bot")).isEqualToIgnoringCase(ManagementFactory.getRuntimeMXBean().getName()); verify(mLoggerMock).info("Startin... |
Core { synchronized public BotInformation getBotinformation() { Core.getLogger().debug( "Retriving Botinformation: \n" + mBotinformation.toString() ); return mBotinformation; } Core(); Core( BotInformation aBotInformation ); static Core getInstance(); static synchronized Logger getLogger(); void close(); void startBo... | @Test public void testConstructorWithBotInformation() { mSUT = new Core(mBotInformationMock); assertThat(mSUT.getBotinformation()).isEqualTo(mBotInformationMock); } |
Core { public static Core getInstance() { if( Core.sINSTANCE == null){ Core.getLogger().trace( "Creating Core-instance." ); Core.sINSTANCE = new Core(); } Core.getLogger().trace( "Retrieving Core-instance." ); return Core.sINSTANCE; } Core(); Core( BotInformation aBotInformation ); static Core getInstance(); static s... | @Test public void testGetInstance() { mSUT = Core.getInstance(); assertThat(mSUT).isInstanceOf(Core.class); assertThat(mSUT).isEqualTo(Core.getInstance()); assertThat(mSUT.getBotinformation()).isEqualTo(Core.getInstance().getBotinformation()); } |
Core { public static synchronized Logger getLogger(){ return sBOTCORELOGGER; } Core(); Core( BotInformation aBotInformation ); static Core getInstance(); static synchronized Logger getLogger(); void close(); void startBot( String[] aCommandline ); @SuppressWarnings("resource") boolean initializeAI(); void disposeAI()... | @Test public void testGetLogger() { Logger vLoggerToTest = Core.getLogger(); assertThat(vLoggerToTest).isInstanceOf(Logger.class); assertThat(vLoggerToTest).isEqualTo(Core.getLogger()); } |
FromServerManagement extends Thread { public void startManagement(){ if( Core.getInstance().getServerConnection() == null ) { throw new NullPointerException( "NetworkCommunication cannot be NULL when starting FromServerManagement." ) ; } else if ( isAlive() ){ throw new IllegalThreadStateException( "FromServerManagemen... | @Test public void testStartManagementWithoutNetworkConnection() { when(mCoreMock.getServerConnection()).thenReturn( null ); try{ mSUT.startManagement(); fail("Expected Nullpointerexception"); } catch( Exception vExpectedException ) { assertThat(vExpectedException).isInstanceOf(NullPointerException.class); assertThat(vE... |
FromServerManagement extends Thread { @Override public void start(){ startManagement(); } FromServerManagement(); static FromServerManagement getInstance(); void close(); void resumeManagement(); void suspendManagement(); boolean isSuspended(); @Override void start(); void startManagement(); void stopManagement(); @Ove... | @Test public void testStartWithoutNetworkConnection() { when(mCoreMock.getServerConnection()).thenReturn( null ); try{ mSUT.start(); fail("Expected Nullpointerexception"); } catch( Exception vExpectedException ) { assertThat(vExpectedException).isInstanceOf(NullPointerException.class); assertThat(vExpectedException.get... |
FromServerManagement extends Thread { public static FromServerManagement getInstance() { if( FromServerManagement.sINSTANCE == null){ FromServerManagement.sINSTANCE = new FromServerManagement(); } return FromServerManagement.sINSTANCE; } FromServerManagement(); static FromServerManagement getInstance(); void close(); v... | @Test public void testGetInstance() { FromServerManagement vSaveToCompare = FromServerManagement.getInstance(); assertThat(vSaveToCompare).isInstanceOf(FromServerManagement.class); assertThat(vSaveToCompare).isEqualTo(FromServerManagement.getInstance()); } |
FromServerManagement extends Thread { public void stopManagement(){ synchronized (this) { mManageMessagesFromServer = false; } if( isAlive()){ mSuspended = false; while(isAlive()){ try { Thread.sleep( 10 ); } catch ( Exception vException ) { Core.getLogger().error( "Error stopping FromServerManagement.", vException ); ... | @Test public void testStopManagementWhenNotAlive() { assertThat(mSUT.isAlive()).isFalse(); mSUT.stopManagement(); assertThat(mSUT.isAlive()).isFalse(); verify(mLoggerMock, never()).info("FromServerManagement stopped."); } |
FromServerManagement extends Thread { public boolean isReceivingMessages(){ return isAlive() && (System.currentTimeMillis() - mLastReceivedMessage.get()) < 100; } FromServerManagement(); static FromServerManagement getInstance(); void close(); void resumeManagement(); void suspendManagement(); boolean isSuspended(); @O... | @Test public void testIsReceivingMessagesWhenNotAlive() { assertThat(mSUT.isAlive()).isFalse(); assertThat(mSUT.isReceivingMessages()).isFalse(); } |
ReloadAiManagement extends Thread { public void startManagement(){ if( !isAlive() ){ mAiActive = true; super.start(); Core.getLogger().info( "RestartAiServerManagement started." ); } } ReloadAiManagement(); static ReloadAiManagement getInstance(); void close(); @Override void start(); void startManagement(); void stopM... | @Test public void testStartManagementWhileNotAlive() { when(mCoreMock.getAI()).thenReturn( null ); assertThat(mSUT.isAlive()).isFalse(); mSUT.startManagement(); assertThat(mSUT.isAlive()).isTrue(); verify(mLoggerMock).info("RestartAiServerManagement started."); }
@Test public void testStartManagementWhileAlive() { when... |
ReloadAiManagement extends Thread { @Override public void start(){ startManagement(); } ReloadAiManagement(); static ReloadAiManagement getInstance(); void close(); @Override void start(); void startManagement(); void stopManagement(); @Override void run(); } | @Test public void testStartWhileNotAlive() { when(mCoreMock.getAI()).thenReturn( null ); assertThat(mSUT.isAlive()).isFalse(); mSUT.start(); assertThat(mSUT.isAlive()).isTrue(); verify(mLoggerMock).info("RestartAiServerManagement started."); }
@Test public void testStartWhileAlive() { when(mCoreMock.getAI()).thenReturn... |
ReloadAiManagement extends Thread { public static ReloadAiManagement getInstance() { if( ReloadAiManagement.sINSTANCE == null){ ReloadAiManagement.sINSTANCE = new ReloadAiManagement(); } return ReloadAiManagement.sINSTANCE; } ReloadAiManagement(); static ReloadAiManagement getInstance(); void close(); @Override void st... | @Test public void testGetInstance() { ReloadAiManagement vSaveToCompare = ReloadAiManagement.getInstance(); assertThat(vSaveToCompare).isInstanceOf(ReloadAiManagement.class); assertThat(vSaveToCompare).isEqualTo(ReloadAiManagement.getInstance()); } |
ReloadAiManagement extends Thread { public void stopManagement(){ mAiActive = false; if( isAlive()){ Core.getLogger().info( "RestartAiServerManagement stopping." ); while(isAlive()){ try { Thread.sleep( 10 ); } catch ( Exception vException ) { Core.getLogger().error( "Error stopping RestartAiServerManagement.", vExcept... | @Test public void testStopManagementWhenNotAlive() { when(mCoreMock.getAI()).thenReturn( null ); assertThat(mSUT.isAlive()).isFalse(); mSUT.stopManagement(); assertThat(mSUT.isAlive()).isFalse(); verify(mLoggerMock, never()).info("RestartAiServerManagement stopped."); } |
ReloadAiManagement extends Thread { @Override public void run(){ while( mAiActive ){ try { if(Core.getInstance().getAI() != null && Core.getInstance().getAI().wantRestart()){ Core.getInstance().initializeAI(); Core.getInstance().resumeAI(); Thread.sleep( 500 ); } Thread.sleep( 50 ); } catch ( Exception vException ) { C... | @Test public void testRunWithoutStart() throws Exception { when(mCoreMock.getAI()).thenReturn( mArtificialIntelligenceMock ); assertThat(mSUT.isAlive()).isFalse(); mSUT.run(); assertThat(mSUT.isAlive()).isFalse(); verifyZeroInteractions(mArtificialIntelligenceMock); } |
ToServerManagement extends Thread { @Override public void start(){ this.startManagement(); } ToServerManagement(); static ToServerManagement getInstance(); void close(); void resumeManagement(); boolean isSuspended(); void suspendManagement(); @Override void start(); void startManagement(); void stopManagement(); @Over... | @Test public void testStartWithoutNetworkConnection() { when(mCoreMock.getServerConnection()).thenReturn( null ); try{ mSUT.start(); fail("Expected Nullpointerexception"); } catch( Exception vExpectedException ) { assertThat(vExpectedException).isInstanceOf(NullPointerException.class); assertThat(vExpectedException.get... |
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("html", "text/html;charset=utf-8"); mappings.add("json", "text/html;char... | @Test public void testUndertowHttp2Enabled() { props.getHttp().setVersion(JHipsterProperties.Http.Version.V_2_0); UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory(); webConfigurer.customize(container); Builder builder = Undertow.builder(); container.getBuilderCustomizers()... |
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Bean public CorsFilter corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = jHipsterProperties.getCors(); if (config.getAllowedOrigins() != null && !config.getAl... | @Test public void testCorsFilterOnApiPath() throws Exception { props.getCors().setAllowedOrigins(Collections.singletonList("*")); props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE")); props.getCors().setAllowedHeaders(Collections.singletonList("*")); props.getCors().setMaxAge(1800L); props.g... |
ProfileInfoResource { @GetMapping("/profile-info") public ProfileInfoVM getActiveProfiles() { String[] activeProfiles = DefaultProfileUtil.getActiveProfiles(env); return new ProfileInfoVM(activeProfiles, getRibbonEnv(activeProfiles)); } ProfileInfoResource(Environment env, JHipsterProperties jHipsterProperties); @GetMa... | @Test public void getActiveProfilesTest() throws Exception { MvcResult res = mock.perform(get("/api/profile-info") .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andReturn(); assertTrue(res.getResponse().getContentAsString().contains(... |
TokenProvider { public boolean validateToken(String authToken) { try { Jwts.parser().setSigningKey(secretKey).parseClaimsJws(authToken); return true; } catch (SignatureException e) { log.info("Invalid JWT signature."); log.trace("Invalid JWT signature trace: {}", e); } catch (MalformedJwtException e) { log.info("Invali... | @Test public void testReturnFalseWhenJWTisUnsupported() { String unsupportedToken = createUnsupportedToken(); boolean isTokenValid = tokenProvider.validateToken(unsupportedToken); assertThat(isTokenValid).isEqualTo(false); } |
LogsResource { @GetMapping("/logs") @Timed public List<LoggerVM> getList() { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); return context.getLoggerList() .stream() .map(LoggerVM::new) .collect(Collectors.toList()); } @GetMapping("/logs") @Timed List<LoggerVM> getList(); @PutMapping("/logs"... | @Test public void getListTest() throws Exception { mock.perform(get("/management/logs") .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)); } |
LogsResource { @PutMapping("/logs") @ResponseStatus(HttpStatus.NO_CONTENT) @Timed public void changeLevel(@RequestBody LoggerVM jsonLogger) { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel())); } @GetMapping(... | @Test public void changeLevelTest() throws Exception { LoggerVM logger = new LoggerVM(); logger.setLevel("ERROR"); logger.setName("ROOT"); mock.perform(put("/management/logs") .contentType(MediaType.APPLICATION_JSON_UTF8) .content(new ObjectMapper().writeValueAsString(logger))) .andExpect(status().isNoContent()); MvcRe... |
SshResource { @GetMapping(value = "/ssh/public_key", produces = MediaType.TEXT_PLAIN_VALUE) @Timed public ResponseEntity<String> eureka() { try { String publicKey = getPublicKey(); if(publicKey != null) return new ResponseEntity<>(publicKey, HttpStatus.OK); } catch (IOException e) { log.warn("SSH public key could not b... | @Test public void eurekaTest() throws Exception { Mockito.doReturn(null).when(ssh).getPublicKey(); mock.perform(get("/api/ssh/public_key")) .andExpect(status().isNotFound()); Mockito.doReturn("key").when(ssh).getPublicKey(); mock.perform(get("/api/ssh/public_key")) .andExpect(content().contentTypeCompatibleWith(MediaTy... |
UserJWTController { @PostMapping("/authenticate") @Timed public ResponseEntity authorize(@Valid @RequestBody LoginVM loginVM, HttpServletResponse response) { UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginVM.getUsername(), loginVM.getPassword()); try { Authenticat... | @Test public void authorizeTest() throws Exception { LoginVM vm = new LoginVM(); vm.setUsername("admin"); vm.setPassword("admin"); vm.setRememberMe(true); Mockito.doReturn("fakeToken").when(tokenProvider) .createToken(Mockito.any(Authentication.class), Mockito.anyBoolean()); mock.perform(post("/api/authenticate") .cont... |
ExceptionTranslator { @ExceptionHandler(MethodArgumentNotValidException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody public ErrorVM processValidationError(MethodArgumentNotValidException ex) { BindingResult result = ex.getBindingResult(); List<FieldError> fieldErrors = result.getFieldErrors(); ErrorVM d... | @Test public void processValidationErrorTest() throws Exception { UserJWTController control = new UserJWTController(null, null); MockMvc jwtMock = MockMvcBuilders.standaloneSetup(control) .setControllerAdvice(new ExceptionTranslator()) .build(); MvcResult res = jwtMock.perform(post("/api/authenticate") .contentType(Med... |
ExceptionTranslator { @ExceptionHandler(CustomParameterizedException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody public ParameterizedErrorVM processParameterizedValidationError(CustomParameterizedException ex) { return ex.getErrorVM(); } @ExceptionHandler(MethodArgumentNotValidException.class) @Respon... | @Test public void processParameterizedValidationErrorTest() throws Exception { SecurityContext securityContext = Mockito.mock(SecurityContext.class); Mockito.when(securityContext.getAuthentication()).thenThrow(new CustomParameterizedException(null)); SecurityContextHolder.setContext(securityContext); MvcResult res = mo... |
ExceptionTranslator { @ExceptionHandler(AccessDeniedException.class) @ResponseStatus(HttpStatus.FORBIDDEN) @ResponseBody public ErrorVM processAccessDeniedException(AccessDeniedException e) { return new ErrorVM(ErrorConstants.ERR_ACCESS_DENIED, e.getMessage()); } @ExceptionHandler(MethodArgumentNotValidException.class... | @Test public void processAccessDeniedExceptionTest() throws Exception { SecurityContext securityContext = Mockito.mock(SecurityContext.class); Mockito.when(securityContext.getAuthentication()).thenThrow(new AccessDeniedException(null)); SecurityContextHolder.setContext(securityContext); MvcResult res = mock.perform(get... |
ExceptionTranslator { @ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ResponseBody @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) public ErrorVM processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) { return new ErrorVM(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, exception.g... | @Test public void processMethodNotSupportedExceptionTest() throws Exception { MvcResult res = mock.perform(post("/api/account") .content("{\"testFakeParam\"}")) .andExpect(status().isMethodNotAllowed()) .andReturn(); assertThat(res.getResolvedException(), instanceOf(HttpRequestMethodNotSupportedException.class)); } |
ExceptionTranslator { @ExceptionHandler(Exception.class) public ResponseEntity<ErrorVM> processRuntimeException(Exception ex) { BodyBuilder builder; ErrorVM errorVM; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder = ResponseEntit... | @Test public void processRuntimeExceptionTest() throws Exception { SecurityContext securityContext = Mockito.mock(SecurityContext.class); Mockito.when(securityContext.getAuthentication()).thenThrow(new RuntimeException()); SecurityContextHolder.setContext(securityContext); MvcResult res = mock.perform(get("/api/account... |
CustomParameterizedException extends RuntimeException { public ParameterizedErrorVM getErrorVM() { return new ParameterizedErrorVM(message, paramMap); } CustomParameterizedException(String message, String... params); CustomParameterizedException(String message, Map<String, String> paramMap); ParameterizedErrorVM getEr... | @Test public void getErrorVMTest() throws Exception { CustomParameterizedException exc = new CustomParameterizedException("Test"); try { throw exc; } catch ( Exception exception ) { assertTrue(exception instanceof CustomParameterizedException); CustomParameterizedException exceptionCast = (CustomParameterizedException)... |
FieldErrorVM implements Serializable { public String getObjectName() { return objectName; } FieldErrorVM(String dto, String field, String message); String getObjectName(); String getField(); String getMessage(); } | @Test public void getObjectNameTest() throws Exception { FieldErrorVM vm = new FieldErrorVM(null, null, null); assertNull(vm.getObjectName()); vm = new FieldErrorVM("dto", "field", "message"); assertEquals("dto", vm.getObjectName()); } |
FieldErrorVM implements Serializable { public String getField() { return field; } FieldErrorVM(String dto, String field, String message); String getObjectName(); String getField(); String getMessage(); } | @Test public void getFieldTest() throws Exception { FieldErrorVM vm = new FieldErrorVM(null, null, null); assertNull(vm.getField()); vm = new FieldErrorVM("dto", "field", "message"); assertEquals("field", vm.getField()); } |
FieldErrorVM implements Serializable { public String getMessage() { return message; } FieldErrorVM(String dto, String field, String message); String getObjectName(); String getField(); String getMessage(); } | @Test public void getMessageTest() throws Exception { FieldErrorVM vm = new FieldErrorVM(null, null, null); assertNull(vm.getMessage()); vm = new FieldErrorVM("dto", "field", "message"); assertEquals("message", vm.getMessage()); } |
ErrorVM implements Serializable { public void add(String objectName, String field, String message) { if (fieldErrors == null) { fieldErrors = new ArrayList<>(); } fieldErrors.add(new FieldErrorVM(objectName, field, message)); } ErrorVM(String message); ErrorVM(String message, String description); ErrorVM(String messa... | @Test public void addTest() throws Exception { assertNull(vm1.getFieldErrors()); assertNull(vm2.getFieldErrors()); assertNotNull(vm3.getFieldErrors()); assertNull(vm1null.getFieldErrors()); assertNull(vm2null.getFieldErrors()); assertNull(vm3null.getFieldErrors()); vm1.add("testObjectName", "testField", "testMsg"); vm2... |
ErrorVM implements Serializable { public String getMessage() { return message; } ErrorVM(String message); ErrorVM(String message, String description); ErrorVM(String message, String description, List<FieldErrorVM> fieldErrors); void add(String objectName, String field, String message); String getMessage(); String get... | @Test public void getMessageTest() throws Exception { assertEquals(message, vm1.getMessage()); assertEquals(message, vm2.getMessage()); assertEquals(message, vm3.getMessage()); assertNull(vm1null.getMessage()); assertNull(vm2null.getMessage()); assertNull(vm3null.getMessage()); } |
ErrorVM implements Serializable { public String getDescription() { return description; } ErrorVM(String message); ErrorVM(String message, String description); ErrorVM(String message, String description, List<FieldErrorVM> fieldErrors); void add(String objectName, String field, String message); String getMessage(); St... | @Test public void getDescriptionTest() throws Exception { assertNull(vm1.getDescription()); assertEquals(description, vm2.getDescription()); assertEquals(description, vm3.getDescription()); assertNull(vm1null.getDescription()); assertNull(vm2null.getDescription()); assertNull(vm3null.getDescription()); } |
ErrorVM implements Serializable { public List<FieldErrorVM> getFieldErrors() { return fieldErrors; } ErrorVM(String message); ErrorVM(String message, String description); ErrorVM(String message, String description, List<FieldErrorVM> fieldErrors); void add(String objectName, String field, String message); String getM... | @Test public void getFieldErrorsTest() throws Exception { assertNull(vm1.getFieldErrors()); assertNull(vm2.getFieldErrors()); assertNotNull(vm3.getFieldErrors()); assertNull(vm1null.getFieldErrors()); assertNull(vm2null.getFieldErrors()); assertNull(vm3null.getFieldErrors()); vm1.add(null, null, null); vm2.add(null, nu... |
ParameterizedErrorVM implements Serializable { public String getMessage() { return message; } ParameterizedErrorVM(String message, Map<String, String> paramMap); String getMessage(); Map<String, String> getParams(); } | @Test public void getMessageTest() { ParameterizedErrorVM vm = new ParameterizedErrorVM(null, null); assertNull(vm.getMessage()); Map<String, String> paramMap = new HashMap<>(); paramMap.put("param1", "param1"); paramMap.put("param2", "param2"); vm = new ParameterizedErrorVM("message", paramMap); assertEquals("message"... |
ParameterizedErrorVM implements Serializable { public Map<String, String> getParams() { return paramMap; } ParameterizedErrorVM(String message, Map<String, String> paramMap); String getMessage(); Map<String, String> getParams(); } | @Test public void getParamsTest() { ParameterizedErrorVM vm = new ParameterizedErrorVM(null, null); assertNull(vm.getMessage()); Map<String, String> paramMap = new HashMap<>(); paramMap.put("param1", "param1"); paramMap.put("param2", "param2"); vm = new ParameterizedErrorVM("message", paramMap); assertTrue(vm.getParams... |
EurekaVM { public List<Map<String, Object>> getApplications() { return applications; } List<Map<String, Object>> getApplications(); void setApplications(List<Map<String, Object>> applications); Map<String, Object> getStatus(); void setStatus(Map<String, Object> status); } | @Test public void getApplicationsTest() throws Exception { List<Map<String, Object>> list = eureka.getApplications(); assertNull(list); eureka.setApplications(initFakeApplicationsList()); list = eureka.getApplications(); assertNotNull(list); assertTrue(list.size()==2); } |
EurekaVM { public void setApplications(List<Map<String, Object>> applications) { this.applications = applications; } List<Map<String, Object>> getApplications(); void setApplications(List<Map<String, Object>> applications); Map<String, Object> getStatus(); void setStatus(Map<String, Object> status); } | @Test public void setApplicationsTest() throws Exception { assertNull(eureka.getApplications()); eureka.setApplications(initFakeApplicationsList()); assertNotNull(eureka.getApplications()); List<Map<String, Object>> newList = new ArrayList<>(); eureka.setApplications(newList); assertEquals(newList, eureka.getApplicatio... |
EurekaVM { public Map<String, Object> getStatus() { return status; } List<Map<String, Object>> getApplications(); void setApplications(List<Map<String, Object>> applications); Map<String, Object> getStatus(); void setStatus(Map<String, Object> status); } | @Test public void getStatusTest() throws Exception { Map<String, Object> status = eureka.getStatus(); assertNull(status); eureka.setStatus(initFakeStatus()); status = eureka.getStatus(); assertNotNull(status); assertTrue(status.size()==3); } |
EurekaVM { public void setStatus(Map<String, Object> status) { this.status = status; } List<Map<String, Object>> getApplications(); void setApplications(List<Map<String, Object>> applications); Map<String, Object> getStatus(); void setStatus(Map<String, Object> status); } | @Test public void setStatusTest() throws Exception { assertNull(eureka.getStatus()); eureka.setStatus(initFakeStatus()); assertNotNull(eureka.getStatus()); Map<String, Object> newStatus = new HashMap<>(); eureka.setStatus(newStatus); assertEquals(newStatus, eureka.getStatus()); } |
LoggerVM { public String getName() { return name; } LoggerVM(Logger logger); @JsonCreator LoggerVM(); String getName(); void setName(String name); String getLevel(); void setLevel(String level); @Override String toString(); } | @Test public void getNameTest() throws Exception { LoggerVM vm = new LoggerVM(); assertNull(vm.getName()); Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); vm = new LoggerVM(logger); assertEquals(Logger.ROOT_LOGGER_NAME, vm.getName()); } |
LoggerVM { public void setName(String name) { this.name = name; } LoggerVM(Logger logger); @JsonCreator LoggerVM(); String getName(); void setName(String name); String getLevel(); void setLevel(String level); @Override String toString(); } | @Test public void setNameTest() throws Exception { LoggerVM vm = new LoggerVM(); vm.setName(null); assertNull(vm.getName()); vm = new LoggerVM(); vm.setName("fakeName"); assertEquals("fakeName", vm.getName()); Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); vm = new LoggerVM(logger); vm.setNa... |
LoggerVM { public String getLevel() { return level; } LoggerVM(Logger logger); @JsonCreator LoggerVM(); String getName(); void setName(String name); String getLevel(); void setLevel(String level); @Override String toString(); } | @Test public void getLevelTest() throws Exception { LoggerVM vm = new LoggerVM(); assertNull(vm.getLevel()); Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); vm = new LoggerVM(logger); assertEquals(Level.ERROR.toString(), vm.getLevel()); } |
LoggerVM { public void setLevel(String level) { this.level = level; } LoggerVM(Logger logger); @JsonCreator LoggerVM(); String getName(); void setName(String name); String getLevel(); void setLevel(String level); @Override String toString(); } | @Test public void setLevelTest() throws Exception { LoggerVM vm = new LoggerVM(); vm.setLevel(null); assertNull(vm.getLevel()); vm = new LoggerVM(); vm.setLevel("fakeLevel"); assertEquals("fakeLevel", vm.getLevel()); Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); vm = new LoggerVM(logger); v... |
LoggerVM { @Override public String toString() { return "LoggerVM{" + "name='" + name + '\'' + ", level='" + level + '\'' + '}'; } LoggerVM(Logger logger); @JsonCreator LoggerVM(); String getName(); void setName(String name); String getLevel(); void setLevel(String level); @Override String toString(); } | @Test public void toStringTestTest() throws Exception { Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); LoggerVM vm = new LoggerVM(logger); assertTrue(vm.toString().startsWith(LoggerVM.class.getSimpleName())); String json = vm.toString().replace(LoggerVM.class.getSimpleName(), ""); assertTrue... |
LoginVM { public String getUsername() { return username; } String getUsername(); void setUsername(String username); String getPassword(); void setPassword(String password); Boolean isRememberMe(); void setRememberMe(Boolean rememberMe); @Override String toString(); } | @Test public void getUsernameTest(){ LoginVM vm = new LoginVM(); assertNull(vm.getUsername()); vm.setUsername("fakeUsername"); assertEquals("fakeUsername", vm.getUsername()); } |
LoginVM { public void setUsername(String username) { this.username = username; } String getUsername(); void setUsername(String username); String getPassword(); void setPassword(String password); Boolean isRememberMe(); void setRememberMe(Boolean rememberMe); @Override String toString(); } | @Test public void setUsernameTest(){ LoginVM vm = new LoginVM(); assertNull(vm.getUsername()); vm.setUsername(null); assertNull(vm.getUsername()); vm.setUsername("fakeUsername"); assertEquals("fakeUsername", vm.getUsername()); vm = new LoginVM(); vm.setPassword("goodPassword"); assertFalse(validator.validate(vm).isEmpt... |
LoginVM { public String getPassword() { return password; } String getUsername(); void setUsername(String username); String getPassword(); void setPassword(String password); Boolean isRememberMe(); void setRememberMe(Boolean rememberMe); @Override String toString(); } | @Test public void getPasswordTest(){ LoginVM vm = new LoginVM(); assertNull(vm.getPassword()); vm.setPassword("fakePassword"); assertEquals("fakePassword", vm.getPassword()); } |
LoginVM { public void setPassword(String password) { this.password = password; } String getUsername(); void setUsername(String username); String getPassword(); void setPassword(String password); Boolean isRememberMe(); void setRememberMe(Boolean rememberMe); @Override String toString(); } | @Test public void setPasswordTest(){ LoginVM vm = new LoginVM(); assertNull(vm.getPassword()); vm.setPassword(null); assertNull(vm.getPassword()); vm.setPassword("fakePassword"); assertEquals("fakePassword", vm.getPassword()); vm = new LoginVM(); vm.setUsername("goodUsername"); vm.setPassword("goodPassword"); assertTru... |
LoginVM { public Boolean isRememberMe() { return rememberMe; } String getUsername(); void setUsername(String username); String getPassword(); void setPassword(String password); Boolean isRememberMe(); void setRememberMe(Boolean rememberMe); @Override String toString(); } | @Test public void isRememberMeTest(){ LoginVM vm = new LoginVM(); assertNull(vm.isRememberMe()); vm.setRememberMe(true); assertTrue(vm.isRememberMe()); } |
LoginVM { public void setRememberMe(Boolean rememberMe) { this.rememberMe = rememberMe; } String getUsername(); void setUsername(String username); String getPassword(); void setPassword(String password); Boolean isRememberMe(); void setRememberMe(Boolean rememberMe); @Override String toString(); } | @Test public void setRememberMeTest(){ LoginVM vm = new LoginVM(); assertNull(vm.isRememberMe()); vm.setRememberMe(null); assertNull(vm.isRememberMe()); vm.setRememberMe(true); assertTrue(vm.isRememberMe()); } |
LoginVM { @Override public String toString() { return "LoginVM{" + "username='" + username + '\'' + ", rememberMe=" + rememberMe + '}'; } String getUsername(); void setUsername(String username); String getPassword(); void setPassword(String password); Boolean isRememberMe(); void setRememberMe(Boolean rememberMe); @Ov... | @Test public void toStringTest(){ LoginVM vm = new LoginVM(); assertTrue(vm.toString().startsWith(LoginVM.class.getSimpleName())); String json = vm.toString().replace(LoginVM.class.getSimpleName(), ""); assertTrue(TestUtils.isValid(json)); vm = new LoginVM(); vm.setUsername("fakeUsername"); vm.setPassword("fakePassword... |
UserVM { public String getLogin() { return login; } UserVM(); UserVM(String login, Set<String> authorities); String getLogin(); Set<String> getAuthorities(); @Override String toString(); } | @Test public void getLoginTest() { UserVM vm = new UserVM(); assertNull(vm.getLogin()); vm = new UserVM("login", null); assertEquals("login", vm.getLogin()); } |
UserVM { public Set<String> getAuthorities() { return authorities; } UserVM(); UserVM(String login, Set<String> authorities); String getLogin(); Set<String> getAuthorities(); @Override String toString(); } | @Test public void getAuthoritiesTest() throws Exception { UserVM vm = new UserVM(); assertNull(vm.getAuthorities()); Set<String> set = new HashSet<>(); set.add("authorities1"); set.add("authorities2"); vm = new UserVM("login", set); assertEquals(set, vm.getAuthorities()); } |
UserVM { @Override public String toString() { return "UserVM{" + "login='" + login + '\'' + ", authorities=" + authorities + "}"; } UserVM(); UserVM(String login, Set<String> authorities); String getLogin(); Set<String> getAuthorities(); @Override String toString(); } | @Test public void toStringTest() throws Exception { UserVM vm = new UserVM(); assertTrue(vm.toString().startsWith(UserVM.class.getSimpleName())); String json = vm.toString().replace(UserVM.class.getSimpleName(), ""); assertTrue(TestUtils.isValid(json)); Set<String> set = new HashSet<>(); set.add("authorities1"); set.ad... |
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); ... | @Test public void testStartUpProdServletContext() throws ServletException { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); webConfigurer.onStartup(servletContext); assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry); assertThat(servletContext.get... |
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("html", "text/html;charset=utf-8"); mappings.add("json", "text/html;char... | @Test public void testCustomizeServletContainer() { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory(); webConfigurer.customize(container); assertThat(container.getMimeMappings().get("abs")).isEqualTo("aud... |
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Bean public CorsFilter corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = jHipsterProperties.getCors(); if (config.getAllowedOrigins() != null && !config.getAl... | @Test public void testCorsFilterOnApiPath() throws Exception { props.getCors().setAllowedOrigins(Collections.singletonList("*")); props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE")); props.getCors().setAllowedHeaders(Collections.singletonList("*")); props.getCors().setMaxAge(1800L); props.g... |
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); ... | @Test public void testStartUpProdServletContext() throws ServletException { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); webConfigurer.onStartup(servletContext); assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry); assertThat(servletContext.get... |
SnapshotCreationService { public void createSnapshotEvents(final String eventType, String filter) { final SnapshotEventGenerator snapshotEventGenerator = snapshotEventProviders.get(eventType); if (snapshotEventGenerator == null) { throw new UnknownEventTypeException(eventType); } Object lastProcessedId = null; do { fin... | @Test public void testCreateSnapshotEvents() { final String filter = "exampleFilter"; when(snapshotEventGenerator.generateSnapshots(null, filter)).thenReturn( singletonList(new Snapshot(1, PUBLISHER_DATA_TYPE, eventPayload))); snapshotCreationService.createSnapshotEvents(PUBLISHER_EVENT_TYPE, filter); verify(eventLogWr... |
MockNakadiPublishingClient implements NakadiPublishingClient { public synchronized List<String> getSentEvents(String eventType) { ArrayList<String> events = new ArrayList<>(); List<String> sentEvents = this.sentEvents.get(eventType); if (sentEvents != null) { events.addAll(sentEvents); } return events; } MockNakadiPubl... | @Test public void returnsEmptyResultIfNoEventsHaveBeenSent() { assertThat(mockNakadiPublishingClient.getSentEvents("myEventType"), is(empty())); } |
EventBatcher { public void finish() { if (!batch.isEmpty()) { this.publisher.accept(batch); } } EventBatcher(ObjectMapper objectMapper, Consumer<List<BatchItem>> publisher); void pushEvent(EventLog eventLogEntry, NakadiEvent nakadiEvent); void finish(); } | @Test public void shouldNotPublishEmptyBatches() { eventBatcher.finish(); verify(publisher, never()).accept(any()); } |
EventBatcher { public void pushEvent(EventLog eventLogEntry, NakadiEvent nakadiEvent) { long eventSize; try { eventSize = objectMapper.writeValueAsBytes(nakadiEvent).length; } catch (Exception e) { log.error("Could not serialize event {} of type {}, skipping it.", eventLogEntry.getId(), eventLogEntry.getEventType(), e)... | @Test public void shouldPublishNonFilledBatchOnEventTypeChange() throws JsonProcessingException { EventLog eventLogEntry1 = eventLogEntry(1, "type1"); EventLog eventLogEntry2 = eventLogEntry(2, "type2"); NakadiEvent nakadiEvent1 = nakadiEvent("1"); NakadiEvent nakadiEvent2 = nakadiEvent("2"); when(objectMapper.writeVal... |
TracerFlowIdComponent implements FlowIdComponent { @Override public void startTraceIfNoneExists() { if (tracer != null) { try { tracer.get(X_FLOW_ID).getValue(); } catch (IllegalArgumentException e) { log.warn("No trace was configured for the name {}. Returning null. " + "To configure Tracer provide an application prop... | @Test public void makeSureTraceWillBeStartedIfNoneHasBeenStartedBefore() { TracerFlowIdComponent flowIdComponent = new TracerFlowIdComponent(tracer); when(tracer.get("X-Flow-ID").getValue()).thenThrow(new IllegalStateException()); flowIdComponent.startTraceIfNoneExists(); verify(tracer).start(); }
@Test public void won... |
BlueOceanApi { public void deletePipelineQueueItem(String organization, String pipeline, String queue) throws ApiException { deletePipelineQueueItemWithHttpInfo(organization, pipeline, queue); } BlueOceanApi(); BlueOceanApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); com.squ... | @Test public void deletePipelineQueueItemTest() throws ApiException { String organization = null; String pipeline = null; String queue = null; api.deletePipelineQueueItem(organization, pipeline, queue); } |
BlueOceanApi { public PipelineRun getPipelineBranchRun(String organization, String pipeline, String branch, String run) throws ApiException { ApiResponse<PipelineRun> resp = getPipelineBranchRunWithHttpInfo(organization, pipeline, branch, run); return resp.getData(); } BlueOceanApi(); BlueOceanApi(ApiClient apiClient)... | @Test public void getPipelineBranchRunTest() throws ApiException { String organization = null; String pipeline = null; String branch = null; String run = null; PipelineRun response = api.getPipelineBranchRun(organization, pipeline, branch, run); } |
BlueOceanApi { public MultibranchPipeline getPipelineBranches(String organization, String pipeline) throws ApiException { ApiResponse<MultibranchPipeline> resp = getPipelineBranchesWithHttpInfo(organization, pipeline); return resp.getData(); } BlueOceanApi(); BlueOceanApi(ApiClient apiClient); ApiClient getApiClient()... | @Test public void getPipelineBranchesTest() throws ApiException { String organization = null; String pipeline = null; MultibranchPipeline response = api.getPipelineBranches(organization, pipeline); } |
BlueOceanApi { public PipelineFolderImpl getPipelineFolder(String organization, String folder) throws ApiException { ApiResponse<PipelineFolderImpl> resp = getPipelineFolderWithHttpInfo(organization, folder); return resp.getData(); } BlueOceanApi(); BlueOceanApi(ApiClient apiClient); ApiClient getApiClient(); void set... | @Test public void getPipelineFolderTest() throws ApiException { String organization = null; String folder = null; PipelineFolderImpl response = api.getPipelineFolder(organization, folder); } |
BlueOceanApi { public PipelineImpl getPipelineFolderPipeline(String organization, String pipeline, String folder) throws ApiException { ApiResponse<PipelineImpl> resp = getPipelineFolderPipelineWithHttpInfo(organization, pipeline, folder); return resp.getData(); } BlueOceanApi(); BlueOceanApi(ApiClient apiClient); Api... | @Test public void getPipelineFolderPipelineTest() throws ApiException { String organization = null; String pipeline = null; String folder = null; PipelineImpl response = api.getPipelineFolderPipeline(organization, pipeline, folder); } |
BlueOceanApi { public PipelineQueue getPipelineQueue(String organization, String pipeline) throws ApiException { ApiResponse<PipelineQueue> resp = getPipelineQueueWithHttpInfo(organization, pipeline); return resp.getData(); } BlueOceanApi(); BlueOceanApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClien... | @Test public void getPipelineQueueTest() throws ApiException { String organization = null; String pipeline = null; PipelineQueue response = api.getPipelineQueue(organization, pipeline); } |
BlueOceanApi { public PipelineRun getPipelineRun(String organization, String pipeline, String run) throws ApiException { ApiResponse<PipelineRun> resp = getPipelineRunWithHttpInfo(organization, pipeline, run); return resp.getData(); } BlueOceanApi(); BlueOceanApi(ApiClient apiClient); ApiClient getApiClient(); void se... | @Test public void getPipelineRunTest() throws ApiException { String organization = null; String pipeline = null; String run = null; PipelineRun response = api.getPipelineRun(organization, pipeline, run); } |
BlueOceanApi { public String getPipelineRunLog(String organization, String pipeline, String run, Integer start, Boolean download) throws ApiException { ApiResponse<String> resp = getPipelineRunLogWithHttpInfo(organization, pipeline, run, start, download); return resp.getData(); } BlueOceanApi(); BlueOceanApi(ApiClient... | @Test public void getPipelineRunLogTest() throws ApiException { String organization = null; String pipeline = null; String run = null; Integer start = null; Boolean download = null; String response = api.getPipelineRunLog(organization, pipeline, run, start, download); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.