-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5d8821
commit bc88893
Showing
5 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...ava/com/dotmarketing/startup/runonce/Task240131UpdateLanguageVariableContentTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.dotmarketing.startup.runonce; | ||
|
||
import com.dotcms.contenttype.exception.NotFoundInDbException; | ||
import com.dotcms.languagevariable.business.LanguageVariableAPI; | ||
import com.dotcms.util.IntegrationTestInitService; | ||
import com.dotmarketing.business.APILocator; | ||
import com.dotmarketing.business.CacheLocator; | ||
import com.dotmarketing.common.db.DotConnect; | ||
import com.dotmarketing.exception.DotDataException; | ||
import com.dotmarketing.exception.DotSecurityException; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.sql.SQLException; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class Task240131UpdateLanguageVariableContentTypeTest { | ||
@BeforeClass | ||
public static void prepare() throws Exception { | ||
// Setting web app environment | ||
IntegrationTestInitService.getInstance().init(); | ||
} | ||
|
||
@Test | ||
public void testExecuteUpgrade() throws DotDataException, SQLException, DotSecurityException { | ||
try { | ||
APILocator.getContentTypeAPI(APILocator.systemUser()).find(LanguageVariableAPI.LANGUAGEVARIABLE); | ||
}catch (NotFoundInDbException e){ | ||
//Create LanguageVariable Content Type in case doesn't exist | ||
Task04210CreateDefaultLanguageVariable upgradeTaskCreateLanguageVariable = new Task04210CreateDefaultLanguageVariable(); | ||
upgradeTaskCreateLanguageVariable.executeUpgrade(); | ||
} | ||
//Update system to true in case it's false | ||
final DotConnect dc = new DotConnect(); | ||
dc.setSQL("update structure set system = true where velocity_var_name = ?"); | ||
dc.addParam(LanguageVariableAPI.LANGUAGEVARIABLE); | ||
dc.loadResult(); | ||
//Flush cache to get latest changes | ||
CacheLocator.getContentTypeCache2().clearCache(); | ||
//System must be true | ||
assertTrue(APILocator.getContentTypeAPI(APILocator.systemUser()).find(LanguageVariableAPI.LANGUAGEVARIABLE).system()); | ||
//Run UT | ||
Task240131UpdateLanguageVariableContentType upgradeTask = new Task240131UpdateLanguageVariableContentType(); | ||
upgradeTask.executeUpgrade(); | ||
//Flush cache to get latest changes | ||
CacheLocator.getContentTypeCache2().clearCache(); | ||
//System must be false | ||
assertFalse(APILocator.getContentTypeAPI(APILocator.systemUser()).find(LanguageVariableAPI.LANGUAGEVARIABLE).system()); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...in/java/com/dotmarketing/startup/runonce/Task240131UpdateLanguageVariableContentType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.dotmarketing.startup.runonce; | ||
|
||
import com.dotcms.languagevariable.business.LanguageVariableAPI; | ||
import com.dotmarketing.common.db.DotConnect; | ||
import com.dotmarketing.exception.DotDataException; | ||
import com.dotmarketing.exception.DotRuntimeException; | ||
import com.dotmarketing.startup.StartupTask; | ||
|
||
/** | ||
* This UT is to update the column system for the Language Variable Content Type. This value needs to be false | ||
* since system content types are being hidden from the Content Search Portlet. | ||
*/ | ||
public class Task240131UpdateLanguageVariableContentType implements StartupTask { | ||
@Override | ||
public boolean forceRun() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void executeUpgrade() throws DotDataException, DotRuntimeException { | ||
final DotConnect dc = new DotConnect(); | ||
dc.setSQL("update structure set system = false where velocity_var_name = ?"); | ||
dc.addParam(LanguageVariableAPI.LANGUAGEVARIABLE); | ||
dc.loadResult(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters