Skip to content

Commit

Permalink
Add more tests to improve coverage
Browse files Browse the repository at this point in the history
Sonar reports error due coverage check failing.

The coverage went off related to this change:
bfbca8a
  • Loading branch information
cstamas committed May 8, 2024
1 parent 269a0ca commit c8f5129
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ protected void configure()
void testBaseLifecycle()
{
assertEquals( "a", injector.getInstance( org.eclipse.sisu.bean.alpha.Public.class ).results() );
assertEquals( "a", injector.getInstance( org.eclipse.sisu.bean.alpha.SisuPublic.class ).results() );
assertEquals( "ab", injector.getInstance( org.eclipse.sisu.bean.alpha.Protected.class ).results() );
assertEquals( "abc", injector.getInstance( org.eclipse.sisu.bean.alpha.Package.class ).results() );
assertEquals( "abcd", injector.getInstance( org.eclipse.sisu.bean.alpha.Private.class ).results() );

injector.getInstance( BeanManager.class ).unmanage();

assertEquals( "az", injector.getInstance( org.eclipse.sisu.bean.alpha.Public.class ).results() );
assertEquals( "az", injector.getInstance( org.eclipse.sisu.bean.alpha.SisuPublic.class ).results() );
assertEquals( "abyz", injector.getInstance( org.eclipse.sisu.bean.alpha.Protected.class ).results() );
assertEquals( "abcxyz", injector.getInstance( org.eclipse.sisu.bean.alpha.Package.class ).results() );
assertEquals( "abcdwxyz", injector.getInstance( org.eclipse.sisu.bean.alpha.Private.class ).results() );
Expand All @@ -55,6 +57,7 @@ void testBaseLifecycle()
void testOverriddenLifecycle()
{
assertEquals( "bcdA", injector.getInstance( org.eclipse.sisu.bean.alpha.OverriddenPublic.class ).results() );
assertEquals( "bcdA", injector.getInstance( org.eclipse.sisu.bean.alpha.SisuOverriddenPublic.class ).results() );
assertEquals( "cdAB", injector.getInstance( org.eclipse.sisu.bean.alpha.OverriddenProtected.class ).results() );
assertEquals( "dABC", injector.getInstance( org.eclipse.sisu.bean.alpha.OverriddenPackage.class ).results() );
assertEquals( "dABCD", injector.getInstance( org.eclipse.sisu.bean.alpha.OverriddenPrivate.class ).results() );
Expand All @@ -63,6 +66,8 @@ void testOverriddenLifecycle()

assertEquals( "bcdAZwxy",
injector.getInstance( org.eclipse.sisu.bean.alpha.OverriddenPublic.class ).results() );
assertEquals( "bcdAZwxy",
injector.getInstance( org.eclipse.sisu.bean.alpha.SisuOverriddenPublic.class ).results() );
assertEquals( "cdABYZwx",
injector.getInstance( org.eclipse.sisu.bean.alpha.OverriddenProtected.class ).results() );
assertEquals( "dABCXYZw",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright (c) 2010-present Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Stuart McCulloch (Sonatype, Inc.) - initial API and implementation
*******************************************************************************/
package org.eclipse.sisu.bean.alpha;

import org.eclipse.sisu.PostConstruct;
import org.eclipse.sisu.PreDestroy;

import javax.inject.Singleton;

@Singleton
public class SisuOverriddenPublic
extends Private
{
@Override
@PostConstruct
public void a()
{
results.append( "A" );
}

@Override
@PreDestroy
public void z()
{
results.append( "Z" );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2010-present Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Stuart McCulloch (Sonatype, Inc.) - initial API and implementation
*******************************************************************************/
package org.eclipse.sisu.bean.alpha;

import org.eclipse.sisu.PostConstruct;
import org.eclipse.sisu.PreDestroy;

import javax.inject.Singleton;

@Singleton
public class SisuPublic
extends Base
{
@PostConstruct
public void a()
{
results.append( "a" );
}

@PreDestroy
public void z()
{
results.append( "z" );
}
}

0 comments on commit c8f5129

Please sign in to comment.